zoom-animation: account for top margin as well if any

Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: If2f771b964d9960108b5eccb235a4c9849ab24ec
(cherry picked from commit a916313bccc6e3d772571d748621d65f967f39eb)
This commit is contained in:
Dennis Francis 2021-07-20 16:19:50 +05:30 committed by Dennis Francis
parent 90653ee8b5
commit b70aa8cd41

View file

@ -618,6 +618,7 @@ L.Map = L.Evented.extend({
}
this._docLayer.setZoomChanged(true);
var thisObj = this;
var cssBounds = this.getPixelBounds();
if (this._docLayer && this._docLayer._visibleCursor && this.getBounds().contains(this._docLayer._visibleCursor.getCenter())) {
// Calculate new center after zoom. The intent is that the caret
@ -626,10 +627,11 @@ L.Map = L.Evented.extend({
var caretPos = this._docLayer._visibleCursor.getCenter();
var newCenter = new L.LatLng(curCenter.lat + (caretPos.lat - curCenter.lat) * (1.0 - zoomScale),
curCenter.lng + (caretPos.lng - curCenter.lng) * (1.0 - zoomScale));
var thisObj = this;
this._docLayer.runZoomAnimation(zoom,
// pinchCenter
new L.LatLng(caretPos.lat,
new L.LatLng(
// Use the current y-center if there is a top margin.
cssBounds.min.y < 0 ? curCenter.lat : caretPos.lat,
// Use the current x-center if there is a left margin.
cssBounds.min.x < 0 ? curCenter.lng : caretPos.lng),
// mapUpdater
@ -644,9 +646,17 @@ L.Map = L.Evented.extend({
return;
}
var retValue = this.setView(curCenter, zoom, {zoom: options});
this._docLayer.setZoomChanged(false);
return retValue;
this._docLayer.runZoomAnimation(zoom,
// pinchCenter
curCenter,
// mapUpdater
function() {
thisObj.setView(curCenter, zoom, {zoom: options});
},
// runAtFinish
function() {
thisObj._docLayer.setZoomChanged(false);
});
},
zoomIn: function (delta, options) {