loleaflet/src/layer/vector/Path.Drag.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
New commits: commit 515b8e62993be9a184d8de18e5dcaa44a7b4c07b Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Jun 27 16:38:32 2019 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Mon Aug 19 17:38:31 2019 +0200 loleaflet: mobile: enable manual dragging in L.Handler.PathDrag for touch devices, it is not necessary to add mouse event listeners Change-Id: Icc4ba5cacde47f79021d317af9b712ba17e84fd5 Reviewed-on: https://gerrit.libreoffice.org/77738 Reviewed-by: Henry Castro <hcas...@collabora.com> Tested-by: Henry Castro <hcas...@collabora.com> diff --git a/loleaflet/src/layer/vector/Path.Drag.js b/loleaflet/src/layer/vector/Path.Drag.js index b35c02b98..60e105388 100644 --- a/loleaflet/src/layer/vector/Path.Drag.js +++ b/loleaflet/src/layer/vector/Path.Drag.js @@ -89,8 +89,10 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends L.Path.Drag.prototype */ { L.DomUtil.removeClass(this._path._path, L.Handler.PathDrag.DRAGGING_CLS); } - L.DomEvent.off(document, 'mousemove touchmove', this._onDrag, this); - L.DomEvent.off(document, 'mouseup touchend', this._onDragEnd, this); + if (!this._path.options.manualDrag) { + L.DomEvent.off(document, 'mousemove touchmove', this._onDrag, this); + L.DomEvent.off(document, 'mouseup touchend', this._onDragEnd, this); + } }, /** @@ -115,9 +117,12 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends L.Path.Drag.prototype */ { L.DomEvent.stop(evt.originalEvent); L.DomUtil.addClass(this._path._renderer._container, 'leaflet-interactive'); - L.DomEvent - .on(document, MOVE[eventType], this._onDrag, this) - .on(document, END[eventType], this._onDragEnd, this); + + if (!this._path.options.manualDrag) { + L.DomEvent + .on(document, MOVE[eventType], this._onDrag, this) + .on(document, END[eventType], this._onDragEnd, this); + } if (this._path._map.dragging.enabled()) { // I guess it's required because mousdown gets simulated with a delay @@ -140,6 +145,9 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends L.Path.Drag.prototype */ { * @param {L.MouseEvent} evt */ _onDrag: function(evt) { + if (!this._startPoint) + return; + L.DomEvent.stop(evt); var first = (evt.touches && evt.touches.length >= 1 ? evt.touches[0] : evt); @@ -223,8 +231,10 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends L.Path.Drag.prototype */ { this._path._transform(null); } - L.DomEvent.off(document, 'mousemove touchmove', this._onDrag, this); - L.DomEvent.off(document, 'mouseup touchend', this._onDragEnd, this); + if (!this._path.options.manualDrag) { + L.DomEvent.off(document, 'mousemove touchmove', this._onDrag, this); + L.DomEvent.off(document, 'mouseup touchend', this._onDragEnd, this); + } this._restoreCoordGetters(); @@ -253,7 +263,7 @@ L.Handler.PathDrag = L.Handler.extend(/** @lends L.Path.Drag.prototype */ { this._path._map.dragging.enable(); } - if (!moved) { + if (!this._path.options.manualDrag && !moved) { this._path._map._handleDOMEvent(this._mouseDown); this._path._map._handleDOMEvent(evt) } @@ -400,5 +410,4 @@ var fnInitHook = function() { } }; -L.Path.addInitHook(fnInitHook); L.SVGGroup.addInitHook(fnInitHook); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits