never stack transforms, simpler grid layer anim, ref #1705

This commit is contained in:
Vladimir Agafonkin 2014-01-10 19:11:59 +02:00
parent 758679ab69
commit b5569dd0c3
3 changed files with 17 additions and 27 deletions

View File

@ -470,14 +470,9 @@ L.GridLayer = L.Layer.extend({
this._prepareBgBuffer();
}
var bg = this._bgBuffer,
transform = L.DomUtil.TRANSFORM,
initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform],
scaleStr = L.DomUtil.getScaleString(e.scale, e.origin);
var offset = e.delta.add(e.origin.multiplyBy(1 - e.scale));
bg.style[transform] = e.backwards ?
scaleStr + ' ' + initialTransform :
initialTransform + ' ' + scaleStr;
L.DomUtil.setTransform(this._bgBuffer, offset, e.scale);
},
_endZoomAnim: function () {

View File

@ -57,12 +57,12 @@ L.Map.include(!zoomAnimated ? {} : {
.fire('movestart')
.fire('zoomstart');
this._animateZoom(center, zoom, origin, scale, null, true);
this._animateZoom(center, zoom, origin, scale, new L.Point(0, 0));
return true;
},
_animateZoom: function (center, zoom, origin, scale, delta, backwards) {
_animateZoom: function (center, zoom, origin, scale, delta) {
this._animatingZoom = true;
@ -83,8 +83,7 @@ L.Map.include(!zoomAnimated ? {} : {
zoom: zoom,
origin: origin,
scale: scale,
delta: delta,
backwards: backwards
delta: delta
});
},

View File

@ -80,12 +80,13 @@ L.Map.TouchZoom = L.Handler.extend({
},
_updateOnMove: function () {
var map = this._map,
origin = this._getScaleOrigin(),
center = map.layerPointToLatLng(origin),
zoom = map.getScaleZoom(this._scale);
var map = this._map;
map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta);
this._origin = this._getScaleOrigin();
this._center = map.layerPointToLatLng(this._origin);
this._zoom = map.getScaleZoom(this._scale);
map._animateZoom(this._center, this._zoom, this._startCenter, this._scale, this._delta);
},
_onTouchEnd: function () {
@ -104,18 +105,13 @@ L.Map.TouchZoom = L.Handler.extend({
.off(document, 'touchmove', this._onTouchMove)
.off(document, 'touchend', this._onTouchEnd);
var origin = this._getScaleOrigin(),
center = map.layerPointToLatLng(origin),
var oldZoom = map.getZoom(),
zoomDelta = this._zoom - oldZoom,
finalZoom = map._limitZoom(oldZoom + (zoomDelta > 0 ? Math.ceil(zoomDelta) : Math.floor(zoomDelta))),
finalScale = map.getZoomScale(finalZoom),
delta = this._delta.add(this._centerOffset.subtract(this._delta).multiplyBy(1 - 1 / this._scale));
oldZoom = map.getZoom(),
floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom,
roundZoomDelta = (floatZoomDelta > 0 ?
Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)),
zoom = map._limitZoom(oldZoom + roundZoomDelta),
scale = map.getZoomScale(zoom) / this._scale;
map._animateZoom(center, zoom, origin, scale);
map._animateZoom(this._center, finalZoom, this._origin, finalScale, delta);
},
_getScaleOrigin: function () {