Search code examples
javascriptjquerybxslider

How to use "stopAuto" function in bxslider?


I have a bx slider which has 6 images. I want to go through each of them once then stop for a second and then begin again, then stop for one second again etc. It's mentioned here (http://bxslider.com/options) but with no full example.

This is the code I have now. It doesn't stop navigation images.

<script>
$('.bxslider').bxSlider({
    auto: true,
    autoControls: true,
    speed: 1,
    pause:200
});
</script>

Sorry for the lame question. I am a still a newbie to jQuery.


Solution

  • Set autoDelay option and onSlideAfter function

    Demo: http://jsfiddle.net/3h0ewwz4/

    var slider = $('.bxslider').bxSlider({
        auto: true,
        autoDelay:2000,
        onSlideAfter: function (slide, oldIndex, newIndex) { // add this function to solve issue
          if (newIndex === 5) { // remember, it's zero based indices with bxslider...5 is index of last image
            slider.stopAuto();
            setTimeout(function () {
                slider.goToSlide(0);
                slider.startAuto();
            }, 2000);
          }
        },
        autoControls: true,
        speed: 1,
        pause:200
    });