diff --git a/src/swipeview.js b/src/swipeview.js index 56b0a00..41cbfe2 100644 --- a/src/swipeview.js +++ b/src/swipeview.js @@ -363,7 +363,7 @@ var SwipeView = (function (window, document) { if (!this.initiated) return; var point = hasTouch ? e.changedTouches[0] : e, - dist = Math.abs(point.pageX - this.startX); + dist = point.pageX - this.startX; this.initiated = false; @@ -375,8 +375,14 @@ var SwipeView = (function (window, document) { } // Check if we exceeded the snap threshold - if (dist < this.snapThreshold) { - this.slider.style[transitionDuration] = Math.floor(300 * dist / this.snapThreshold) + 'ms'; + if (Math.abs(dist) < this.snapThreshold) { + this.slider.style.webkitTransitionDuration = Math.floor(300 * Math.abs(dist) / this.snapThreshold) + 'ms'; + this.__pos(-this.page * this.pageWidth); + return; + } + // Check if swipe was cancelled by reversing swipe direction + if ((dist < 0 && this.directionX >= 0) || (dist > 0 && this.directionX <= 0)) { + this.slider.style.webkitTransitionDuration = Math.floor(300 * Math.abs(dist) / this.pageWidth) + 'ms'; this.__pos(-this.page * this.pageWidth); return; }