diff options
Diffstat (limited to 'platform/android')
-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; } |