use offset when animating transform to avoid dividing by zero
This commit is contained in:
parent
c1b2c5c37c
commit
de4910f407
@ -502,7 +502,10 @@ L.GridLayer = L.Layer.extend({
|
||||
|
||||
_animateZoom: function (e) {
|
||||
// avoid stacking transforms by calculating cumulating translate/scale sequence
|
||||
this._translate = this._prevTranslate.multiplyBy(e.scale).add(e.origin.multiplyBy(1 - e.scale)).round();
|
||||
this._translate = this._prevTranslate.multiplyBy(e.scale)
|
||||
.add(e.origin.multiplyBy(1 - e.scale))
|
||||
.add(e.offset).round();
|
||||
|
||||
this._scale = this._prevScale * e.scale;
|
||||
|
||||
L.DomUtil.setTransform(this._bgBuffer, this._translate, this._scale);
|
||||
|
@ -45,7 +45,7 @@ L.Renderer = L.Layer.extend({
|
||||
|
||||
_animateZoom: function (e) {
|
||||
var origin = e.origin.subtract(this._map._getCenterLayerPoint()),
|
||||
offset = this._bounds.min.add(origin.multiplyBy(1 - e.scale));
|
||||
offset = this._bounds.min.add(origin.multiplyBy(1 - e.scale)).add(e.offset).round();
|
||||
|
||||
L.DomUtil.setTransform(this._container, offset, e.scale);
|
||||
},
|
||||
|
@ -78,14 +78,14 @@ L.Map.include(!zoomAnimated ? {} : {
|
||||
L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim');
|
||||
}
|
||||
|
||||
var scale = this.getZoomScale(zoom),
|
||||
origin = this._getCenterLayerPoint().add(this._getCenterOffset(center)._divideBy(1 - 1 / scale));
|
||||
var centerOffset = this._getCenterOffset(center);
|
||||
|
||||
this.fire('zoomanim', {
|
||||
center: center,
|
||||
zoom: zoom,
|
||||
origin: origin,
|
||||
scale: scale
|
||||
scale: this.getZoomScale(zoom),
|
||||
origin: this._getCenterLayerPoint().add(centerOffset),
|
||||
offset: centerOffset.multiplyBy(-1)
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user