1

在 Owl Carousel 中到达最后一张幻灯片时如何停止幻灯片?我已经click使用下面的代码在功能上完成了它。现在,我想在到达最后一张幻灯片时达到同样的效果

$(".btn-skip").click(function () {
    owl.data('owlCarousel').reinit({
        touchDrag: false,
        mouseDrag: false
    });
    owl.trigger('owl.jumpTo', 2);
});
4

1 回答 1

1

将选项 afterAction 添加到您的 owl init。

owl.owlCarousel({
      afterAction : afterAction
  });

然后,在 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
    }
} 
于 2015-08-21T13:41:37.510 回答