author | Kartikaya Gupta <kgupta@mozilla.com> |
Tue, 10 Jan 2012 10:05:53 -0500 | |
changeset 84215 | 9f3130c6f2858b15c8ca6c6abc55fdf6ccfd574e |
parent 84214 | b4f876211d7e879351004bb654de6d03fa7fa27d |
child 84216 | 82efff89bd7669b71987f5695076b9343c9e5a11 |
push id | 21832 |
push user | bmo@edmorley.co.uk |
push date | Wed, 11 Jan 2012 17:04:15 +0000 |
treeherder | mozilla-central@40c9f9ff9fd5 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | pcwalton |
bugs | 716673 |
milestone | 12.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/ui/PanZoomController.java +++ b/mobile/android/base/ui/PanZoomController.java @@ -407,18 +407,18 @@ public class PanZoomController } } mX.updateWithTouchAt(x, timeDelta); mY.updateWithTouchAt(y, timeDelta); } private void track(MotionEvent event) { - mX.lastTouchPos = mX.touchPos; - mY.lastTouchPos = mY.touchPos; + mX.saveTouchPos(); + mY.saveTouchPos(); for (int i = 0; i < event.getHistorySize(); i++) { track(event.getHistoricalX(0, i), event.getHistoricalY(0, i), event.getHistoricalEventTime(i)); } track(event.getX(0), event.getY(0), event.getEventTime()); @@ -697,18 +697,18 @@ public class PanZoomController public enum Overscroll { NONE, MINUS, // Overscrolled in the negative direction PLUS, // Overscrolled in the positive direction BOTH, // Overscrolled in both directions (page is zoomed to smaller than screen) } private float firstTouchPos; /* Position of the first touch event on the current drag. */ - public float touchPos; /* Position of the most recent touch event on the current drag. */ - public float lastTouchPos; /* Position of the touch event before touchPos. */ + private float touchPos; /* Position of the most recent touch event on the current drag. */ + private float lastTouchPos; /* Position of the touch event before touchPos. */ public float velocity; /* Velocity in this direction. */ public boolean locked; /* Whether movement on this axis is locked. */ public boolean disableSnap; /* Whether overscroll snapping is disabled. */ private FlingStates mFlingState; /* The fling state we're in on this axis. */ public abstract float getOrigin(); protected abstract float getViewportLength(); @@ -734,16 +734,20 @@ public class PanZoomController locked = false; firstTouchPos = touchPos = lastTouchPos = pos; } float panDistance(float currentPos) { return currentPos - firstTouchPos; } + void saveTouchPos() { + lastTouchPos = touchPos; + } + void updateWithTouchAt(float pos, float timeDelta) { float newVelocity = (touchPos - pos) / timeDelta * MS_PER_FRAME; // If there's a direction change, or current velocity is very low, // allow setting of the velocity outright. Otherwise, use the current // velocity and a maximum change factor to set the new velocity. boolean curVelocityIsLow = Math.abs(velocity) < 1.0f; boolean directionChange = (velocity > 0) != (newVelocity > 0);