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