diff options
author | Ximeng Zu <uznomis@yahoo.com> | 2017-04-27 22:07:32 -0500 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-05-09 19:51:49 +0200 |
commit | e0ccc8913598c91a9a76fd6bcca6d397bf79e304 (patch) | |
tree | bf402343e38f2857530a7ec7b177e1945de36435 /android | |
parent | 5c2833c4edf88ab7f9ad9b6165829c149432aae5 (diff) |
Fix behavior of double tap zoom in and out
Fix the behavior of double tap zoom. Previously
double tap zooms to the viewport whose
top left point is the point of double touch. Now
double tap behaves such that the point of
doule touch does not move on the screen, and
the rest part of the view zooms in or out. This
behavior is more UX friendly and correct.
Change-Id: Ifccc337631d523be1cd870f892235899d0fc5dfe
Reviewed-on: https://gerrit.libreoffice.org/37046
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java index 1d109cf426a1..b834fa0798d5 100644 --- a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java +++ b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java @@ -985,16 +985,18 @@ class JavaPanZoomController @Override public boolean onDoubleTap(MotionEvent motionEvent) { // Double tap zooms in or out depending on the current zoom factor - PointF viewPoint = getMotionInDocumentCoordinates(motionEvent); - ZoomConstraints constraints = mTarget.getZoomConstraints(); - float zoomFactor = getMetrics().getZoomFactor(); - if (zoomFactor >= DOUBLE_TAP_THRESHOLD) { - animatedMove(viewPoint, constraints.getMinZoom()); - } else { - animatedMove(viewPoint, DOUBLE_TAP_THRESHOLD); - } - - LOKitShell.sendTouchEvent("DoubleTap", getMotionInDocumentCoordinates(motionEvent)); + PointF pointOfTap = getMotionInDocumentCoordinates(motionEvent); + ImmutableViewportMetrics metrics = getMetrics(); + float newZoom = metrics.getZoomFactor() >= + DOUBLE_TAP_THRESHOLD ? mTarget.getZoomConstraints().getMinZoom() : DOUBLE_TAP_THRESHOLD; + // calculate new top_left point from the point of tap + float ratio = newZoom/metrics.getZoomFactor(); + float newLeft = pointOfTap.x - 1/ratio * (pointOfTap.x - metrics.getOrigin().x / metrics.getZoomFactor()); + float newTop = pointOfTap.y - 1/ratio * (pointOfTap.y - metrics.getOrigin().y / metrics.getZoomFactor()); + // animate move to the new view + animatedMove(new PointF(newLeft, newTop), newZoom); + + LOKitShell.sendTouchEvent("DoubleTap", pointOfTap); return true; } |