From f370538d9cf02aab19038b34b5cac1fe9c77c1fc Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 2 May 2011 13:34:00 -0700 Subject: [PATCH] Bug 653772 - Add a minimum velocity to start kinetic panning [r=stechz] DONTBUILD (mobile only) --- mobile/chrome/content/input.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mobile/chrome/content/input.js b/mobile/chrome/content/input.js index 158b6c895c0d..a930f5f921ac 100644 --- a/mobile/chrome/content/input.js +++ b/mobile/chrome/content/input.js @@ -64,7 +64,8 @@ const kStateActive = 0x00000001; // a pan in 300 milliseconds. const kStopKineticPanOnDragTimeout = 300; -// Max velocity of a pan. This is in pixels/millisecond. +// Min/max velocity of kinetic panning. This is in pixels/millisecond. +const kMinVelocity = 0.4; const kMaxVelocity = 6; /** @@ -994,8 +995,13 @@ KineticController.prototype = { currentVelocityY = 0; let swipeTime = Math.min(swipeLength, lastTime - mb[0].t); - this._velocity.x = clampFromZero((distanceX / swipeTime) + currentVelocityX, Math.abs(currentVelocityX), 6); - this._velocity.y = clampFromZero((distanceY / swipeTime) + currentVelocityY, Math.abs(currentVelocityY), 6); + this._velocity.x = clampFromZero((distanceX / swipeTime) + currentVelocityX, Math.abs(currentVelocityX), kMaxVelocity); + this._velocity.y = clampFromZero((distanceY / swipeTime) + currentVelocityY, Math.abs(currentVelocityY), kMaxVelocity); + + if (Math.abs(this._velocity.x) < kMinVelocity) + this._velocity.x = 0; + if (Math.abs(this._velocity.y) < kMinVelocity) + this._velocity.y = 0; // Set acceleration vector to opposite signs of velocity this._acceleration.set(this._velocity.clone().map(sign).scale(-this._polynomialC));