Flexslider stop at first slide after loop

亡梦爱人 提交于 2019-12-23 18:46:51

问题


I am trying to get the Flexslider to make a full loop and then stop or pause once it gets back to the first slide. Here is my code so far:

$(window).load(function(){
    $('.flexslider').flexslider({
        animation: "slide",
        animationLoop: true, 
        slideshowSpeed: 5000,
        pauseOnHover: true,
        start: function(slider){
            $('body').removeClass('loading');
        }   
    });
});

回答1:


Try with this:

$(window).load(function(){
    $('.flexslider').flexslider({
        animation: "slide",
        animationLoop: true, 
        slideshowSpeed: 5000,
        pauseOnHover: true,
        start: function(slider){
            $('body').removeClass('loading');
        },
        after: function (slider) {
            if ((slider.currentSlide + 1) == slider.count) {
                 slider.pause();
            }
        }
    });
});



回答2:


Try this, it worked for me

$(window).load(function(){
    var loopCount = 0; 
    $('.flexslider').flexslider({
        animation: "slide",
        animationLoop: true, 
        slideshowSpeed: 5000,
        pauseOnHover: true,
        start: function(slider){
            $('body').removeClass('loading');
        },
        after : function(slider){
           if(slider.currentSlide == 0 && loopCount == 1){
             slider.pause();
           }   
        },
        end : function(slider){
          loopCount++;  
        }
    });
});



回答3:


Use this to pause at first slide after looping specific times. change var n value to loop as many time you wish.

var n = 2; 
$('.flexslider').flexslider({
    animation: "slide",
    slideshowSpeed: 5000,
    start: function(slider) {
        $('body').removeClass('loading');
    },
    after: function(slider) {
        if (slider.currentSlide == 0) { // is last slide
            n--;
            if(n==0) {
                slider.pause();
            }
        }
    }
});


来源:https://stackoverflow.com/questions/16072307/flexslider-stop-at-first-slide-after-loop

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