Bug 705092 - Kinetic scrolling is too slow. r=pcwalton a=java-only

This introduces a friction factor, so that the deceleration is relative to
the current velocity. Now, the faster you scroll, the slower the view
decelerates, allowing you to page through longer pages easier.
This commit is contained in:
Chris Lord 2011-12-12 18:56:15 +00:00
Родитель 000efbc764
Коммит 51e3c16d50
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -75,6 +75,7 @@ public class PanZoomController
private LayerController mController;
private static final float FRICTION = 0.85f;
private static final float FRICTION_FACTOR = 6.0f;
// Animation stops if the velocity is below this value.
private static final float STOPPED_THRESHOLD = 4.0f;
// The percentage of the surface which can be overscrolled before it must snap back.
@ -772,7 +773,11 @@ public class PanZoomController
// If we aren't overscrolled, just apply friction.
float excess = getExcess();
if (disableSnap || FloatUtils.fuzzyEquals(excess, 0.0f)) {
velocity *= FRICTION;
float absvelocity = (float)
Math.pow(Math.pow(velocity, FRICTION_FACTOR) * FRICTION,
1 / FRICTION_FACTOR);
velocity = Math.copySign(absvelocity, velocity);
if (Math.abs(velocity) < 0.1f) {
velocity = 0.0f;
setFlingState(FlingStates.STOPPED);