From 57121ca1cc81b502f3a4a0f79759404d0fb0d846 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 3 Apr 2015 14:48:38 +0100 Subject: 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. --- .../android/src/com/artifex/mupdfdemo/ReaderView.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'platform/android/src/com/artifex') 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; } -- cgit v1.2.3