admin管理员组

文章数量:1426403

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>
  • Link to live demo - /

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.

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>
  • Link to live demo - http://emannthod.0fees/stock1/

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.

Share Improve this question edited Feb 23, 2014 at 4:53 Qantas 94 Heavy 16k31 gold badges72 silver badges88 bronze badges asked Sep 25, 2013 at 11:27 Emann Tumala SaligueEmann Tumala Saligue 1454 silver badges8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Set this parameter:

autoplayDisableOnInteraction:false

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.

本文标签: javascriptidangero sliders startAutoplay after swipe not workingStack Overflow