From d0862afeaf234786578c1d2a86883d5a6756f338 Mon Sep 17 00:00:00 2001
From: Jason
Date: Mon, 13 Nov 2023 16:24:34 +0800
Subject: [PATCH 1/2] fix(core): swipe to last with slidesPerView: auto
---
src/core/events/onTouchEnd.mjs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/core/events/onTouchEnd.mjs b/src/core/events/onTouchEnd.mjs
index ee9a4a447..ad29a069c 100644
--- a/src/core/events/onTouchEnd.mjs
+++ b/src/core/events/onTouchEnd.mjs
@@ -108,6 +108,7 @@ export default function onTouchEnd(event) {
}
// Find current slide
+ const swipeToLast = currentPos >= -swiper.maxTranslate();
let stopIndex = 0;
let groupSize = swiper.slidesSizesGrid[0];
for (
@@ -117,11 +118,11 @@ export default function onTouchEnd(event) {
) {
const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
if (typeof slidesGrid[i + increment] !== 'undefined') {
- if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
+ if (swipeToLast || (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment])) {
stopIndex = i;
groupSize = slidesGrid[i + increment] - slidesGrid[i];
}
- } else if (currentPos >= slidesGrid[i]) {
+ } else if (swipeToLast || currentPos >= slidesGrid[i]) {
stopIndex = i;
groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
}
From 1349f4a32cc1c18013b9b436acd4598de86e03c3 Mon Sep 17 00:00:00 2001
From: Vladimir Kharlampidi
Date: Wed, 22 Nov 2023 15:49:49 +0300
Subject: [PATCH 2/2] consider loop
---
src/core/events/onTouchEnd.mjs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/events/onTouchEnd.mjs b/src/core/events/onTouchEnd.mjs
index ad29a069c..4c01519ce 100644
--- a/src/core/events/onTouchEnd.mjs
+++ b/src/core/events/onTouchEnd.mjs
@@ -108,7 +108,7 @@ export default function onTouchEnd(event) {
}
// Find current slide
- const swipeToLast = currentPos >= -swiper.maxTranslate();
+ const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
let stopIndex = 0;
let groupSize = swiper.slidesSizesGrid[0];
for (