Skip to content

Commit

Permalink
fix(core): fixed ignored allowSlidePrev/Next in loop mode
Browse files Browse the repository at this point in the history
fixes #6987
  • Loading branch information
nolimits4web committed Aug 30, 2023
1 parent 8180a52 commit 1b74619
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/events/onTouchMove.mjs
Expand Up @@ -149,9 +149,11 @@ export default function onTouchMove(event) {
swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';

const isLoop = swiper.params.loop && !params.cssMode;

const allowLoopFix =
(swiper.swipeDirection === 'next' && swiper.allowSlideNext) ||
(swiper.swipeDirection === 'prev' && swiper.allowSlidePrev);
if (!data.isMoved) {
if (isLoop) {
if (isLoop && allowLoopFix) {
swiper.loopFix({ direction: swiper.swipeDirection });
}
data.startTranslate = swiper.getTranslate();
Expand All @@ -175,6 +177,7 @@ export default function onTouchMove(event) {
data.isMoved &&
prevTouchesDirection !== swiper.touchesDirection &&
isLoop &&
allowLoopFix &&
Math.abs(diff) >= 1
) {
// need another loop fix
Expand All @@ -194,6 +197,7 @@ export default function onTouchMove(event) {
if (diff > 0) {
if (
isLoop &&
allowLoopFix &&
!loopFixed &&
data.currentTranslate >
(params.centeredSlides ? swiper.minTranslate() - swiper.size / 2 : swiper.minTranslate())
Expand All @@ -212,6 +216,7 @@ export default function onTouchMove(event) {
} else if (diff < 0) {
if (
isLoop &&
allowLoopFix &&
!loopFixed &&
data.currentTranslate <
(params.centeredSlides ? swiper.maxTranslate() + swiper.size / 2 : swiper.maxTranslate())
Expand Down

0 comments on commit 1b74619

Please sign in to comment.