谁能帮我添加正确的 Autoplay Wallop 滑块
Who could help me to add a correct Autoplay Wallop slider
我已将自动播放功能添加到 Wallop 滑块,我正尝试在用户单击键盘上的左箭头或右箭头后重新启动。问题,如果你多次点击其中一个箭头,幻灯片就会变得奇怪 ^^
这是我的作品:http://codepen.io/Le-future/pen/Nxexrw
$(document).ready(function(){
"use strict";
var wallopEl = document.querySelector('.Wallop');
var slider = new Wallop(wallopEl);
var timer = setInterval('$(".Wallop .Wallop-buttonNext").click()', 5000); //assign timer to a variable
$(document).keydown( function(eventObject) {
if(eventObject.which==37) {//left arrow
$('.Wallop .Wallop-buttonPrevious').click();//emulates click on prev button
clearInterval(timer); //clear interval
setTimeout(function() {
var timer = setInterval('$(".Wallop .Wallop-buttonNext").click()', 5000); //start it again
}, 8000);
}
else if(eventObject.which==39) {//right arrow
$('.Wallop .Wallop-buttonNext').click();//emulates click on next button
clearInterval(timer); //clear interval
setTimeout(function() {
var timer = setInterval('$(".Wallop .Wallop-buttonNext").click()', 5000); //start it again
}, 8000);
}
});
});
请不要犹豫,按两次以上键盘箭头查看问题。
提前感谢您的帮助:-)
从存储库中查看此代码示例:
jQuery(document).ready(function() {
var photoslider = new WallopSlider('.photo-slider');
var count = photoslider.allItemsArrayLength;
var start = photoslider.currentItemIndex;
var end = count+1;
var index = start;
jQuery(function(){
setInterval(function() {
photoslider.goTo(index);
++index;
if (index == end) {index=start}
},3000);
});
});
另请查看 http://codepen.io/peduarte/pen/wKwbYJ
和 http://codepen.io/peduarte/pen/RapQBB
我已将自动播放功能添加到 Wallop 滑块,我正尝试在用户单击键盘上的左箭头或右箭头后重新启动。问题,如果你多次点击其中一个箭头,幻灯片就会变得奇怪 ^^
这是我的作品:http://codepen.io/Le-future/pen/Nxexrw
$(document).ready(function(){
"use strict";
var wallopEl = document.querySelector('.Wallop');
var slider = new Wallop(wallopEl);
var timer = setInterval('$(".Wallop .Wallop-buttonNext").click()', 5000); //assign timer to a variable
$(document).keydown( function(eventObject) {
if(eventObject.which==37) {//left arrow
$('.Wallop .Wallop-buttonPrevious').click();//emulates click on prev button
clearInterval(timer); //clear interval
setTimeout(function() {
var timer = setInterval('$(".Wallop .Wallop-buttonNext").click()', 5000); //start it again
}, 8000);
}
else if(eventObject.which==39) {//right arrow
$('.Wallop .Wallop-buttonNext').click();//emulates click on next button
clearInterval(timer); //clear interval
setTimeout(function() {
var timer = setInterval('$(".Wallop .Wallop-buttonNext").click()', 5000); //start it again
}, 8000);
}
});
});
请不要犹豫,按两次以上键盘箭头查看问题。
提前感谢您的帮助:-)
从存储库中查看此代码示例:
jQuery(document).ready(function() {
var photoslider = new WallopSlider('.photo-slider');
var count = photoslider.allItemsArrayLength;
var start = photoslider.currentItemIndex;
var end = count+1;
var index = start;
jQuery(function(){
setInterval(function() {
photoslider.goTo(index);
++index;
if (index == end) {index=start}
},3000);
});
});
另请查看 http://codepen.io/peduarte/pen/wKwbYJ 和 http://codepen.io/peduarte/pen/RapQBB