Skip to content

Commit

Permalink
fix(core): fix slideToClickedSlide when using Element slide slots
Browse files Browse the repository at this point in the history
fixes #6958
  • Loading branch information
nolimits4web committed Aug 30, 2023
1 parent e4fddc0 commit af0519c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/events/onTouchEnd.mjs
Expand Up @@ -51,7 +51,7 @@ export default function onTouchEnd(event) {
// Tap, doubleTap, Click
if (swiper.allowClick) {
const pathTree = e.path || (e.composedPath && e.composedPath());
swiper.updateClickedSlide((pathTree && pathTree[0]) || e.target);
swiper.updateClickedSlide((pathTree && pathTree[0]) || e.target, pathTree);
swiper.emit('tap click', e);
if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
swiper.emit('doubleTap doubleClick', e);
Expand Down
11 changes: 9 additions & 2 deletions src/core/update/updateClickedSlide.mjs
@@ -1,7 +1,14 @@
export default function updateClickedSlide(e) {
export default function updateClickedSlide(el, path) {
const swiper = this;
const params = swiper.params;
const slide = e.closest(`.${params.slideClass}, swiper-slide`);
let slide = el.closest(`.${params.slideClass}, swiper-slide`);
if (!slide && swiper.isElement && path && path.length > 1 && path.includes(el)) {
[...path.slice(path.indexOf(el) + 1, path.length)].forEach((pathEl) => {
if (!slide && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) {
slide = pathEl;
}
});
}
let slideFound = false;
let slideIndex;

Expand Down

0 comments on commit af0519c

Please sign in to comment.