Center restore after zoom

private/hcvcastro/forking
Mihai Varga 2015-04-03 17:22:19 +03:00
parent f870f78e1d
commit 4d66d025fa
1 changed files with 7 additions and 0 deletions

View File

@ -359,6 +359,10 @@ L.GridLayer = L.Layer.extend({
var topLeft = this._map.unproject([0, 0], this._tileZoom);
var bottomRight = this._map.unproject(docPixelLimits, this._tileZoom);
var maxBounds = new L.LatLngBounds(topLeft, bottomRight);
// previous scroll position (relative)
var prevX = this._map._outerContainer.scrollLeft / this._map._container.clientWidth;
var prevY = this._map._outerContainer.scrollTop / this._map._container.clientHeight;
L.DomUtil.setStyle(this._map._outerContainer, 'overflow', '');
L.DomUtil.setStyle(this._map._container, 'width', docPixelLimits.x + 'px');
L.DomUtil.setStyle(this._map._container, 'height', docPixelLimits.y + 'px');
@ -368,6 +372,9 @@ L.GridLayer = L.Layer.extend({
// crashes on Chrome
setTimeout(L.bind(this._map.invalidateSize, this._map), 100);
L.DomUtil.setStyle(this._map._outerContainer, 'overflow', 'auto');
// restore the relative scroll position
this._map._outerContainer.scrollLeft = prevX * this._map._container.clientWidth;
this._map._outerContainer.scrollTop = prevY * this._map._container.clientHeight;
},
_setZoomTransforms: function (center, zoom) {