简体   繁体   中英

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. https://github.com/kenwheeler/slick How can I do that?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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