zoom-animation:Draw the last frame with final-zoom

...which is rounded to the allowed set of zooms hence reduce the view
jump after map's zoom is set. There is still a jump depending on the
position of the pinch center on the screen. This is because on setting
the zoom in Map, it repositions the center such that pinch center is now
the center of the screen.

Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: I2a79240373f333b96574b7fe5c2b18de7dec612e
This commit is contained in:
Dennis Francis 2020-12-29 12:09:27 +05:30 committed by Dennis Francis
parent 009c317da6
commit 4ad8a8d9d5
2 changed files with 18 additions and 11 deletions

View file

@ -461,7 +461,7 @@ L.CanvasTilePainter = L.Class.extend({
var paneBoundsList = ctx.paneBoundsList;
var splitPos = ctx.paneBoundsActive ? this._splitPos.multiplyBy(this._dpiScale) : new L.Point(0, 0);
var rafFunc = function () {
this._rafFunc = function () {
for (var i = 0; i < paneBoundsList.length; ++i) {
var paneBounds = paneBoundsList[i];
@ -493,18 +493,23 @@ L.CanvasTilePainter = L.Class.extend({
paneSize.x, paneSize.y);
}
painter._zoomRAF = requestAnimationFrame(rafFunc);
painter._zoomRAF = requestAnimationFrame(painter._rafFunc);
};
rafFunc();
this._rafFunc();
},
zoomStep: function (zoom, newCenter) {
_calcZoomFrameScale: function (zoom, newCenter) {
zoom = this._map._limitZoom(zoom);
var origZoom = this._map.getZoom();
// Compute relative-multiplicative scale of this zoom-frame w.r.t the starting zoom(ie the current Map's zoom).
this._zoomFrameScale = this._map.zoomToFactor(zoom - origZoom + this._map.options.zoom);
this._newCenter = this._map.project(newCenter).multiplyBy(this._dpiScale); // in core pixels
},
zoomStep: function (zoom, newCenter) {
this._calcZoomFrameScale(zoom, newCenter);
if (!this._inZoomAnim) {
this._inZoomAnim = true;
this._layer._prefetchTilesSync();
@ -513,10 +518,12 @@ L.CanvasTilePainter = L.Class.extend({
}
},
zoomStepEnd: function () {
this._zoomFrameScale = undefined;
zoomStepEnd: function (zoom, newCenter) {
if (this._inZoomAnim) {
cancelAnimationFrame(this._zoomRAF);
this._calcZoomFrameScale(zoom, newCenter);
this._rafFunc();
this._zoomFrameScale = undefined;
this._inZoomAnim = false;
}
}
@ -681,8 +688,8 @@ L.CanvasTileLayer = L.TileLayer.extend({
this._painter.zoomStep(zoom, newCenter);
},
zoomStepEnd: function () {
this._painter.zoomStepEnd();
zoomStepEnd: function (zoom, newCenter) {
this._painter.zoomStepEnd(zoom, newCenter);
},
_viewReset: function (e) {

View file

@ -569,11 +569,11 @@ L.Map.TouchGesture = L.Handler.extend({
this._center = this._map._limitCenter(this._map.mouseEventToLatLng({clientX: center.x, clientY: center.y}),
this._zoom, this._map.options.maxBounds);
var origCenter = this._map._limitCenter(this._map.mouseEventToLatLng({clientX: center.x, clientY: center.y}),
this._origCenter = this._map._limitCenter(this._map.mouseEventToLatLng({clientX: center.x, clientY: center.y}),
this._map.getZoom(), this._map.options.maxBounds);
if (this._map._docLayer.zoomStep) {
this._map._docLayer.zoomStep(this._zoom, origCenter);
this._map._docLayer.zoomStep(this._zoom, this._origCenter);
}
},
@ -610,7 +610,7 @@ L.Map.TouchGesture = L.Handler.extend({
this._pinchStartCenter = undefined;
if (this._map._docLayer.zoomStepEnd) {
this._map._docLayer.zoomStepEnd();
this._map._docLayer.zoomStepEnd(finalZoom, this._origCenter);
}
this._map.setView(this._center, finalZoom);