I have the following
mySwiper = new Swiper('.my-swiper', {
direction: 'vertical',
loop: true,
});
mySwiper.on('slideChange', function () {
console.log('*** mySwiper.realIndex', mySwiper.realIndex);
});
But realIndex
always returns the previous index. So if I'm on the first slide (0) and go to the next, realIndex
is 0 when it should be 1. When I go back to the first slide realIndex
is 1 when it should be 0. So it seems the event fires before the index is updated. I've tried other events but haven't had any luck. Is there an event that fires after the slide is changed so that I can capture the current slide index?
slideChange
listener that would tell you what you want, likemySwiper.on('slideChange', function (event) {...
? – Christinachristine