到达最后一张幻灯片时停止滑动

时间:2015-07-10 06:25:31

标签: javascript jquery owl-carousel-2

在猫头鹰转盘中到达最后一张幻灯片时如何停止幻灯片?我已使用下面的代码在click函数上完成了它。现在,我希望在达到最后一张幻灯片时实现相同的目标

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

1 个答案:

答案 0 :(得分: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
    }
} 
相关问题