问题
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