loleaflet/src/map/handler/Map.TouchGesture.js |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

New commits:
commit 93992872e18d4043075d2d01d2ba8e74dcb5e38d
Author:     Marco Cecchetti <mrcek...@gmail.com>
AuthorDate: Mon Jul 1 20:07:54 2019 +0200
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Tue Aug 20 17:31:02 2019 +0200

    loleaflet: pinch + pan issue: move in the opposite direction
    
    When the user pans with 2 fingers the document is moved in the
    opposite direction. So we store the initial center point and invert
    the offset to achieve the correct behavior.
    
    Change-Id: Ief63aa39f56c3b812a90b392ddedc4ba21d813e4
    Reviewed-on: https://gerrit.libreoffice.org/77846
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    Tested-by: Henry Castro <hcas...@collabora.com>

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js 
b/loleaflet/src/map/handler/Map.TouchGesture.js
index 01b564ddc..3171e2794 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -84,7 +84,8 @@ L.Map.TouchGesture = L.Handler.extend({
                this._hammer.on('panstart', L.bind(this._onPanStart, this));
                this._hammer.on('pan', L.bind(this._onPan, this));
                this._hammer.on('panend', L.bind(this._onPanEnd, this));
-               this._hammer.on('pinchstart pinchmove', L.bind(this._onPinch, 
this));
+               this._hammer.on('pinchstart', L.bind(this._onPinchStart, this));
+               this._hammer.on('pinchmove', L.bind(this._onPinch, this));
                this._hammer.on('pinchend', L.bind(this._onPinchEnd, this));
                this._hammer.on('tripletap', L.bind(this._onTripleTap, this));
                if (window.ThisIsTheiOSApp)
@@ -99,7 +100,8 @@ L.Map.TouchGesture = L.Handler.extend({
                this._hammer.off('panstart', L.bind(this._onPanStart, this));
                this._hammer.off('pan', L.bind(this._onPan, this));
                this._hammer.off('panend', L.bind(this._onPanEnd, this));
-               this._hammer.off('pinchstart pinchmove', L.bind(this._onPinch, 
this));
+               this._hammer.off('pinchstart', L.bind(this._onPinchStart, 
this));
+               this._hammer.off('pinchmove', L.bind(this._onPinch, this));
                this._hammer.off('pinchend', L.bind(this._onPinchEnd, this));
                this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
                this._hammer.off('tripletap', L.bind(this._onTripleTap, this));
@@ -325,9 +327,21 @@ L.Map.TouchGesture = L.Handler.extend({
                }
        },
 
+       _onPinchStart: function (e) {
+               if (this._map.getDocType() !== 'spreadsheet') {
+                       this._pinchStartCenter = {x: e.center.x, y: e.center.y};
+               }
+       },
+
        _onPinch: function (e) {
+               if (!this._pinchStartCenter)
+                       return;
+
                if (this._map.getDocType() !== 'spreadsheet') {
-                       this._center = this._map.mouseEventToLatLng({clientX: 
e.center.x, clientY: e.center.y});
+                       // we need to invert the offset or the map is moved in 
the opposite direction
+                       var offset = {x: e.center.x - this._pinchStartCenter.x, 
y: e.center.y - this._pinchStartCenter.y};
+                       var center = {x: this._pinchStartCenter.x - offset.x, 
y: this._pinchStartCenter.y - offset.y};
+                       this._center = this._map.mouseEventToLatLng({clientX: 
center.x, clientY: center.y});
                        this._zoom = this._map.getScaleZoom(e.scale);
 
                        L.Util.cancelAnimFrame(this._animRequest);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to