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
This commit is contained in:
Marco Cecchetti 2019-10-20 14:56:33 +02:00
parent dcbf91b597
commit 84bc57c4d3
2 changed files with 14 additions and 2 deletions

View file

@ -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;

View file

@ -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 () {