add DomUtil.setTransform for translate+scale ops

This commit is contained in:
Vladimir Agafonkin 2014-01-10 16:05:58 +02:00
parent 30f86b11e3
commit 758679ab69
4 changed files with 9 additions and 5 deletions

View File

@ -141,6 +141,10 @@ L.DomUtil = {
point.y + 'px' + (is3d ? ',0)' : ')');
},
setTransform: function (el, point, scale) {
el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point) + (scale ? ' scale(' + scale + ')' : '');
},
getScaleString: function (scale, origin) {
return L.DomUtil.getTranslateString(origin.multiplyBy(1 - scale)) + ' scale(' + scale + ') ';
},
@ -151,7 +155,7 @@ L.DomUtil = {
el._leaflet_pos = point;
if (!disable3D && L.Browser.any3d) {
el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point);
L.DomUtil.setTransform(el, point);
} else {
el.style.left = point.x + 'px';
el.style.top = point.y + 'px';

View File

@ -92,7 +92,7 @@ L.ImageOverlay = L.Layer.extend({
size = map._latLngToNewLayerPoint(this._bounds.getSouthEast(), e.zoom, e.center)._subtract(topLeft),
origin = topLeft._add(size._multiplyBy((1 - 1 / scale) / 2));
image.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';
L.DomUtil.setTransform(image, origin, scale);
},
_reset: function () {

View File

@ -498,7 +498,7 @@ L.GridLayer = L.Layer.extend({
if (map && !map._animatingZoom && !map.touchZoom._zooming) {
this._bgBuffer.innerHTML = '';
this._bgBuffer.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString();
L.DomUtil.setTransform(this._bgBuffer);
}
},
@ -514,7 +514,7 @@ L.GridLayer = L.Layer.extend({
// prepare the buffer to become the front tile pane
bg.style.visibility = 'hidden';
bg.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString();
L.DomUtil.setTransform(bg);
// switch out the current layer to be the new bg layer (and vice-versa)
this._tileContainer = bg;

View File

@ -47,7 +47,7 @@ L.Renderer = L.Layer.extend({
var scale = this._map.getZoomScale(e.zoom),
offset = this._map._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._bounds.min);
this._container.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') ';
L.DomUtil.setTransform(this._container, offset, scale);
},
_update: function () {