Bug 856039 - (Cleanup) Extract magic number. r=Cwiiis
--- a/mobile/android/base/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/gfx/JavaPanZoomController.java
@@ -64,16 +64,19 @@ class JavaPanZoomController
private static final float MAX_ZOOM = 4.0f;
// The maximum amount we would like to scroll with the mouse
private static final float MAX_SCROLL = 0.075f * GeckoAppShell.getDpi();
// The maximum zoom factor adjustment per frame of the AUTONAV animation
private static final float MAX_ZOOM_DELTA = 0.125f;
+ // Length of the bounce animation in ms
+ private static final int BOUNCE_ANIMATION_DURATION = 250;
+
private enum PanZoomState {
NOTHING, /* no touch-start events received */
FLING, /* all touches removed, but we're still scrolling page */
TOUCHING, /* one touch-start event received */
PANNING_LOCKED, /* touch-start followed by move (i.e. panning with axis lock) */
PANNING, /* panning without axis lock */
PANNING_HOLD, /* in panning, but not moving.
* similar to TOUCHING but after starting a pan */
@@ -803,31 +806,31 @@ class JavaPanZoomController
* out.
*/
if (!(mState == PanZoomState.BOUNCE || mState == PanZoomState.ANIMATED_ZOOM)) {
finishAnimation();
return;
}
/* Perform the next frame of the bounce-back animation. */
- if (mBounceFrame < (int)(256f/Axis.MS_PER_FRAME)) {
+ if (mBounceFrame < (int)(BOUNCE_ANIMATION_DURATION / Axis.MS_PER_FRAME)) {
advanceBounce();
return;
}
/* Finally, if there's nothing else to do, complete the animation and go to sleep. */
finishBounce();
finishAnimation();
setState(PanZoomState.NOTHING);
}
/* Performs one frame of a bounce animation. */
private void advanceBounce() {
synchronized (mTarget.getLock()) {
- float t = easeOut(mBounceFrame * Axis.MS_PER_FRAME / 256f);
+ float t = easeOut(mBounceFrame * Axis.MS_PER_FRAME / BOUNCE_ANIMATION_DURATION);
ImmutableViewportMetrics newMetrics = mBounceStartMetrics.interpolate(mBounceEndMetrics, t);
mTarget.setViewportMetrics(newMetrics);
mBounceFrame++;
}
}
/* Concludes a bounce animation and snaps the viewport into place. */
private void finishBounce() {