When Slick calls beforeChange, it passes prevSlide and nextSlide. This cannot be used to determine the direction of the slide in case of infinity loop.
+1
@brsanthu I'm sure this could be cleaner but it gets the job done for now (at least in beforeChange):
if ((currentSlide > nextSlide && (nextSlide !== 0 || currentSlide === 1)) || (currentSlide === 0 && nextSlide === slick.slideCount - 1)) {
console.log('previous');
}
else {
console.log('next');
}
@drastick thank you
+1
@drastick unfortunately this will not work for only 2 slides, otherwise perfect
@drastick Works for an infinite loop's autoplay or previous/next buttons. But it doesn't work for the dots.
+1
+1
+1
@drastick Your solution works! Tks!
Thank you....
Most helpful comment
@brsanthu I'm sure this could be cleaner but it gets the job done for now (at least in beforeChange):