summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Ross-Perry <fred.ross-perry@artifex.com>2016-09-27 08:16:24 -0700
committerFred Ross-Perry <fred.ross-perry@artifex.com>2016-11-15 12:31:08 -0800
commit3512a02e11b3f80c3b5fe6af8639e510e1382568 (patch)
tree31955277e8c0ab73a335a76dbc08cea3c02481de
parentd11ed8c4d7816cfe40181178c2150c8056d388f9 (diff)
downloadmupdf-3512a02e11b3f80c3b5fe6af8639e510e1382568.tar.xz
Android example - fix to maintain vertical center when zooming.
-rwxr-xr-xplatform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocViewBase.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocViewBase.java b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocViewBase.java
index 5ecc75d8..10cf78ca 100755
--- a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocViewBase.java
+++ b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocViewBase.java
@@ -477,9 +477,14 @@ public class DocViewBase
mScale *= ratio;
scaleChildren();
- // scroll so the left edged is flush to the viewport.
+ // scroll horizontally so the left edge is flush with the viewport.
mXScroll += getScrollX();
+ // scroll vertically to maintain the center.
+ int oldy = mViewport.centerY() - mLastBlockRect.top;
+ int newy = (int) ((float) oldy * ratio);
+ mYScroll -= (newy-oldy);
+
requestLayout();
}