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]);