loleaflet/src/layer/tile/TileLayer.js | 86 +++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 36 deletions(-)
New commits: commit 82121cb783e330d27141eaf933c965fd78fc2164 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Tue Jul 21 13:59:27 2020 +0530 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Jul 21 13:25:04 2020 +0200 leaflet: fixed selection handler lagging behind Change-Id: Ic89a6827bac4511a8f9cd9afbcc2594cdc2046f3 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97897 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 2bbfd3c8f..c4a18db31 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1837,6 +1837,7 @@ L.TileLayer = L.GridLayer.extend({ this._twipsToLatLng(bottomRightTwips, this._map.getZoom())); this._updateScrollOnCellSelection(oldSelection, this._textSelectionEnd); + this._updateMarkers(); } else { this._textSelectionEnd = null; @@ -3169,42 +3170,7 @@ L.TileLayer = L.GridLayer.extend({ this._isEmptyRectangle(this._textSelectionEnd)) { return; } - - var startPos = this._map.project(this._textSelectionStart.getSouthWest()); - var endPos = this._map.project(this._textSelectionEnd.getSouthWest()); - var startMarkerPos = this._map.project(startMarker.getLatLng()); - if (startMarkerPos.distanceTo(endPos) < startMarkerPos.distanceTo(startPos) && startMarker._icon && endMarker._icon) { - // if the start marker is actually closer to the end of the selection - // reverse icons and markers - L.DomUtil.removeClass(startMarker._icon, 'leaflet-selection-marker-start'); - L.DomUtil.removeClass(endMarker._icon, 'leaflet-selection-marker-end'); - L.DomUtil.addClass(startMarker._icon, 'leaflet-selection-marker-end'); - L.DomUtil.addClass(endMarker._icon, 'leaflet-selection-marker-start'); - var tmp = startMarker; - startMarker = endMarker; - endMarker = tmp; - } - else if (startMarker._icon && endMarker._icon) { - // normal markers and normal icons - L.DomUtil.removeClass(startMarker._icon, 'leaflet-selection-marker-end'); - L.DomUtil.removeClass(endMarker._icon, 'leaflet-selection-marker-start'); - L.DomUtil.addClass(startMarker._icon, 'leaflet-selection-marker-start'); - L.DomUtil.addClass(endMarker._icon, 'leaflet-selection-marker-end'); - } - - if (!startMarker.isDragged) { - var pos = this._map.project(this._textSelectionStart.getSouthWest()); - pos = this._map.unproject(pos); - startMarker.setLatLng(pos); - this._map.addLayer(startMarker); - } - - if (!endMarker.isDragged) { - pos = this._map.project(this._textSelectionEnd.getSouthEast()); - pos = this._map.unproject(pos); - endMarker.setLatLng(pos); - this._map.addLayer(endMarker); - } + this._updateMarkers(); } else { this._textSelectionStart = null; @@ -3217,6 +3183,54 @@ L.TileLayer = L.GridLayer.extend({ } }, + _updateMarkers: function() { + var startMarker, endMarker; + for (var key in this._selectionHandles) { + if (key === 'start') { + startMarker = this._selectionHandles[key]; + } + else if (key === 'end') { + endMarker = this._selectionHandles[key]; + } + } + + var startPos = this._map.project(this._textSelectionStart.getSouthWest()); + var endPos = this._map.project(this._textSelectionEnd.getSouthWest()); + var startMarkerPos = this._map.project(startMarker.getLatLng()); + if (startMarkerPos.distanceTo(endPos) < startMarkerPos.distanceTo(startPos) && startMarker._icon && endMarker._icon) { + // if the start marker is actually closer to the end of the selection + // reverse icons and markers + L.DomUtil.removeClass(startMarker._icon, 'leaflet-selection-marker-start'); + L.DomUtil.removeClass(endMarker._icon, 'leaflet-selection-marker-end'); + L.DomUtil.addClass(startMarker._icon, 'leaflet-selection-marker-end'); + L.DomUtil.addClass(endMarker._icon, 'leaflet-selection-marker-start'); + var tmp = startMarker; + startMarker = endMarker; + endMarker = tmp; + } + else if (startMarker._icon && endMarker._icon) { + // normal markers and normal icons + L.DomUtil.removeClass(startMarker._icon, 'leaflet-selection-marker-end'); + L.DomUtil.removeClass(endMarker._icon, 'leaflet-selection-marker-start'); + L.DomUtil.addClass(startMarker._icon, 'leaflet-selection-marker-start'); + L.DomUtil.addClass(endMarker._icon, 'leaflet-selection-marker-end'); + } + + if (!startMarker.isDragged) { + var pos = this._map.project(this._textSelectionStart.getSouthWest()); + pos = this._map.unproject(pos); + startMarker.setLatLng(pos); + this._map.addLayer(startMarker); + } + + if (!endMarker.isDragged) { + pos = this._map.project(this._textSelectionEnd.getSouthEast()); + pos = this._map.unproject(pos); + endMarker.setLatLng(pos); + this._map.addLayer(endMarker); + } + }, + hasGraphicSelection: function() { return (this._graphicSelection !== null && !this._isEmptyRectangle(this._graphicSelection)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits