Emann Tumala Saligue
Emann Tumala Saligue

Reputation: 145

idangero sliders startAutoplay after swipe not working

Hello, I am using the iDangero.us Slider and I have a problem resuming the replay/autoplay after swiping.

Here are the program details: "Create an iPad slider that has autoplay and a clickable pagination button. If the user stops using/swiping the slider, it will resume autoplay without refreshing the page."

<script>
    var mySwiper = new Swiper('.swiper-container',{
        pagination: '.pagination',
        loop:true,
        autoplay: 2000,
        speed:1000,
        autoResize:true,
        paginationClickable: true,
        onTouchStart : function() {
            slideTouched();
        }
    })

    $('.pagination').on('click',function() {
        mySwiper.stopAutoplay();
        mySwiper.params.autoplay = 10000;
        mySwiper.startAutoplay();
    });

    var timer = null;
    function slideTouched(){
        mySwiper.stopAutoplay();
        mySwiper.params.autoplay = 10000
        mySwiper.startAutoplay();
    }
</script>

I believe the problem is in the function slideTouched(). I don't think mySwiper is defined inside of the function. Please help me fix the autoplay feature after swiping.

Upvotes: 1

Views: 6605

Answers (2)

worlock
worlock

Reputation: 300

Set this parameter:

autoplayDisableOnInteraction:false

Upvotes: 3

Josh Durham
Josh Durham

Reputation: 1662

Your live demo code in the link you provided has the slideTouched() function defined as

function slideTouched(){
    Swiper.stopAutoplay();
    Swiper.params.autoplay = 10000
    Swiper.startAutoplay();
}

when it should be

function slideTouched(){
    mySwiper.stopAutoplay();
    mySwiper.params.autoplay = 10000;
    mySwiper.startAutoplay();
}

You want to reference the Swiper object you used to create the slideshow.

Upvotes: 1

Related Questions