[英]Stop slide when it reaches the last slide
How can the slide be stopped when the last slide is reached in Owl Carousel? 在“猫头鹰轮播”中到达最后一张幻灯片时,如何停止幻灯片? I have done it on
click
function using the below code. 我已经使用以下代码在
click
功能上完成了此操作。 Now, I want to achieve the same when the last slide is reached 现在,我想在到达最后一张幻灯片时实现相同的效果
$(".btn-skip").click(function () {
owl.data('owlCarousel').reinit({
touchDrag: false,
mouseDrag: false
});
owl.trigger('owl.jumpTo', 2);
});
Add the option afterAction to your owl init. 将afterAction选项添加到您的owl init中。
owl.owlCarousel({
afterAction : afterAction
});
Then, on the function declared on afterAction, evaluate if owlItems.length its equal to the current owl item plus the visible items. 然后,在afterAction上声明的函数上,计算owlItems.length是否等于当前owl项加上可见项。
function afterAction(){
//Get an array of items from the variable visibleItems, then get the length of that array
var numOfVisibleItems = this.owl.visibleItems.split(',').length();
if(this.owl.currentItem + numOfVisibleItems == this.owl.owlItems.length){
//Here the code you want to do after the owlCarousel reach its end
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.