Reputation: 1221
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. 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);
});
Upvotes: 1
Views: 654
Reputation: 556
Add the option afterAction to your 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.
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
}
}
Upvotes: 1