[Libreoffice-commits] online.git: 15 commits - loleaflet/build loleaflet/src

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 11 07:56:58 UTC 2019


 loleaflet/build/deps.js                       |    4 
 loleaflet/src/control/Control.MobileInput.js  |   17 +++
 loleaflet/src/core/Socket.js                  |   22 ---
 loleaflet/src/dom/Draggable.js                |   18 +--
 loleaflet/src/layer/marker/Marker.js          |    4 
 loleaflet/src/map/Map.js                      |    4 
 loleaflet/src/map/handler/Map.Tap.js          |  146 --------------------------
 loleaflet/src/map/handler/Map.TouchGesture.js |   79 +++++++++-----
 loleaflet/src/map/handler/Map.TouchZoom.js    |  122 ---------------------
 9 files changed, 85 insertions(+), 331 deletions(-)

New commits:
commit 5a1a057854f630763f37b3bf83ccec25f9d9d2c2
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 11 11:59:51 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: remove Map.CalcTap initialisation
    
    follow up:
    "create Map.CalcTap handler when initialize L.Map"
    
    remove init in Socket.js which was include in the
    original commit
    
    Change-Id: If26278dc655ff4434bce0ca21d4b63623f2cdd17

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index d9f31e09b..366918123 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -757,18 +757,6 @@ L.Socket = L.Class.extend({
 					});
 				}
 				else if (command.type === 'spreadsheet') {
-					// replace touch handler for mobile devices
-					if (L.Browser.touch && !L.Browser.pointer) {
-						this._map.options.inertia = false;
-						this._map.removeHandler('tap');
-						this._map.removeHandler('mouse');
-						this._map.removeHandler('touchZoom');
-						this._map.dragging.disable();
-						this._map.dragging._draggable._manualDrag = true;
-						L.DomEvent.off(this._map._container, 'mousedown mouseup mouseover mouseout mousemove click dblclick trplclick qdrplclick dragover drop scroll', this._map._handleDOMEvent, this._map);
-						this._map.addHandler('touchCalc', L.Map.CalcTap);
-						this._map.touchCalc.enable();
-					}
 					docLayer = new L.CalcTileLayer('', {
 						permission: this._map.options.permission,
 						tileWidthTwips: tileWidthTwips,
commit fcdcfa3e7cedac77f8d9508df6c479caa9528af5
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 4 18:22:36 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    aloleaflet: mobile: activate manual drag and drop
    
    In order to reuse code to handle drag and drop, it is necessary to
    handle without listening the drag events. The Hammer library has an
    event called "swipe" and it can be used to simulate drag and drop.
    
    Change-Id: I1ed4e9422cd9bd98bdede88f2c994bdbba4adc4c

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 74b2cd3d1..d9f31e09b 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -763,18 +763,8 @@ L.Socket = L.Class.extend({
 						this._map.removeHandler('tap');
 						this._map.removeHandler('mouse');
 						this._map.removeHandler('touchZoom');
-						if (this._map.dragging.enabled()) {
-							this._map.dragging.disable();
-							L.Draggable.START = ['mousedown'];
-							L.Draggable.MOVE = {mousedown: 'mousemove'};
-							L.Draggable.END = {mousedown: 'mouseup'};
-							this._map.dragging.enable();
-						}
-						else {
-							L.Draggable.START = ['mousedown'];
-							L.Draggable.MOVE = {mousedown: 'mousemove'};
-							L.Draggable.END = {mousedown: 'mouseup'};
-						}
+						this._map.dragging.disable();
+						this._map.dragging._draggable._manualDrag = true;
 						L.DomEvent.off(this._map._container, 'mousedown mouseup mouseover mouseout mousemove click dblclick trplclick qdrplclick dragover drop scroll', this._map._handleDOMEvent, this._map);
 						this._map.addHandler('touchCalc', L.Map.CalcTap);
 						this._map.touchCalc.enable();
commit b5f2ad76db84e90abc3d1c94ad4dc4f32d63dfb6
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jun 20 15:32:44 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: prevent more default actions
    
    Occurs that some devices support touch and pointer events,
    and the combination emit mouse events
    
    Change-Id: I85a6a918d2e39ec1b60105a15d35856fd5600ebb

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 559979770..0ae55b59b 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -24,14 +24,28 @@ L.Map.TouchGesture = L.Handler.extend({
 			this._hammer.get('pinch').set({
 				enable: true
 			});
+
+			if (L.Browser.touch) {
+				L.DomEvent.on(this._map._mapPane, 'touchstart touchmove touchend touchcancel', L.DomEvent.preventDefault);
+			}
+
+			if (Hammer.prefixed(window, 'PointerEvent') !== undefined) {
+				L.DomEvent.on(this._map._mapPane, 'pointerdown pointermove pointerup pointercancel', L.DomEvent.preventDefault);
+			}
+
+			// IE10 has prefixed support, and case-sensitive
+			if (window.MSPointerEvent && !window.PointerEvent) {
+				L.DomEvent.on(this._map._mapPane, 'MSPointerDown MSPointerMove MSPointerUp MSPointerCancel', L.DomEvent.preventDefault);
+			}
+
+			L.DomEvent.on(this._map._mapPane, 'mousedown mousemove mouseup', L.DomEvent.preventDefault);
+			L.DomEvent.on(document, 'contextmenu', L.DomEvent.preventDefault);
 		}
 
 		for (var events in L.Draggable.MOVE) {
 			L.DomEvent.on(document, L.Draggable.END[events], this._onDocUp, this);
 		}
 
-		L.DomEvent.on(document, 'contextmenu', L.DomEvent.preventDefault);
-
 		/// $.contextMenu does not support touch events so,
 		/// attach 'touchend' menu clicks event handler
 		if (this._hammer.input instanceof Hammer.TouchInput) {
commit f519ff51c49a91193166fb81949d398f57ceb0d9
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 19 14:42:05 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    Revert "loleaflet: mobile: check against undefined values"
    
    This reverts commit aa0c968976416b16af071787c99204068f91482c.
    
    It was a bad idea, it breaks panning on IOS devices

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 306d149bb..559979770 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -136,12 +136,8 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPanStart: function (e) {
-		var point = e.pointers[0];
-		if (isNaN(point.x) || isNaN(point.y)) {
-			return;
-		}
-
-		var containerPoint = this._map.mouseEventToContainerPoint(point),
+		var point = e.pointers[0],
+		    containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
@@ -155,12 +151,8 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPan: function (e) {
-		var point = e.pointers[0];
-		if (isNaN(point.x) || isNaN(point.y)) {
-			return;
-		}
-
-		var containerPoint = this._map.mouseEventToContainerPoint(point),
+		var point = e.pointers[0],
+		    containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
@@ -173,12 +165,8 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPanEnd: function (e) {
-		var point = e.pointers[0];
-		if (isNaN(point.x) || isNaN(point.y)) {
-			return;
-		}
-
-		var containerPoint = this._map.mouseEventToContainerPoint(point),
+		var point = e.pointers[0],
+		    containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
@@ -192,10 +180,6 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPinch: function (e) {
-		if (isNaN(e.center.x) || isNaN(e.center.y)) {
-			return;
-		}
-
 		if (this._map.getDocType() !== 'spreadsheet') {
 			this._center = this._map.mouseEventToLatLng({clientX: e.center.x, clientY: e.center.y});
 			this._zoom = this._map.getScaleZoom(e.scale);
commit 166d0beb79dc7ead85ddb79d50caa8c790315cc9
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 18 15:01:20 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: avoid undefined values when panning
    
    Change-Id: I3e67b52b383e11ea2e98831e040edc5ae0650910

diff --git a/loleaflet/src/dom/Draggable.js b/loleaflet/src/dom/Draggable.js
index 4ea83458a..df22f3b11 100644
--- a/loleaflet/src/dom/Draggable.js
+++ b/loleaflet/src/dom/Draggable.js
@@ -87,6 +87,10 @@ L.Draggable = L.Evented.extend({
 	},
 
 	_onMove: function (e) {
+		if (!this._startPoint) {
+			return;
+		}
+
 		if (e.touches && e.touches.length > 1) {
 			this._moved = true;
 			return;
commit fb2a9a0e37285f8bb15936e508e087c6dfdf7252
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 18 10:40:07 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: remove Map.TouchZoom
    
    It is obsolete and now we use hammerjs library
    
    Change-Id: I9126e694767a8fca372c8e6c608f38626b76537b

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 904f4608e..63c9df5f5 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -235,7 +235,6 @@ var deps = {
 		      'dom/DomEvent.DoubleTap.js',
 		      'dom/DomEvent.Pointer.js',
 		      'core/Handler.js',
-		      'map/handler/Map.TouchZoom.js',
 		      'map/handler/Map.TouchGesture.js'],
 		deps: ['AnimationZoom'],
 		desc: 'Enables smooth touch zoom / tap / longhold / doubletap on iOS, IE10, Android.'
diff --git a/loleaflet/src/map/handler/Map.TouchZoom.js b/loleaflet/src/map/handler/Map.TouchZoom.js
deleted file mode 100644
index 35b3cf839..000000000
--- a/loleaflet/src/map/handler/Map.TouchZoom.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/* -*- js-indent-level: 8 -*- */
-/*
- * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
- */
-
-L.Map.mergeOptions({
-	touchZoom: L.Browser.touch && !L.Browser.android23,
-	bounceAtZoomLimits: true
-});
-
-L.Map.TouchZoom = L.Handler.extend({
-	addHooks: function () {
-		L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this);
-	},
-
-	removeHooks: function () {
-		L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this);
-	},
-
-	_onTouchStart: function (e) {
-		var map = this._map;
-
-		if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
-
-		var p1 = map.mouseEventToLayerPoint(e.touches[0]),
-		    p2 = map.mouseEventToLayerPoint(e.touches[1]),
-		    viewCenter = map._getCenterLayerPoint();
-
-		this._startCenter = p1.add(p2)._divideBy(2);
-		this._startDist = p1.distanceTo(p2);
-
-		this._moved = false;
-		if (map.getDocType() === 'spreadsheet') {
-			this._zooming = false;
-		}
-		else {
-			this._zooming = true;
-		}
-
-		this._centerOffset = viewCenter.subtract(this._startCenter);
-
-		map.stop();
-
-		L.DomEvent
-		    .on(document, 'touchmove', this._onTouchMove, this)
-		    .on(document, 'touchend', this._onTouchEnd, this);
-
-		L.DomEvent.preventDefault(e);
-	},
-
-	_onTouchMove: function (e) {
-		if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
-
-		var map = this._map,
-		    p1 = map.mouseEventToLayerPoint(e.touches[0]),
-		    p2 = map.mouseEventToLayerPoint(e.touches[1]);
-
-		this._scale = p1.distanceTo(p2) / this._startDist;
-		this._delta = p1._add(p2)._divideBy(2)._subtract(this._startCenter);
-
-		if (!map.options.bounceAtZoomLimits) {
-			var currentZoom = map.getScaleZoom(this._scale);
-			if ((currentZoom <= map.getMinZoom() && this._scale < 1) ||
-		     (currentZoom >= map.getMaxZoom() && this._scale > 1)) { return; }
-		}
-
-		if (!this._moved) {
-			map
-			    .fire('movestart')
-			    .fire('zoomstart');
-
-			this._moved = true;
-		}
-
-		L.Util.cancelAnimFrame(this._animRequest);
-		this._animRequest = L.Util.requestAnimFrame(this._updateOnMove, this, true, this._map._container);
-
-		L.DomEvent.preventDefault(e);
-	},
-
-	_updateOnMove: function () {
-		var map = this._map;
-
-		if (map.options.touchZoom === 'center') {
-			this._center = map.getCenter();
-		} else {
-			this._center = map.layerPointToLatLng(this._getTargetCenter());
-		}
-
-		this._zoom = map.getScaleZoom(this._scale);
-
-		if (this._scale !== 1 || this._delta.x !== 0 || this._delta.y !== 0) {
-			map._animateZoom(this._center, this._zoom, false, true);
-		}
-	},
-
-	_onTouchEnd: function () {
-		if (!this._moved || !this._zooming) {
-			this._zooming = false;
-			return;
-		}
-
-		this._zooming = false;
-		L.Util.cancelAnimFrame(this._animRequest);
-
-		L.DomEvent
-		    .off(document, 'touchmove', this._onTouchMove)
-		    .off(document, 'touchend', this._onTouchEnd);
-
-		var map = this._map,
-		    oldZoom = map.getZoom(),
-		    zoomDelta = this._zoom - oldZoom,
-		    finalZoom = map._limitZoom(zoomDelta > 0 ? Math.ceil(this._zoom) : Math.floor(this._zoom));
-
-		map._animateZoom(this._center, finalZoom, true, true);
-	},
-
-	_getTargetCenter: function () {
-		var centerOffset = this._centerOffset.subtract(this._delta).divideBy(this._scale);
-		return this._startCenter.add(centerOffset);
-	}
-});
commit fa757db186892aa832c4c9f35f390daade3e7759
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 18 10:36:00 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: check against undefined values
    
    Change-Id: Ic353d381b8a39eb548122d0324d2048728d887fe

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 559979770..306d149bb 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -136,8 +136,12 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPanStart: function (e) {
-		var point = e.pointers[0],
-		    containerPoint = this._map.mouseEventToContainerPoint(point),
+		var point = e.pointers[0];
+		if (isNaN(point.x) || isNaN(point.y)) {
+			return;
+		}
+
+		var containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
@@ -151,8 +155,12 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPan: function (e) {
-		var point = e.pointers[0],
-		    containerPoint = this._map.mouseEventToContainerPoint(point),
+		var point = e.pointers[0];
+		if (isNaN(point.x) || isNaN(point.y)) {
+			return;
+		}
+
+		var containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
@@ -165,8 +173,12 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPanEnd: function (e) {
-		var point = e.pointers[0],
-		    containerPoint = this._map.mouseEventToContainerPoint(point),
+		var point = e.pointers[0];
+		if (isNaN(point.x) || isNaN(point.y)) {
+			return;
+		}
+
+		var containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
@@ -180,6 +192,10 @@ L.Map.TouchGesture = L.Handler.extend({
 	},
 
 	_onPinch: function (e) {
+		if (isNaN(e.center.x) || isNaN(e.center.y)) {
+			return;
+		}
+
 		if (this._map.getDocType() !== 'spreadsheet') {
 			this._center = this._map.mouseEventToLatLng({clientX: e.center.x, clientY: e.center.y});
 			this._zoom = this._map.getScaleZoom(e.scale);
commit 7e71b32a003ca0150b92acae0c69a553af4f801e
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 18 10:22:37 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: add handlers to pinch events
    
    Change-Id: Ibc757415e6bb9da9654b08c05e96560991d9d4b1

diff --git a/loleaflet/src/dom/Draggable.js b/loleaflet/src/dom/Draggable.js
index 0c20f6824..4ea83458a 100644
--- a/loleaflet/src/dom/Draggable.js
+++ b/loleaflet/src/dom/Draggable.js
@@ -79,9 +79,11 @@ L.Draggable = L.Evented.extend({
 		// for scrolling during cursor dragging.
 		this.startOffset = this._startPoint.subtract(new L.Point(startBoundingRect.left, startBoundingRect.top));
 
-		L.DomEvent
-			.on(document, L.Draggable.MOVE[e.type], this._onMove, this)
-			.on(document, L.Draggable.END[e.type], this._onUp, this);
+		if (!this._manualDrag) {
+			L.DomEvent
+				.on(document, L.Draggable.MOVE[e.type], this._onMove, this)
+				.on(document, L.Draggable.END[e.type], this._onUp, this);
+		}
 	},
 
 	_onMove: function (e) {
@@ -138,11 +140,7 @@ L.Draggable = L.Evented.extend({
 		L.Util.cancelAnimFrame(this._animRequest);
 		this._lastEvent = e;
 
-		if (!this._manualDrag) {
-			this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget);
-		} else {
-			this._updatePosition();
-		}
+		this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget);
 	},
 
 	_updatePosition: function () {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 004545171..d5f8880f2 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -117,7 +117,6 @@ L.Map = L.Evented.extend({
 			this.dragging._draggable._manualDrag = true;
 			this._mainEvents('off');
 			this.addHandler('touchGesture', L.Map.TouchGesture);
-			this.addHandler('touchZoom', L.Map.TouchZoom);
 		} else {
 			this.addHandler('mouse', L.Map.Mouse);
 			this.addHandler('boxZoom', L.Map.BoxZoom);
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 77f2e00c0..559979770 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -21,6 +21,9 @@ L.Map.TouchGesture = L.Handler.extend({
 			this._hammer.get('pan').set({
 				direction: Hammer.DIRECTION_ALL
 			});
+			this._hammer.get('pinch').set({
+				enable: true
+			});
 		}
 
 		for (var events in L.Draggable.MOVE) {
@@ -49,8 +52,9 @@ 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('pinchend', L.bind(this._onPinchEnd, this));
 		this._map.on('updatepermission', this._onPermission, this);
-		this._map.on('input.press', this._onInputPress, this);
 		this._onPermission({perm: this._map._permission});
 	},
 
@@ -60,8 +64,9 @@ 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('pinchend', L.bind(this._onPinchEnd, this));
 		this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
-		this._hammer.off('press', L.bind(this._onPress, this));
 		this._map.off('updatepermission', this._onPermission, this);
 	},
 
@@ -86,10 +91,6 @@ L.Map.TouchGesture = L.Handler.extend({
 		}
 	},
 
-	_onInputPress: function (/*e*/) {
-		//var pos = this._map.latLngToContainerPoint(e);
-	},
-
 	_onPress: function (e) {
 		var point = e.pointers[0],
 		    containerPoint = this._map.mouseEventToContainerPoint(point),
@@ -178,6 +179,24 @@ L.Map.TouchGesture = L.Handler.extend({
 		}
 	},
 
+	_onPinch: function (e) {
+		if (this._map.getDocType() !== 'spreadsheet') {
+			this._center = this._map.mouseEventToLatLng({clientX: e.center.x, clientY: e.center.y});
+			this._zoom = this._map.getScaleZoom(e.scale);
+			this._map._animateZoom(this._center, this._zoom, false, true);
+		}
+	},
+
+	_onPinchEnd: function () {
+		if (this._map.getDocType() !== 'spreadsheet') {
+			var oldZoom = this._map.getZoom(),
+			    zoomDelta = this._zoom - oldZoom,
+			    finalZoom = this._map._limitZoom(zoomDelta > 0 ? Math.ceil(this._zoom) : Math.floor(this._zoom));
+
+			this._map._animateZoom(this._center, finalZoom, true, true);
+		}
+	},
+
 	_constructFakeEvent: function (evt, type) {
 		var fakeEvt = {
 			type: type,
commit f0d803b7c089b595c5c5184ecb576c7443c768a6
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Jun 17 11:18:41 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: remove context toolbar
    
    It is no longer need it because the context menu has the same
    functionality
    
    Change-Id: I8f0cfa0ff8ea6d0d564e5edb7eeabdf369952926

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index ed183e76f..77f2e00c0 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -13,10 +13,6 @@ L.Map.TouchGesture = L.Handler.extend({
 	initialize: function (map) {
 		L.Handler.prototype.initialize.call(this, map);
 
-		if (!this._toolbar) {
-			this._toolbar = L.control.contextToolbar();
-		}
-
 		if (!this._hammer) {
 			this._hammer = new Hammer(this._map._mapPane);
 			this._hammer.get('swipe').set({
@@ -90,11 +86,8 @@ L.Map.TouchGesture = L.Handler.extend({
 		}
 	},
 
-	_onInputPress: function (e) {
-		var pos = this._map.latLngToContainerPoint(e);
-		this._toolbar.remove();
-		this._toolbar._pos = pos;
-		this._toolbar.addTo(this._map);
+	_onInputPress: function (/*e*/) {
+		//var pos = this._map.latLngToContainerPoint(e);
 	},
 
 	_onPress: function (e) {
@@ -104,16 +97,10 @@ L.Map.TouchGesture = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		if (!this._toolbar._map && this._map._docLayer.containsSelection(latlng)) {
-			this._toolbar._pos = containerPoint;
-			this._toolbar.addTo(this._map);
-		} else {
-			this._toolbar.remove();
-			this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
-			// send right click to trigger context menus
-			this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
-			this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
-		}
+		this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
+		// send right click to trigger context menus
+		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
+		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
 
 		this._cellSelections = false;
 		e.preventDefault();
@@ -126,7 +113,6 @@ L.Map.TouchGesture = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		this._toolbar.remove();
 		this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
commit cf7436a58ebcc6f3d61256384048f6773db03708
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jun 13 08:35:43 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: do no use setTimeout to set focus
    
    Change-Id: I83f03f00aa3a09af04a83368c14a79901ea401e6

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 59a604db8..ed183e76f 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -133,7 +133,7 @@ L.Map.TouchGesture = L.Handler.extend({
 		this._cellSelections = false;
 
 		if (!this._map.hasFocus()) {
-			setTimeout(L.bind(this._map.focus, this._map), 0);
+			this._map.focus();
 		}
 	},
 
commit c75124d0089cc342213e60316151525a1f44c878
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jun 13 08:28:43 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: fix single tap to set focus
    
    Change-Id: Ia5431893815ca56a3e4991b2c3a956c7aaa88764

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index d255197b3..59a604db8 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -131,6 +131,10 @@ L.Map.TouchGesture = L.Handler.extend({
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
 		this._cellSelections = false;
+
+		if (!this._map.hasFocus()) {
+			setTimeout(L.bind(this._map.focus, this._map), 0);
+		}
 	},
 
 	_onDoubleTap: function (e) {
@@ -142,10 +146,6 @@ L.Map.TouchGesture = L.Handler.extend({
 
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 2, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0);
-
-		if (!this._map.hasFocus()) {
-			setTimeout(L.bind(this._map.focus, this._map), 0);
-		}
 	},
 
 	_onPanStart: function (e) {
commit e98fc715f7c8914a27b86ef2c5df6901aef377ad
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 12 09:32:51 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: prevent default action of the 'contextmenu' event
    
    Change-Id: I3f991dfc277548e5811c9342edd98775b3d51122

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 751c51019..d255197b3 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -31,6 +31,8 @@ L.Map.TouchGesture = L.Handler.extend({
 			L.DomEvent.on(document, L.Draggable.END[events], this._onDocUp, this);
 		}
 
+		L.DomEvent.on(document, 'contextmenu', L.DomEvent.preventDefault);
+
 		/// $.contextMenu does not support touch events so,
 		/// attach 'touchend' menu clicks event handler
 		if (this._hammer.input instanceof Hammer.TouchInput) {
commit a89d122479fd5aaae723ab8e646b705472b50591
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 12 09:11:53 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: remove obsolete Map.Tap handler
    
    It has been replaced by Map.TouchGesture using Hammerjs library
    
    Change-Id: I386e270015b507897cc355c62f7ea57551d18531

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 23b0815c3..904f4608e 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -236,7 +236,6 @@ var deps = {
 		      'dom/DomEvent.Pointer.js',
 		      'core/Handler.js',
 		      'map/handler/Map.TouchZoom.js',
-		      'map/handler/Map.Tap.js',
 		      'map/handler/Map.TouchGesture.js'],
 		deps: ['AnimationZoom'],
 		desc: 'Enables smooth touch zoom / tap / longhold / doubletap on iOS, IE10, Android.'
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 17ca49206..004545171 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -112,7 +112,6 @@ L.Map = L.Evented.extend({
 		this.addHandler('keyboard', L.Map.Keyboard);
 		this.addHandler('dragging', L.Map.Drag);
 		if (L.Browser.touch && !L.Browser.pointer) {
-			//this.addHandler('tap', L.Map.Tap);
 			this.dragging.disable();
 			this.options.inertia = false;
 			this.dragging._draggable._manualDrag = true;
diff --git a/loleaflet/src/map/handler/Map.Tap.js b/loleaflet/src/map/handler/Map.Tap.js
deleted file mode 100644
index 81565f2e4..000000000
--- a/loleaflet/src/map/handler/Map.Tap.js
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- js-indent-level: 8; fill-column: 100 -*- */
-/*
- * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
- */
-
-L.Map.mergeOptions({
-	tap: true,
-	tapTolerance: 15
-});
-
-L.Map.Tap = L.Handler.extend({
-	addHooks: function () {
-		if (!this._toolbar) {
-			this._toolbar = L.control.contextToolbar();
-		}
-		L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this);
-	},
-
-	removeHooks: function () {
-		L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this);
-	},
-
-	_onCursorClick: function (e) {
-		L.DomEvent.preventDefault(e.originalEvent);
-
-		var state = this._map['stateChangeHandler'].getItemValue('.uno:Paste');
-		if (state !== 'disabled') {
-			L.setOptions(this._toolbar, {item: 'paste'});
-			this._toolbar._pos = this._map.latLngToContainerPoint(this._map._docLayer._visibleCursor.getNorthWest());
-			this._toolbar.addTo(this._map);
-		}
-	},
-
-	_onDown: function (e) {
-		if (!e.touches || !this._map._docLayer) { return; }
-
-		// console.log('=========> _onDown, e.touches.length=' + e.touches.length);
-
-		// The start of a two-finger gesture comes in as first _onDown with e.touches.length
-		// == 1, then _onDown with e.touches.length == 2.
-
-		// The _wasSingleTap flag is supposed to mean "we got a single-finger quick tap with
-		// no movement".
-
-		// FIXME: Is there some saner place to store this _wasSingleTap flag than in
-		// this._map._container? It needs to be readily available over in _handleDOMEvent in
-		// Map.js.
-		this._map._container._wasSingleTap = (e.touches.length === 1);
-
-		L.DomEvent.preventDefault(e);
-
-		// don't simulate click or track longpress if more than 1 touch
-		if (e.touches.length > 1) {
-			clearTimeout(this._holdTimeout);
-			return;
-		}
-
-		var first = e.touches[0],
-		    containerPoint = this._map.mouseEventToContainerPoint(first),
-		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
-		    latlng = this._map.layerPointToLatLng(layerPoint);
-		this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
-
-		if (!this._toolbar._map && this._map._docLayer.containsSelection(latlng)) {
-			this._toolbar._pos = containerPoint;
-			this._toolbar.addTo(this._map);
-			return;
-		}
-
-		this._toolbar.remove();
-		// simulate long hold but setting a timeout
-		this._fireClick = true;
-		this._holdTimeout = setTimeout(L.bind(function () {
-			this._fireClick = false;
-			if (this._isTapValid()) {
-				this._fireDblClick = true;
-				this._onUp(e);
-			}
-		}, this), 1000);
-
-		this._simulateEvent('mousedown', first);
-
-		L.DomEvent.on(document, {
-			touchmove: this._onMove,
-			touchend: this._onUp
-		}, this);
-	},
-
-	_onUp: function (e) {
-		// console.log('=========> _onUp, e.touches.length=' + e.touches.length + ', e.changedTouches.length=' + e.changedTouches.length);
-		clearTimeout(this._holdTimeout);
-
-		L.DomEvent.off(document, {
-			touchmove: this._onMove,
-			touchend: this._onUp
-		}, this);
-
-		var first = e.changedTouches[0];
-		this._simulateEvent('mouseup', first);
-
-		if (this._fireClick) {
-			this._fireClick = false;
-			if (this._isTapValid()) {
-				this._simulateEvent('click', first);
-			}
-		}
-		if (this._fireDblClick) {
-			this._simulateEvent('dblclick', first);
-			this._fireDblClick = false;
-		}
-	},
-
-	_isTapValid: function () {
-		return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
-	},
-
-	_onMove: function (e) {
-		var first = e.touches[0];
-		var newPos = new L.Point(first.clientX, first.clientY);
-		if (newPos.distanceTo(this._startPos) > this._map.options.tapTolerance) {
-			this._newPos = newPos;
-			this._map._container._wasSingleTap = false;
-			this._simulateEvent('mousemove', first);
-		}
-	},
-
-	_simulateEvent: function (type, e) {
-		var simulatedEvent = {
-			type: type,
-			canBubble: false,
-			cancelable: true,
-			screenX: e.screenX,
-			screenY: e.screenY,
-			clientX: e.clientX,
-			clientY: e.clientY,
-			ctrlKey: false,
-			altKey: false,
-			shiftKey: false,
-			metaKey: false,
-			button: 0,
-			target: e.target,
-			preventDefault: function () {}
-		};
-		this._map._handleDOMEvent(simulatedEvent);
-	}
-});
commit ed9aa0a800118a9b861a79e8d07f5c2d090eef3f
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 11 15:03:43 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: show context toolbar when press...
    
    the input marker handler
    
    Change-Id: Ia5d8a5002d978b2b82a7a384a1aca152332d8124

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 84cd0b36f..27e63c596 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -2,6 +2,8 @@
 /*
  * L.Control.MobileInput.
  */
+
+/* global Hammer */
 L.Control.MobileInput = L.Control.extend({
 	options: {
 		position: 'topleft'
@@ -33,6 +35,11 @@ L.Control.MobileInput = L.Control.extend({
 		return this._container;
 	},
 
+	onPress: function (e) {
+		e.preventDefault();
+		this._map.fire('input.press', this._cursorHandler.getLatLng());
+	},
+
 	onDragEnd: function () {
 		var mousePos = this._map._docLayer._latLngToTwips(this._cursorHandler.getLatLng());
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
@@ -45,7 +52,13 @@ L.Control.MobileInput = L.Control.extend({
 			this._map.addLayer(this._map._docLayer._cursorMarker);
 			if (this._map._docLayer._selections.getLayers().length === 0) {
 				this._map.addLayer(this._cursorHandler);
+				this._hammer = new Hammer(this._cursorHandler._icon);
+				this._hammer.on('press', L.bind(this.onPress, this));
 			} else {
+				if (this._hammer) {
+					this._hammer.destroy();
+					this._hammer = undefined;
+				}
 				this._map.removeLayer(this._cursorHandler);
 			}
 		}
@@ -55,6 +68,10 @@ L.Control.MobileInput = L.Control.extend({
 		if (this._map._docLayer && this._map._docLayer._cursorMarker) {
 			this._textArea.value = '';
 			this._map.removeLayer(this._map._docLayer._cursorMarker);
+			if (this._hammer) {
+				this._hammer.destroy();
+				this._hammer = undefined;
+			}
 			this._map.removeLayer(this._cursorHandler);
 		}
 	},
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index a3224c226..751c51019 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -52,6 +52,7 @@ L.Map.TouchGesture = L.Handler.extend({
 		this._hammer.on('pan', L.bind(this._onPan, this));
 		this._hammer.on('panend', L.bind(this._onPanEnd, this));
 		this._map.on('updatepermission', this._onPermission, this);
+		this._map.on('input.press', this._onInputPress, this);
 		this._onPermission({perm: this._map._permission});
 	},
 
@@ -87,6 +88,13 @@ L.Map.TouchGesture = L.Handler.extend({
 		}
 	},
 
+	_onInputPress: function (e) {
+		var pos = this._map.latLngToContainerPoint(e);
+		this._toolbar.remove();
+		this._toolbar._pos = pos;
+		this._toolbar.addTo(this._map);
+	},
+
 	_onPress: function (e) {
 		var point = e.pointers[0],
 		    containerPoint = this._map.mouseEventToContainerPoint(point),
commit f90810e6e8df38665784cb5b8e0eb874ee10a73f
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 11 14:08:11 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jul 11 16:51:02 2019 +0900

    loleaflet: mobile: rename Map.CalcTap to Map.TouchGesture
    
    Change-Id: Ibcb45d87fcf5a0ea98bec06816e9085c6fe28937

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 82652bfe8..23b0815c3 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -237,7 +237,7 @@ var deps = {
 		      'core/Handler.js',
 		      'map/handler/Map.TouchZoom.js',
 		      'map/handler/Map.Tap.js',
-		      'map/handler/Map.CalcTap.js'],
+		      'map/handler/Map.TouchGesture.js'],
 		deps: ['AnimationZoom'],
 		desc: 'Enables smooth touch zoom / tap / longhold / doubletap on iOS, IE10, Android.'
 	},
diff --git a/loleaflet/src/layer/marker/Marker.js b/loleaflet/src/layer/marker/Marker.js
index f20b892e5..3db3dbfd9 100644
--- a/loleaflet/src/layer/marker/Marker.js
+++ b/loleaflet/src/layer/marker/Marker.js
@@ -56,8 +56,8 @@ L.Marker = L.Layer.extend({
 	},
 
 	onDown: function () {
-		if (this._map && this._map.touchCalc) {
-			this._map.touchCalc.disable();
+		if (this._map && this._map.touchGesture) {
+			this._map.touchGesture.disable();
 		}
 	},
 
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index c23b6b95a..17ca49206 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -117,7 +117,7 @@ L.Map = L.Evented.extend({
 			this.options.inertia = false;
 			this.dragging._draggable._manualDrag = true;
 			this._mainEvents('off');
-			this.addHandler('touchCalc', L.Map.CalcTap);
+			this.addHandler('touchGesture', L.Map.TouchGesture);
 			this.addHandler('touchZoom', L.Map.TouchZoom);
 		} else {
 			this.addHandler('mouse', L.Map.Mouse);
diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.TouchGesture.js
similarity index 96%
rename from loleaflet/src/map/handler/Map.CalcTap.js
rename to loleaflet/src/map/handler/Map.TouchGesture.js
index 58613175a..a3224c226 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -4,11 +4,11 @@
  */
 
 L.Map.mergeOptions({
-	touchCalc: true,
+	touchGesture: true,
 });
 
 /* global Hammer $ */
-L.Map.CalcTap = L.Handler.extend({
+L.Map.TouchGesture = L.Handler.extend({
 
 	initialize: function (map) {
 		L.Handler.prototype.initialize.call(this, map);
@@ -82,8 +82,8 @@ L.Map.CalcTap = L.Handler.extend({
 	},
 
 	_onDocUp: function () {
-		if (!this._map.touchCalc.enabled()) {
-			this._map.touchCalc.enable();
+		if (!this._map.touchGesture.enabled()) {
+			this._map.touchGesture.enable();
 		}
 	},
 
@@ -145,7 +145,7 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		if (this._map._docLayer._cellCursor.contains(latlng)) {
+		if (this._map._docLayer._cellCursor && this._map._docLayer._cellCursor.contains(latlng)) {
 			this._cellSelections = true;
 			this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		} else {


More information about the Libreoffice-commits mailing list