-
I'm trying to get the active slide after the slider has finished moving like so: slider.on('moved', function() {
const active_slide = document.querySelector('.splide__slide.is-active.is-visible');
console.log(active_slide);
}); However, this logs I tried listening for the active event instead and getting the slide component from its callback, and that works, but only if the active slide changes. I need to get the active slide even if it doesn't change. I also tried adding a short timeout inside the moved event handler, and that works too, but I want to avoid using a timeout. The moved event returns the new slide index, could I somehow use that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After digging through the docs, I came up with this solution: slider.on('moved', function(newIndex) {
const active_slide = slider.Components.Slides.getAt(newIndex).slide;
console.log(active_slide);
}); |
Beta Was this translation helpful? Give feedback.
After digging through the docs, I came up with this solution: