diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-04-03 14:48:38 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-04-03 14:50:54 +0100 |
commit | 57121ca1cc81b502f3a4a0f79759404d0fb0d846 (patch) | |
tree | de228c862b470d2048a20c1a1db354764c37ca79 /platform/android/src/com | |
parent | c1e007023bf0a9b88f6dfdb20b9fbdcf8dfebb83 (diff) | |
download | mupdf-57121ca1cc81b502f3a4a0f79759404d0fb0d846.tar.xz |
Bug 693481: Android: Allow panning while zooming
Adopt (slightly modified) version of Kenny Lam's patch to allow
panning while zooming. This more closely matches how a web view
behaves.
Diffstat (limited to 'platform/android/src/com')
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/ReaderView.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/platform/android/src/com/artifex/mupdfdemo/ReaderView.java b/platform/android/src/com/artifex/mupdfdemo/ReaderView.java index 4e95d331..7b129916 100644 --- a/platform/android/src/com/artifex/mupdfdemo/ReaderView.java +++ b/platform/android/src/com/artifex/mupdfdemo/ReaderView.java @@ -58,6 +58,8 @@ public class ReaderView private final Stepper mStepper; private int mScrollerLastX; private int mScrollerLastY; + private float mLastScaleFocusX; + private float mLastScaleFocusY; static abstract class ViewMapper { abstract void applyToView(View view); @@ -478,12 +480,22 @@ public class ReaderView View v = mChildViews.get(mCurrent); if (v != null) { + float currentFocusX = detector.getFocusX(); + float currentFocusY = detector.getFocusY(); // Work out the focus point relative to the view top left - int viewFocusX = (int)detector.getFocusX() - (v.getLeft() + mXScroll); - int viewFocusY = (int)detector.getFocusY() - (v.getTop() + mYScroll); + int viewFocusX = (int)currentFocusX - (v.getLeft() + mXScroll); + int viewFocusY = (int)currentFocusY - (v.getTop() + mYScroll); // Scroll to maintain the focus point mXScroll += viewFocusX - viewFocusX * factor; mYScroll += viewFocusY - viewFocusY * factor; + + if (mLastScaleFocusX>=0) + mXScroll+=currentFocusX-mLastScaleFocusX; + if (mLastScaleFocusY>=0) + mYScroll+=currentFocusY-mLastScaleFocusY; + + mLastScaleFocusX=currentFocusX; + mLastScaleFocusY=currentFocusY; requestLayout(); } } @@ -496,6 +508,7 @@ public class ReaderView // screen is not showing the effect of them, so they can // only confuse the user mXScroll = mYScroll = 0; + mLastScaleFocusX = mLastScaleFocusY = -1; return true; } |