diff --git a/src/FlexScrollView.js b/src/FlexScrollView.js index 1e0a7ca..921e5e3 100644 --- a/src/FlexScrollView.js +++ b/src/FlexScrollView.js @@ -522,11 +522,11 @@ define(function(require, exports, module) { * Delegates any scroll force to leading/trailing scrollviews. * @private */ - FlexScrollView.prototype.releaseScrollForce = function(delta, velocity) { + FlexScrollView.prototype.releaseScrollForce = function(delta, velocity, detectSwipes) { var leadingScrollView = this.options.leadingScrollView; var trailingScrollView = this.options.trailingScrollView; if (!leadingScrollView && !trailingScrollView) { - return ScrollController.prototype.releaseScrollForce.call(this, delta, velocity); + return ScrollController.prototype.releaseScrollForce.call(this, delta, velocity, detectSwipes); } var partialDelta; if (delta < 0) { @@ -534,19 +534,19 @@ define(function(require, exports, module) { partialDelta = Math.max(this._leadingScrollViewDelta, delta); this._leadingScrollViewDelta -= partialDelta; delta -= partialDelta; - leadingScrollView.releaseScrollForce(this._leadingScrollViewDelta, delta ? 0 : velocity); + leadingScrollView.releaseScrollForce(this._leadingScrollViewDelta, delta ? 0 : velocity, detectSwipes); } if (trailingScrollView) { partialDelta = Math.max(this._thisScrollViewDelta, delta); this._thisScrollViewDelta -= partialDelta; delta -= partialDelta; - ScrollController.prototype.releaseScrollForce.call(this, this._thisScrollViewDelta, delta ? 0 : velocity); + ScrollController.prototype.releaseScrollForce.call(this, this._thisScrollViewDelta, delta ? 0 : velocity, detectSwipes); this._trailingScrollViewDelta -= delta; - trailingScrollView.releaseScrollForce(this._trailingScrollViewDelta, delta ? velocity : 0); + trailingScrollView.releaseScrollForce(this._trailingScrollViewDelta, delta ? velocity : 0, detectSwipes); } else { this._thisScrollViewDelta -= delta; - ScrollController.prototype.releaseScrollForce.call(this, this._thisScrollViewDelta, delta ? velocity : 0); + ScrollController.prototype.releaseScrollForce.call(this, this._thisScrollViewDelta, delta ? velocity : 0, detectSwipes); } } else { @@ -554,19 +554,19 @@ define(function(require, exports, module) { partialDelta = Math.min(this._trailingScrollViewDelta, delta); this._trailingScrollViewDelta -= partialDelta; delta -= partialDelta; - trailingScrollView.releaseScrollForce(this._trailingScrollViewDelta, delta ? 0 : velocity); + trailingScrollView.releaseScrollForce(this._trailingScrollViewDelta, delta ? 0 : velocity, detectSwipes); } if (leadingScrollView) { partialDelta = Math.min(this._thisScrollViewDelta, delta); this._thisScrollViewDelta -= partialDelta; delta -= partialDelta; - ScrollController.prototype.releaseScrollForce.call(this, this._thisScrollViewDelta, delta ? 0 : velocity); + ScrollController.prototype.releaseScrollForce.call(this, this._thisScrollViewDelta, delta ? 0 : velocity, detectSwipes); this._leadingScrollViewDelta -= delta; - leadingScrollView.releaseScrollForce(this._leadingScrollViewDelta, delta ? velocity : 0); + leadingScrollView.releaseScrollForce(this._leadingScrollViewDelta, delta ? velocity : 0, detectSwipes); } else { this._thisScrollViewDelta -= delta; - ScrollController.prototype.updateScrollForce.call(this, this._thisScrollViewDelta, delta ? velocity : 0); + ScrollController.prototype.updateScrollForce.call(this, this._thisScrollViewDelta, delta ? velocity : 0, detectSwipes); } } return this; diff --git a/src/ScrollController.js b/src/ScrollController.js index f794a34..bce54a4 100644 --- a/src/ScrollController.js +++ b/src/ScrollController.js @@ -442,7 +442,9 @@ define(function(require, exports, module) { } // Release scroll force - this.releaseScrollForce(this._scroll.mouseMove.delta, velocity); + var swipeDirection = (Math.abs(this._scroll.mouseMove.current[0] - this._scroll.mouseMove.prev[0]) > Math.abs(this._scroll.mouseMove.current[1] - this._scroll.mouseMove.prev[1])) ? 0 : 1; + var allowSwipes = (swipeDirection === this._direction); + this.releaseScrollForce(this._scroll.mouseMove.delta, velocity, allowSwipes); this._scroll.mouseMove = undefined; } @@ -609,7 +611,9 @@ define(function(require, exports, module) { // Release scroll force var delta = this._scroll.touchDelta; - this.releaseScrollForce(delta, velocity); + var swipeDirection = (Math.abs(primaryTouch.current[0] - primaryTouch.prev[0]) > Math.abs(primaryTouch.current[1] - primaryTouch.prev[1])) ? 0 : 1; + var allowSwipes = (swipeDirection === this._direction); + this.releaseScrollForce(delta, velocity, allowSwipes); this._scroll.touchDelta = 0; } @@ -1651,7 +1655,7 @@ define(function(require, exports, module) { * @param {Number} [velocity] Velocity to apply after which the view keeps scrolling * @return {ScrollController} this */ - ScrollController.prototype.releaseScrollForce = function(delta, velocity) { + ScrollController.prototype.releaseScrollForce = function(delta, velocity, detectSwipes) { this.halt(); if (this._scroll.scrollForceCount === 1) { var scrollOffset = _calcScrollOffset.call(this); @@ -1665,7 +1669,7 @@ define(function(require, exports, module) { if (item.renderNode !== this._scroll.scrollForceStartItem.renderNode) { this.goToRenderNode(item.renderNode); } - else if (this.options.paginationEnergyThreshold && (Math.abs(this._scroll.particle.getEnergy()) >= this.options.paginationEnergyThreshold)) { + else if (detectSwipes && this.options.paginationEnergyThreshold && (Math.abs(this._scroll.particle.getEnergy()) >= this.options.paginationEnergyThreshold)) { velocity = velocity || 0; if ((velocity < 0) && item._node._next && item._node._next.renderNode) { this.goToRenderNode(item._node._next.renderNode);