diff --git a/src/swipeview.js b/src/swipeview.js index 56b0a00..b6e0340 100644 --- a/src/swipeview.js +++ b/src/swipeview.js @@ -315,7 +315,10 @@ var SwipeView = (function (window, document) { deltaX = point.pageX - this.pointX, deltaY = point.pageY - this.pointY, newX = this.x + deltaX, - dist = Math.abs(point.pageX - this.startX); + dist = Math.abs(point.pageX - this.startX), + wrapperBound = this.wrapper.getBoundingClientRect(), + absoluteWrapperLeft = wrapperBound.left + window.pageXOffset, + absoluteWrapperRight = absoluteWrapperLeft + wrapperBound.width; this.moved = true; this.pointX = point.pageX; @@ -336,6 +339,14 @@ var SwipeView = (function (window, document) { return; } + // If using touch we need to determine if the user swiped outside of the bounds of the + // container. This is not an issue for non touch which would never get in here. + if(hasTouch){ + if (point.pageX < absoluteWrapperLeft || point.pageX > absoluteWrapperRight){ + return; + } + } + e.preventDefault(); this.directionLocked = true;