Skip to content

Commit

Permalink
Loop fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Apr 1, 2018
1 parent 429a6c6 commit 68af09c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/core/events/onTouchEnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default function (event) {
let doBounce = false;
let afterBouncePosition;
const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio;
let needsLoopFix;
if (newPosition < swiper.maxTranslate()) {
if (params.freeModeMomentumBounce) {
if (newPosition + swiper.maxTranslate() < -bounceAmount) {
Expand All @@ -125,6 +126,7 @@ export default function (event) {
} else {
newPosition = swiper.maxTranslate();
}
if (params.loop && params.centeredSlides) needsLoopFix = true;
} else if (newPosition > swiper.minTranslate()) {
if (params.freeModeMomentumBounce) {
if (newPosition - swiper.minTranslate() > bounceAmount) {
Expand All @@ -136,6 +138,7 @@ export default function (event) {
} else {
newPosition = swiper.minTranslate();
}
if (params.loop && params.centeredSlides) needsLoopFix = true;
} else if (params.freeModeSticky) {
let nextSlide;
for (let j = 0; j < snapGrid.length; j += 1) {
Expand All @@ -152,6 +155,11 @@ export default function (event) {
}
newPosition = -newPosition;
}
if (needsLoopFix) {
swiper.once('transitionEnd', () => {
swiper.loopFix();
});
}
// Fix duration
if (swiper.velocity !== 0) {
if (rtl) {
Expand Down

0 comments on commit 68af09c

Please sign in to comment.