loleaflet/src/geo/LatLngBounds.js | 11 ++ loleaflet/src/layer/tile/TileLayer.js | 2 loleaflet/src/map/handler/Map.TouchGesture.js | 96 +++++++++++++++++++++++--- 3 files changed, 99 insertions(+), 10 deletions(-)
New commits: commit 41c6d402f47c28ad17c6cb14aa5aacfee2235d1c Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Jun 27 16:57:22 2019 -0400 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jul 15 11:31:22 2019 +0200 loleaflet: mobile: enable graphic dragging Change-Id: Ia6ef34ff99891ad249d6f7aa6ed5915723d1013b Reviewed-on: https://gerrit.libreoffice.org/75619 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 183c87e4b..9cd0935bd 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1848,7 +1848,7 @@ L.TileLayer = L.GridLayer.extend({ this._graphicMarker.isDragged = true; this._graphicMarker._startPos = aPos; } - else if (e.type === 'graphicmoveend') { + else if (e.type === 'graphicmoveend' && this._graphicMarker._startPos) { var deltaPos = aPos.subtract(this._graphicMarker._startPos); if (deltaPos.x === 0 && deltaPos.y === 0) { this._graphicMarker.isDragged = false; diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js index 3acf95dc8..1fb90af1c 100644 --- a/loleaflet/src/map/handler/Map.TouchGesture.js +++ b/loleaflet/src/map/handler/Map.TouchGesture.js @@ -9,9 +9,15 @@ L.Map.mergeOptions({ /* global Hammer $ */ L.Map.TouchGesture = L.Handler.extend({ + statics: { + MAP: 1, + CURSOR: 2, + GRAPHIC: 4 + }, initialize: function (map) { L.Handler.prototype.initialize.call(this, map); + this._state = L.Map.TouchGesture.MAP; if (!this._hammer) { this._hammer = new Hammer(this._map._mapPane); @@ -103,8 +109,30 @@ L.Map.TouchGesture = L.Handler.extend({ }, _onHammer: function (e) { - L.DomEvent.preventDefault(e.srcEvent); - L.DomEvent.stopPropagation(e.srcEvent); + this._map.notifyActive(); + if (e.isFirst) { + var point = e.pointers[0], + containerPoint = this._map.mouseEventToContainerPoint(point), + layerPoint = this._map.containerPointToLayerPoint(containerPoint), + latlng = this._map.layerPointToLatLng(layerPoint); + + if (this._map._docLayer._graphicMarker && this._map._docLayer._graphicMarker.getBounds().contains(latlng)) { + this._state = L.Map.TouchGesture.GRAPHIC; + } else if (this._map._docLayer._cellCursor && this._map._docLayer._cellCursor.contains(latlng)) { + this._state = L.Map.TouchGesture.CURSOR; + } else { + this._state = L.Map.TouchGesture.MAP; + } + } + + if (e.isLast && this._state !== L.Map.TouchGesture.MAP) { + this._state = L.Map.TouchGesture.hitTest.MAP; + } + + if ($(e.srcEvent.target).has(this._map._mapPane)) { + L.DomEvent.preventDefault(e.srcEvent); + L.DomEvent.stopPropagation(e.srcEvent); + } }, _onDocUp: function () { @@ -125,7 +153,6 @@ L.Map.TouchGesture = L.Handler.extend({ 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(); }, @@ -139,7 +166,6 @@ L.Map.TouchGesture = L.Handler.extend({ 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); - this._cellSelections = false; if (!this._map.hasFocus()) { this._map.focus(); @@ -183,8 +209,6 @@ L.Map.TouchGesture = L.Handler.extend({ } if (increasedCellCursor && increasedCellCursor.contains(latlng)) { - this._cellSelections = true; - if (!originalCellCursor.contains(latlng)) { var lat = latlng.lat; var lng = latlng.lng; @@ -204,7 +228,11 @@ L.Map.TouchGesture = L.Handler.extend({ latlng = new L.LatLng(lat, lng); mousePos = this._map._docLayer._latLngToTwips(latlng); } + } + if (this._state === L.Map.TouchGesture.GRAPHIC) { + this._map._docLayer._graphicMarker._onDragStart(e.srcEvent); + } else if (this._state === L.Map.TouchGesture.CURSOR) { this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0); } else { this._map.dragging._draggable._onDown(this._constructFakeEvent(point, 'mousedown')); @@ -218,7 +246,9 @@ L.Map.TouchGesture = L.Handler.extend({ latlng = this._map.layerPointToLatLng(layerPoint), mousePos = this._map._docLayer._latLngToTwips(latlng); - if (this._cellSelections) { + if (this._state === L.Map.TouchGesture.GRAPHIC) { + this._map._docLayer._graphicMarker._onDrag(e.srcEvent); + } else if (this._state === L.Map.TouchGesture.CURSOR) { this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0); } else { this._map.dragging._draggable._onMove(this._constructFakeEvent(point, 'mousemove')); @@ -232,8 +262,9 @@ L.Map.TouchGesture = L.Handler.extend({ latlng = this._map.layerPointToLatLng(layerPoint), mousePos = this._map._docLayer._latLngToTwips(latlng); - if (this._cellSelections) { - this._cellSelections = false; + if (this._state === L.Map.TouchGesture.GRAPHIC) { + this._map._docLayer._graphicMarker._onDragEnd(e.srcEvent); + } else if (this._state === L.Map.TouchGesture.CURSOR) { this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0); } else { this._map.dragging._draggable._onUp(this._constructFakeEvent(point, 'mouseup')); commit c72e68154f5a37adad65004b7520e0da2538c330 Author: Marco Cecchetti <mrcek...@gmail.com> AuthorDate: Fri Jun 28 10:37:19 2019 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jul 15 11:31:13 2019 +0200 loleaflet: mobile enable tripletap for opening links Change-Id: I9bcf7dfda7984b51f7be4c195496a892046077bc Reviewed-on: https://gerrit.libreoffice.org/75618 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js index 5553f8865..3acf95dc8 100644 --- a/loleaflet/src/map/handler/Map.TouchGesture.js +++ b/loleaflet/src/map/handler/Map.TouchGesture.js @@ -25,6 +25,12 @@ L.Map.TouchGesture = L.Handler.extend({ enable: true }); + var singleTap = this._hammer.get('tap'); + var doubleTap = this._hammer.get('doubletap'); + var tripleTap = new Hammer.Tap({event: 'tripletap', taps: 3 }); + this._hammer.add(tripleTap); + tripleTap.recognizeWith([doubleTap, singleTap]); + if (L.Browser.touch) { L.DomEvent.on(this._map._mapPane, 'touchstart touchmove touchend touchcancel', L.DomEvent.preventDefault); } @@ -68,6 +74,7 @@ L.Map.TouchGesture = L.Handler.extend({ 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._hammer.on('tripletap', L.bind(this._onTripleTap, this)); this._map.on('updatepermission', this._onPermission, this); this._onPermission({perm: this._map._permission}); }, @@ -81,6 +88,7 @@ L.Map.TouchGesture = L.Handler.extend({ 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('tripletap', L.bind(this._onTripleTap, this)); this._map.off('updatepermission', this._onPermission, this); }, @@ -149,6 +157,17 @@ L.Map.TouchGesture = L.Handler.extend({ this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0); }, + _onTripleTap: function (e) { + 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); + + this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 8192); + this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 8192); + }, + _onPanStart: function (e) { var point = e.pointers[0], containerPoint = this._map.mouseEventToContainerPoint(point), commit 02be8f962d91b71bee8a705f5f80317b3327ed72 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Jun 26 15:51:04 2019 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jul 15 11:31:03 2019 +0200 Increase selectable cell area Change-Id: If9ca302253369bfa5708097106507e8f3d8d398b Reviewed-on: https://gerrit.libreoffice.org/75617 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/src/geo/LatLngBounds.js b/loleaflet/src/geo/LatLngBounds.js index 72ebe646d..e6f7396a2 100644 --- a/loleaflet/src/geo/LatLngBounds.js +++ b/loleaflet/src/geo/LatLngBounds.js @@ -60,6 +60,17 @@ L.LatLngBounds.prototype = { new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); }, + // extend the bounds by a percentage + padVertically: function (bufferRatio) { // (Number) -> LatLngBounds + var sw = this._southWest, + ne = this._northEast, + heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio; + + return new L.LatLngBounds( + new L.LatLng(sw.lat - heightBuffer, sw.lng), + new L.LatLng(ne.lat + heightBuffer, ne.lng)); + }, + getCenter: function () { // -> LatLng return new L.LatLng( (this._southWest.lat + this._northEast.lat) / 2, diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js index 0ae55b59b..5553f8865 100644 --- a/loleaflet/src/map/handler/Map.TouchGesture.js +++ b/loleaflet/src/map/handler/Map.TouchGesture.js @@ -156,8 +156,36 @@ L.Map.TouchGesture = L.Handler.extend({ latlng = this._map.layerPointToLatLng(layerPoint), mousePos = this._map._docLayer._latLngToTwips(latlng); - if (this._map._docLayer._cellCursor && this._map._docLayer._cellCursor.contains(latlng)) { + var originalCellCursor = this._map._docLayer._cellCursor; + var increaseRatio = 0.40; + var increasedCellCursor = null; + if (originalCellCursor) { + increasedCellCursor = originalCellCursor.padVertically(increaseRatio); + } + + if (increasedCellCursor && increasedCellCursor.contains(latlng)) { this._cellSelections = true; + + if (!originalCellCursor.contains(latlng)) { + var lat = latlng.lat; + var lng = latlng.lng; + + var sw = originalCellCursor._southWest, + ne = originalCellCursor._northEast; + var heightBuffer = Math.abs(sw.lat - ne.lat) * increaseRatio; + + if (lat < originalCellCursor.getSouthWest().lat) { + lat = lat + heightBuffer; + } + + if (lat > originalCellCursor.getNorthEast().lat) { + lat = lat - heightBuffer; + } + + latlng = new L.LatLng(lat, lng); + mousePos = this._map._docLayer._latLngToTwips(latlng); + } + this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0); } else { this._map.dragging._draggable._onDown(this._constructFakeEvent(point, 'mousedown')); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits