diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js index 471ccd48f..a679814d1 100644 --- a/loleaflet/src/layer/tile/CanvasTileLayer.js +++ b/loleaflet/src/layer/tile/CanvasTileLayer.js @@ -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) { diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js index ab850c640..9b7bf416a 100644 --- a/loleaflet/src/map/handler/Map.TouchGesture.js +++ b/loleaflet/src/map/handler/Map.TouchGesture.js @@ -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);