how can i change nivo slider parameters while it's running?

iHaveacomputer picture iHaveacomputer · Nov 25, 2011 · Viewed 20.1k times · Source

So i have a NivoSlider on my page. My problem is that i want the first slide only to show for 2 seconds, and all the other slides for 5 seconds (first one is only some text "Product version 2 is here"). How can i do this? i didn't find any (good) documentation at http://nivo.dev7studios.com/support/ .

here is what i tried:

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
        pauseTime:2000,
        pauseOnHover: false,
        controlNav:false,
        directionNav:true,
        directionNavHide:true,
        effect:'sliceDown',
        captionOpacity: 0.9,
        afterChange: function(){$('#slider').nivoSlider().defaults({pauseTime:5000})}       
    });
});
</script>

the last line here afterChange: function(){$('#slider').nivoSlider().defaults({pauseTime:5000})} is called, but the my attemp to change the initial settings fails - it only destroys the animations (flips from one slide to the next without anim) and does not change the pause time.

does anyone know how to change the pause/delay between the slides during runtime?

Answer

user1359111 picture user1359111 · Sep 26, 2012

I had this same problem as I had a page with 3 sliders on it, where we wanted 1 to change every 5 seconds, which meant while each one had a 15 second pauseTime, the second one needed a 5 second delay, and the 3rd needed a 10 second delay. I tried the above solutions and many others but couldn't get it to work with the mutliple sliders. I ended up fixing it by adding a new setting "recurPauseTime" and then adding the following to the nivo:animFinished function:

clearInterval(timer);
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.recurPauseTime);

This allowed me to set it up like:

slider1:

pauseTime: 5000,
recurPauseTime:15000 

slider2:

pauseTime: 10000,
recurPauseTime:15000 

slider3:

pauseTime: 15000,
recurPauseTime:15000