2
我想知道是否可以创建一个Unslider图片滑动条,其中某些幻灯片的暂停长度是不同的?例如,我希望幻灯片1显示5秒钟,幻灯片2显示10秒钟。谢谢!Unslider为每张幻灯片设置不同的暂停长度
我想知道是否可以创建一个Unslider图片滑动条,其中某些幻灯片的暂停长度是不同的?例如,我希望幻灯片1显示5秒钟,幻灯片2显示10秒钟。谢谢!Unslider为每张幻灯片设置不同的暂停长度
Unslider没有内置此功能,所以我们必须使用Unslider的方法和一些jQuery自己做。这是我遇到同样问题时想到的。
“自动播放”选项是错误的(默认设置),这个工作:
// Initialize Unslider
var slider = jQuery('#unslider').unslider();
// Array of the times you want for each slide.
var slideTimes = [5000,10000];
// Move the slider to the next slide and start the timer
function timeToNextSlide(ms){
slideTimeout = setTimeout(function(){
slider.data('unslider')['next']();
}, ms);
}
// Every time the slide changes
slider.on('unslider.change', function(event, index, slide) {
// Clear the timeout in case user clicks the navigation
clearTimeout(slideTimeout);
// Reset the timeout to the next slide's time
timeToNextSlide(slideTimes[index]);
});
// Start the slider
timeToNextSlide(slideTimes[0]);