Skip to content

Commit

Permalink
fix(core): fix beforeSlideChangeStart event routing
Browse files Browse the repository at this point in the history
fixes #5913
  • Loading branch information
nolimits4web committed Sep 14, 2022
1 parent f01bf9a commit 0e8a8b8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/slide/slideTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,8 @@ export default function slideTo(
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;

if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) {
swiper.emit('beforeSlideChangeStart');
}

const translate = -snapGrid[snapIndex];

// Update progress
swiper.updateProgress(translate);

// Normalize slideIndex
if (params.normalizeSlideIndex) {
for (let i = 0; i < slidesGrid.length; i += 1) {
Expand Down Expand Up @@ -114,6 +107,13 @@ export default function slideTo(
}
}

if (slideIndex !== (previousIndex || 0) && runCallbacks) {
swiper.emit('beforeSlideChangeStart');
}

// Update progress
swiper.updateProgress(translate);

let direction;
if (slideIndex > activeIndex) direction = 'next';
else if (slideIndex < activeIndex) direction = 'prev';
Expand Down

0 comments on commit 0e8a8b8

Please sign in to comment.