loleaflet/src/layer/tile/TileLayer.js | 10 ++++++++++ 1 file changed, 10 insertions(+)
New commits: commit 3d029cb6d0011f7cdf158a9d14ff704b3321695b Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Thu Feb 13 02:04:50 2020 +0000 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Feb 13 10:10:02 2020 +0100 Instead of zooming each time we resize, instead keep zoom and pan. This helps us smoothly follow the cursor, and to adapt to less space available when eg. the wizard or the keyboard pop up. Ensure we do the right zoom-to-fit on the first call, interestingly if we do not do that - we get just a single tile at the top left (que?). Change-Id: Ib26f9b474caa631028e18e790dd50c058cbaef3b Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88577 Tested-by: Jan Holesovsky <ke...@collabora.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 7be34c242..298ce5a41 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -306,6 +306,7 @@ L.TileLayer = L.GridLayer.extend({ map.on('requestloksession', this._onRequestLOKSession, this); map.on('error', this._mapOnError, this); if (map.options.autoFitWidth !== false) { + // always true since autoFitWidth is never set map.on('resize', this._fitWidthZoom, this); } // Retrieve the initial cell cursor position (as LOK only sends us an @@ -3106,10 +3107,12 @@ L.TileLayer = L.GridLayer.extend({ this._map._socket.sendMessage('requestloksession'); }, + // This is really just called on zoomend _fitWidthZoom: function (e, maxZoom) { if (isNaN(this._docWidthTwips)) { return; } var oldSize = e ? e.oldSize : this._map.getSize(); var newSize = e ? e.newSize : this._map.getSize(); + if (this._docType !== 'presentation' && newSize.x - oldSize.x === 0) { return; } var widthTwips = newSize.x * this._map.options.tileWidthTwips / this._tileSize; @@ -3123,6 +3126,13 @@ L.TileLayer = L.GridLayer.extend({ zoom = Math.min(maxZoom, Math.max(1, zoom)); if (this._docWidthTwips * this._map.getZoomScale(zoom, 10) < widthTwips) { + // Not clear why we wanted to zoom in the past. + // This resets the view & scroll area and does a 'panTo' + // to keep the cursor in view. + // But of course, zoom to fit the first time. + if (this._firstFitDone) + zoom = this._map._zoom; + this._firstFitDone = true; this._map.setZoom(zoom, {animate: false}); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits