diff --git a/src/swipeview.js b/src/swipeview.js index 56b0a00..2cad49f 100644 --- a/src/swipeview.js +++ b/src/swipeview.js @@ -66,7 +66,8 @@ var SwipeView = (function (window, document) { numberOfPages: 3, snapThreshold: null, hastyPageFlip: false, - loop: true + loop: true, + touchOffset: [0, 0] }; // User defined options @@ -177,6 +178,10 @@ var SwipeView = (function (window, document) { this.options.numberOfPages = n; this.maxX = -this.options.numberOfPages * this.pageWidth + this.wrapperWidth; }, + + updateTouchOffset: function (x, y) { + this.options.touchOffset = [x, y]; + }, goToPage: function (p) { var i; @@ -291,14 +296,15 @@ var SwipeView = (function (window, document) { this.initiated = true; this.moved = false; this.thresholdExceeded = false; - this.startX = point.pageX; - this.startY = point.pageY; - this.pointX = point.pageX; - this.pointY = point.pageY; + this.startX = point.pageX - this.options.touchOffset[0]; + this.startY = point.pageY - this.options.touchOffset[1]; + this.pointX = point.pageX - this.options.touchOffset[0]; + this.pointY = point.pageY - this.options.touchOffset[1]; this.stepsX = 0; this.stepsY = 0; this.directionX = 0; this.directionLocked = false; + this.updateTouchOffset(0, 0); /* var matrix = getComputedStyle(this.slider, null).webkitTransform.replace(/[^0-9-.,]/g, '').split(','); this.x = matrix[4] * 1;*/