From 84bc57c4d3711c604a29f9c20d1dcb53e4ba889d Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Sun, 20 Oct 2019 14:56:33 +0200 Subject: [PATCH] loleaflet: headers/scrolling can become messed up on adding a new sheet scroll up to 200, enter some text, add a new sheet, headers, grid lines are wrong, swicth back to the previous sheet, now headers and document position are wrong too Change-Id: If9d59b5509584e92491bbce4b8db54ec5308b211 --- loleaflet/src/control/Control.Scroll.js | 2 +- loleaflet/src/layer/tile/GridLayer.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js index ab3fc47c6..265640b53 100644 --- a/loleaflet/src/control/Control.Scroll.js +++ b/loleaflet/src/control/Control.Scroll.js @@ -239,7 +239,7 @@ L.Control.Scroll = L.Control.extend({ _onUpdateScrollOffset: function (e) { // used on window resize - if (this._map._docLayer._docType === 'spreadsheet') { + if (e.updateHeaders && this._map._docLayer._docType === 'spreadsheet') { var offset = new L.Point(e.x - this._prevScrollX, e.y - this._prevScrollY); if (offset.x === 0) { offset.x = 1; diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index 26a3806d3..e88bdbe35 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -443,7 +443,7 @@ L.GridLayer = L.Layer.extend({ var newScrollPos = centerPixel.subtract(this._map.getSize().divideBy(2)); var x = Math.round(newScrollPos.x < 0 ? 0 : newScrollPos.x); var y = Math.round(newScrollPos.y < 0 ? 0 : newScrollPos.y); - this._map.fire('updatescrolloffset', {x: x, y: y}); + this._map.fire('updatescrolloffset', {x: x, y: y, updateHeaders: true}); }, _setZoomTransforms: function (center, zoom) { @@ -702,6 +702,18 @@ L.GridLayer = L.Layer.extend({ this._level.el.appendChild(fragment); } + + if (typeof (this._prevSelectedPart) === 'number' && + this._prevSelectedPart !== this._selectedPart + && this._docType === 'spreadsheet') { + this._map.fire('updatescrolloffset', {x: 0, y: 0, updateHeaders: false}); + this._map.scrollTop(0); + this._map.scrollLeft(0); + this._cellCursor = L.LatLngBounds.createDefault(); + this._prevCellCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(1, 1)); + this._cellCursorXY = new L.Point(-1, -1); + this._prevCellCursorXY = new L.Point(0, 0); + } }, _requestNewTiles: function () {