Jquery Nivo Slider set delay time for each slide

会有一股神秘感。 提交于 2019-12-02 02:13:55

问题


We are using a special system that allows our users to set a delay between slides and whether or not the image contains a link. We were using mootools for the slideshow but wish to update to nivoSlider.

A php script exports the following as per our old system requirements

var data = {
'0225201274127_1.jpg': {delay:4000},
'0225201274417_4.jpg': {delay:3000},
'0225201274624_9.jpg': {delay:5000},
'0225201274607_8.jpg': {delay:3000},
'0225201274456_6.jpg': {delay:6000},
'0225201274521_7.jpg': {delay:7000},
'0225201274435_5.jpg': {delay:3000},
'0225201274338_2.jpg': {delay:2000},
'0225201274647_10.jpg': {delay:1000},
'0225201274359_3.jpg': {delay:6000},
'0225201274707_11.jpg': {delay:4000}
};

I am simply looking for a way to set the delays above to the individual images in the slideshow.

If needed I can reconfigure the output. We have been trying different methods all day without success.


回答1:


I'm using an array with 'afterLoad' and it works good.

  var delays = [4000,3000,5000,3000]; //your delay array

    function pageLoad() {
        $(function () {
            $('#slider').nivoSlider({
                pauseTime: 50000,
                directionNav: true,
                afterChange: function () { setDelay() },
                afterLoad: function () { setDelay() },
                controlNav: true,
                pauseOnHover: false
            });
        });
    }

    function setDelay() {
        var currentSlide = $('#slider').data("nivo:vars").currentSlide;
        setTimeout(function () {
            $('#slider').find('a.nivo-nextNav').click()
        }, delays[currentSlide]);

    }

hope this helps. The rest of your html is standar nivo layout



来源:https://stackoverflow.com/questions/13315904/jquery-nivo-slider-set-delay-time-for-each-slide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!