Skip to content

Commit

Permalink
fix(core): correcly update slideIndex when other elements are present…
Browse files Browse the repository at this point in the history
… in slides wrapper
  • Loading branch information
ettoredn committed Feb 21, 2021
1 parent c6f0c12 commit 21e7713
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/core/update/updateClickedSlide.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ export default function updateClickedSlide(e) {
const params = swiper.params;
const slide = $(e.target).closest(`.${params.slideClass}`)[0];
let slideFound = false;
let slideIndex;

if (slide) {
for (let i = 0; i < swiper.slides.length; i += 1) {
if (swiper.slides[i] === slide) slideFound = true;
if (swiper.slides[i] === slide) {
slideFound = true;
slideIndex = i;
break;
}
}
}

Expand All @@ -16,7 +22,7 @@ export default function updateClickedSlide(e) {
if (swiper.virtual && swiper.params.virtual.enabled) {
swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10);
} else {
swiper.clickedIndex = $(slide).index();
swiper.clickedIndex = slideIndex;
}
} else {
swiper.clickedSlide = undefined;
Expand Down

0 comments on commit 21e7713

Please sign in to comment.