Bug 721125 - Prevent the edge resistance from being negative, which can wreak havoc on the viewport. r=pcwalton

This commit is contained in:
Kartikaya Gupta 2012-01-31 00:42:40 -05:00
parent c40ebd5017
commit 4f628e8540

View File

@ -185,7 +185,12 @@ abstract class Axis {
*/
float getEdgeResistance() {
float excess = getExcess();
return (excess > 0.0f) ? SNAP_LIMIT - excess / getViewportLength() : 1.0f;
if (excess > 0.0f) {
// excess can be greater than viewport length, but the resistance
// must never drop below 0.0
return Math.max(0.0f, SNAP_LIMIT - excess / getViewportLength());
}
return 1.0f;
}
/* Returns the velocity. If the axis is locked, returns 0. */