Bug 706891 part 1 - Rename Axis setLocked/mLocked to setScrolledDisabled/mScrollingDisabled to clarify meaning. r=kats

This commit is contained in:
Chris Peterson 2012-02-14 10:55:22 -08:00
parent a80a5ca858
commit f1e536ebfc
2 changed files with 16 additions and 15 deletions

View File

@ -88,7 +88,7 @@ abstract class Axis {
private float mTouchPos; /* Position of the most recent touch event on the current drag. */
private float mLastTouchPos; /* Position of the touch event before touchPos. */
private float mVelocity; /* Velocity in this direction; pixels per animation frame. */
private boolean mLocked; /* Whether movement on this axis is locked. */
public boolean mScrollingDisabled; /* Whether movement on this axis is locked. */
private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */
private float mDisplacement;
@ -108,7 +108,7 @@ abstract class Axis {
void startTouch(float pos) {
mVelocity = 0.0f;
mLocked = false;
mScrollingDisabled = false;
mFirstTouchPos = mTouchPos = mLastTouchPos = pos;
}
@ -116,8 +116,8 @@ abstract class Axis {
return currentPos - mFirstTouchPos;
}
void setLocked(boolean locked) {
mLocked = locked;
void setScrollingDisabled(boolean disabled) {
mScrollingDisabled = disabled;
}
void saveTouchPos() {
@ -172,11 +172,12 @@ abstract class Axis {
}
/*
* Returns true if the page is zoomed in to some degree along this axis such that scrolling
* is possible. Otherwise, returns false.
* Returns true if the page is zoomed in to some degree along this axis such that scrolling is
* possible and this axis has not been scroll locked while panning. Otherwise, returns false.
*/
private boolean scrollable() {
return getViewportLength() <= getPageLength() - MIN_SCROLLABLE_DISTANCE;
return getViewportLength() <= getPageLength() - MIN_SCROLLABLE_DISTANCE &&
!mScrollingDisabled;
}
/*
@ -195,7 +196,7 @@ abstract class Axis {
/* Returns the velocity. If the axis is locked, returns 0. */
float getRealVelocity() {
return (mLocked || !scrollable()) ? 0.0f : mVelocity;
return scrollable() ? mVelocity : 0f;
}
void startPan() {
@ -253,7 +254,7 @@ abstract class Axis {
// Performs displacement of the viewport position according to the current velocity.
void displace() {
if (!mSubscroller.scrolling() && (mLocked || !scrollable()))
if (!mSubscroller.scrolling() && !scrollable())
return;
if (mFlingState == FlingStates.PANNING)

View File

@ -387,17 +387,17 @@ public class PanZoomController
angle = Math.abs(angle); // range [0, pi]
if (angle < AXIS_LOCK_ANGLE || angle > (Math.PI - AXIS_LOCK_ANGLE)) {
// lock to x-axis
mX.setLocked(false);
mY.setLocked(true);
mX.setScrollingDisabled(false);
mY.setScrollingDisabled(true);
} else if (Math.abs(angle - (Math.PI / 2)) < AXIS_LOCK_ANGLE) {
// lock to y-axis
mX.setLocked(true);
mY.setLocked(false);
mX.setScrollingDisabled(true);
mY.setScrollingDisabled(false);
} else {
// break axis lock but log the angle so we can fine-tune this when people complain
mState = PanZoomState.PANNING;
mX.setLocked(false);
mY.setLocked(false);
mX.setScrollingDisabled(false);
mY.setScrollingDisabled(false);
angle = Math.abs(angle - (Math.PI / 2)); // range [0, pi/2]
}
}