From 30a3edb393153615813dec34801511000956ae28 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Tue, 11 Dec 2012 20:19:16 +0200 Subject: [PATCH] simplify zoom animation calculations a bit --- src/layer/ImageOverlay.js | 5 ++--- src/layer/vector/Path.SVG.js | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/layer/ImageOverlay.js b/src/layer/ImageOverlay.js index e9fd5867..af100efa 100644 --- a/src/layer/ImageOverlay.js +++ b/src/layer/ImageOverlay.js @@ -97,8 +97,7 @@ L.ImageOverlay = L.Class.extend({ topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center), size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft), - currentSize = map.latLngToLayerPoint(se)._subtract(map.latLngToLayerPoint(nw)), - origin = topLeft._add(size._subtract(currentSize)._divideBy(2)); + origin = topLeft._add(size._multiplyBy(1/2 * (1 - 1/scale))); image.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') '; @@ -107,7 +106,7 @@ L.ImageOverlay = L.Class.extend({ _reset: function () { var image = this._image, topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()), - size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft); + size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft); L.DomUtil.setPosition(image, topLeft); diff --git a/src/layer/vector/Path.SVG.js b/src/layer/vector/Path.SVG.js index 879d20dc..697beb17 100644 --- a/src/layer/vector/Path.SVG.js +++ b/src/layer/vector/Path.SVG.js @@ -159,13 +159,12 @@ L.Map.include({ } }, - _animatePathZoom: function (opt) { - var scale = this.getZoomScale(opt.zoom), - offset = this._getCenterOffset(opt.center), - translate = offset.multiplyBy(-scale)._add(this._pathViewport.min); + _animatePathZoom: function (e) { + var scale = this.getZoomScale(e.zoom), + offset = this._getCenterOffset(e.center)._multiplyBy(-scale); - this._pathRoot.style[L.DomUtil.TRANSFORM] = - L.DomUtil.getTranslateString(translate) + ' scale(' + scale + ') '; + this._pathRoot.style[L.DomUtil.TRANSFORM] += + L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') '; this._pathZooming = true; },