diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2021-06-04 10:02:35 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2021-06-04 14:58:36 +0100 |
commit | e24b00cf8fbfd8d542e90219cd2fd3efa3519d58 (patch) | |
tree | 48c34081ee064667b6e40caf70e55214866aa2ba | |
parent | Add 'messagesdone' event after all slurped msgs are emitted. (diff) | |
download | online-e24b00cf8fbfd8d542e90219cd2fd3efa3519d58.tar.gz online-e24b00cf8fbfd8d542e90219cd2fd3efa3519d58.zip |
Update table markers only on 'messagesdone'.
Also connect just once to the zoomend message in a more sensible place.
Change-Id: I9ac799a0c9a0f77a61a85954d270af6e7ca28dac
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | loleaflet/src/layer/tile/CanvasTileLayer.js | 1 | ||||
-rw-r--r-- | loleaflet/src/layer/tile/TileLayer.TableOverlay.js | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js index 1e11224343..a91bd79e6a 100644 --- a/loleaflet/src/layer/tile/CanvasTileLayer.js +++ b/loleaflet/src/layer/tile/CanvasTileLayer.js @@ -999,6 +999,7 @@ L.CanvasTileLayer = L.Layer.extend({ this._painter._addGridSection(); } this._syncTileContainerSize(); + this._setupTableOverlay(); }, // Returns true if the document type is Writer. diff --git a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js index 958141206e..e050396800 100644 --- a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js +++ b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js @@ -14,6 +14,10 @@ L.CanvasTileLayer.include({ this._selectionHeaderDistanceFromTable = 6; this._selectionHeaderHeight = 16; }, + _setupTableOverlay: function() { + this._map.on('messagesdone', this._updateTableMarkers, this); + this._map.on('zoomend', this._onZoomForTableMarkers, this); + }, _convertPixelToTwips: function(pixel) { var point = this._latLngToTwips(this._map.unproject(new L.Point(pixel, 0))); return point.x; @@ -132,6 +136,12 @@ L.CanvasTileLayer.include({ }, _updateTableMarkers: function() { + if (this._currentTableData === undefined) + return; // not writer, no table selected yet etc. + if (this._currentTableMarkerJson === this._lastTableMarkerJson) + return; // identical table setup. + this._lastTableMarkerJson = this._currentTableMarkerJson; + // Clean-up first this._clearTableMarkers(); @@ -210,6 +220,7 @@ L.CanvasTileLayer.include({ } }, _onZoomForTableMarkers: function () { + this._lastTableMarkerJson = 'foo'; this._updateTableMarkers(); }, _onTableSelectedMsg: function (textMsg) { @@ -224,9 +235,8 @@ L.CanvasTileLayer.include({ // Parse the message textMsg = textMsg.substring('tableselected:'.length + 1); var message = JSON.parse(textMsg); + this._currentTableMarkerJson = textMsg; this._currentTableData = message; - this._updateTableMarkers(); - this._map.on('zoomend', L.bind(this._onZoomForTableMarkers, this)); }, _addSelectionMarkers: function (type, positions, start, end) { if (positions.length < 2) |