Skip to content

Commit

Permalink
fix(core): fix loopFix in loop and cssMode
Browse files Browse the repository at this point in the history
fixes #6919
  • Loading branch information
nolimits4web committed Aug 30, 2023
1 parent af0519c commit 8180a52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/slide/slideNext.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ export default function slideNext(speed = this.params.speed, runCallbacks = true
swiper.loopFix({ direction: 'next' });
// eslint-disable-next-line
swiper._clientLeft = swiper.wrapperEl.clientLeft;
if (swiper.activeIndex === swiper.slides.length - 1 && params.cssMode) {
requestAnimationFrame(() => {
swiper.slideTo(swiper.activeIndex + increment);
});
return true;
}
}
if (params.rewind && swiper.isEnd) {
return swiper.slideTo(0, speed, runCallbacks, internal);
}
return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
return swiper.slideTo(swiper.activeIndex + increment);
}
5 changes: 5 additions & 0 deletions src/core/slide/slidePrev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export default function slidePrev(speed = this.params.speed, runCallbacks = true
? swiper.virtual.slides.length - 1
: swiper.slides.length - 1;
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
requestAnimationFrame(() => {
swiper.slideTo(prevIndex, speed, runCallbacks, internal);
});
return true;
}
return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
}

0 comments on commit 8180a52

Please sign in to comment.