[Libreoffice-commits] online.git: loleaflet/src
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 30 07:32:02 UTC 2019
loleaflet/src/layer/tile/TileLayer.TableOverlay.js | 24 ++-------------------
loleaflet/src/layer/tile/TileLayer.js | 18 +++++++++++++++
loleaflet/src/map/handler/Map.TouchGesture.js | 9 +++++--
3 files changed, 27 insertions(+), 24 deletions(-)
New commits:
commit 6b3eea91215a0e1d361db639dc9b4514a310cdbb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Sep 30 09:24:08 2019 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Sep 30 09:31:44 2019 +0200
Convert the touch to mouse event when dragging graphic seelction
This is needed so the dragging code can correctly recognize the
event and set the variables or the preview won't be drawn during
dragging.
Change-Id: I9b92985f9557cf6d87db4f73507b961941e0a039
Reviewed-on: https://gerrit.libreoffice.org/79827
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
index 6a7cba29b..978a3ebc5 100644
--- a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
+++ b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
@@ -333,36 +333,18 @@ L.TileLayer.include({
if (e.originalEvent)
e.originalEvent.preventDefault();
},
- _createMouseEvent: function (type, inputEvent) {
- var event = inputEvent;
- if (inputEvent.type == 'touchstart' || inputEvent.type == 'touchmove') {
- event = inputEvent.touches[0];
- }
- else if (inputEvent.type == 'touchend') {
- event = inputEvent.changedTouches[0];
- }
-
- var newEvent = document.createEvent('MouseEvents');
- newEvent.initMouseEvent(
- type, true, true, window, 1,
- event.screenX, event.screenY,
- event.clientX, event.clientY,
- false, false, false, false, 0, null
- );
- return newEvent;
- },
_onTableMoveMarkerDrag: function (event) {
var mouseEvent;
if (event.type == 'dragstart') {
- mouseEvent = this._createMouseEvent('mousedown', event.originalEvent);
+ mouseEvent = this._createNewMouseEvent('mousedown', event.originalEvent);
this._graphicMarker._onDragStart(mouseEvent);
}
else if (event.type == 'drag') {
- mouseEvent = this._createMouseEvent('mousemove', event.originalEvent);
+ mouseEvent = this._createNewMouseEvent('mousemove', event.originalEvent);
this._graphicMarker._onDrag(mouseEvent);
}
else if (event.type == 'dragend') {
- mouseEvent = this._createMouseEvent('mouseup', event.originalEvent);
+ mouseEvent = this._createNewMouseEvent('mouseup', event.originalEvent);
this._graphicMarker._onDragEnd(mouseEvent);
}
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 8a39c97b7..0d1668489 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -334,6 +334,24 @@ L.TileLayer = L.GridLayer.extend({
map.fire('statusindicator', {statusType: 'loleafletloaded'});
},
+ _createNewMouseEvent: function (type, inputEvent) {
+ var event = inputEvent;
+ if (inputEvent.type == 'touchstart' || inputEvent.type == 'touchmove') {
+ event = inputEvent.touches[0];
+ }
+ else if (inputEvent.type == 'touchend') {
+ event = inputEvent.changedTouches[0];
+ }
+ var newEvent = document.createEvent('MouseEvents');
+ newEvent.initMouseEvent(
+ type, true, true, window, 1,
+ event.screenX, event.screenY,
+ event.clientX, event.clientY,
+ false, false, false, false, 0, null
+ );
+ return newEvent;
+ },
+
clearAnnotations: function() {
console.debug('Implemented in child classes');
},
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index e78709e56..be2d3813f 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -300,7 +300,8 @@ L.Map.TouchGesture = L.Handler.extend({
if (this._state === L.Map.TouchGesture.MARKER) {
this._map._fireDOMEvent(this._marker, point, 'mousedown');
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
- this._map._docLayer._graphicMarker._onDragStart(point);
+ var mouseEvent = this._map._docLayer._createNewMouseEvent('mousedown', point);
+ this._map._docLayer._graphicMarker._onDragStart(mouseEvent);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
} else {
@@ -319,7 +320,8 @@ L.Map.TouchGesture = L.Handler.extend({
this._map._fireDOMEvent(this._map, point, 'mousemove');
this._moving = true;
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
- this._map._docLayer._graphicMarker._onDrag(point);
+ var mouseEvent = this._map._docLayer._createNewMouseEvent('mousemove', point);
+ this._map._docLayer._graphicMarker._onDrag(mouseEvent);
this._moving = true;
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
@@ -339,7 +341,8 @@ L.Map.TouchGesture = L.Handler.extend({
this._map._fireDOMEvent(this._map, point, 'mouseup');
this._moving = false;
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
- this._map._docLayer._graphicMarker._onDragEnd(point);
+ var mouseEvent = this._map._docLayer._createNewMouseEvent('mouseup', point);
+ this._map._docLayer._graphicMarker._onDragEnd(mouseEvent);
this._moving = false;
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
More information about the Libreoffice-commits
mailing list