When "loop: false", pulling and releasing past the bounds, restores to position instantaneously
Opened this issue · 3 comments
Deleted user commented
On iPad, with "loop: false", when you drag past the first or last page and release your finger, the page instantly snaps back instead of smoothly animating back to its position.
The native swiper does smoothly animate back to its position, so it looks rather odd in an app.
Deleted user commented
I fixed it by changing this code in _end()
// Check if we exceeded the snap threshold
if (dist < this.snapThreshold) {
this.slider.style[transitionDuration] = Math.floor(300 * dist / this.snapThreshold) + 'ms';
this.__pos(-this.page * this.pageWidth);
return;
}
to:
// Check if we exceeded the snap threshold
if (dist < this.snapThreshold) {
this.slider.style[transitionDuration] = 400 + 'ms';
this.__pos(-this.page * this.pageWidth);
return;
}
MathieuLoutre commented
Indeed, it happens because a couple of lines before dist
is set to 0
. If you want to keep the original formula, you can replace dist with Math.abs(point.pageX - this.startX)
and it should work.
linlex commented
its realy nice resolve