简体   繁体   English

如何检测最后一张幻灯片和第一张幻灯片?

[英]How to detect the last slide and first slide in slick?

I am trying to detect the first slide and last slide using slick.js.我正在尝试使用 slick.js 检测第一张幻灯片和最后一张幻灯片。 https://github.com/kenwheeler/slick How can I do that? https://github.com/kenwheeler/slick我该怎么做?

There is couple of events you can use to detect this:您可以使用几个事件来检测这一点:

beforeChange更改前

$('.slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  console.log(nextSlide);
});

afterChange更改后

$('.slider').on('afterChange', function(event, slick, currentSlide){
  console.log(currentSlide);
});

swipe刷卡

$('.slider').on('swipe', function(event, slick, direction){
  console.log(direction);
  // left
});

Let me know if this works for u.让我知道这是否适合你。

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM