Skip to content

Commit

Permalink
minor tweaks, allow turning off pagingDecelleration
Browse files Browse the repository at this point in the history
  • Loading branch information
natew committed Mar 4, 2015
1 parent f5b57bf commit e51bea6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/Scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ var Scroller = function (callback, options) {
/** Enable pagination mode (switching between full page content panes) */
paging: false,

/** Enable deceleration on paging animation */
pagingDeceleration: true,

/** Enable snapping of content to a configured pixel grid */
snapping: false,

Expand Down Expand Up @@ -546,7 +549,7 @@ Scroller.prototype = {
if (timeStamp instanceof Date) {
timeStamp = timeStamp.valueOf();
}
if (typeof timeStamp !== "number") {
else if (typeof timeStamp !== "number") {
throw new Error("Invalid timestamp value: " + timeStamp);
}

Expand Down Expand Up @@ -629,7 +632,7 @@ Scroller.prototype = {
if (timeStamp instanceof Date) {
timeStamp = timeStamp.valueOf();
}
if (typeof timeStamp !== "number") {
else if (typeof timeStamp !== "number") {
throw new Error("Invalid timestamp value: " + timeStamp);
}

Expand Down Expand Up @@ -734,7 +737,7 @@ Scroller.prototype = {
// Otherwise figure out whether we are switching into dragging mode now.
} else {
var minimumTrackingForScroll = this.options.locking ? 3 : 0;
var minimumTrackingForDrag = 5;
var minimumTrackingForDrag = 0;

var distanceX = Math.abs(currentTouchLeft - this.__initialTouchLeft);
var distanceY = Math.abs(currentTouchTop - this.__initialTouchTop);
Expand Down Expand Up @@ -806,8 +809,8 @@ Scroller.prototype = {
var movedTop = this.__scrollTop - positions[startPos - 1];

// Based on 50ms compute the movement to apply for each render step
this.__decelerationVelocityX = movedLeft / timeOffset * (1000 / 60);
this.__decelerationVelocityY = movedTop / timeOffset * (1000 / 60);
this.__decelerationVelocityX = movedLeft / timeOffset * 16.6667;
this.__decelerationVelocityY = movedTop / timeOffset * 16.6667;

// How much velocity is required to start the deceleration
var minVelocityToStartDeceleration = this.options.paging || this.options.snapping ? 4 : 1;
Expand Down Expand Up @@ -965,7 +968,7 @@ Scroller.prototype = {
* to switch into deceleration mode.
*/
__startDeceleration : function (timeStamp) {
if (this.options.paging) {
if (this.options.paging && this.options.pagingDeceleration) {
var scrollLeft = Math.max(Math.min(this.__scrollLeft, this.__maxScrollLeft), 0);
var scrollTop = Math.max(Math.min(this.__scrollTop, this.__maxScrollTop), 0);
var clientWidth = this.__clientWidth;
Expand Down

0 comments on commit e51bea6

Please sign in to comment.