Skip to content

Commit

Permalink
Delay firing the 'update' event on renderers (should fix #4928) (#4929)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanSanchez authored and mourner committed Sep 21, 2016
1 parent 6e08ae4 commit c931d33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/layer/vector/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ L.Canvas = L.Renderer.extend({

// translate so we use the same path coordinates after canvas element moves
this._ctx.translate(-b.min.x, -b.min.y);

// Tell paths to redraw themselves
this.fire('update');
},

_initPath: function (layer) {
Expand Down
5 changes: 2 additions & 3 deletions src/layer/vector/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ L.Renderer = L.Layer.extend({
},

_update: function () {
// update pixel bounds of renderer container (for positioning/sizing/clipping later)
// Update pixel bounds of renderer container (for positioning/sizing/clipping later)
// Subclasses are responsible of firing the 'update' event.
var p = this.options.padding,
size = this._map.getSize(),
min = this._map.containerPointToLayerPoint(size.multiplyBy(-p)).round();
Expand All @@ -103,8 +104,6 @@ L.Renderer = L.Layer.extend({

this._center = this._map.getCenter();
this._zoom = this._map.getZoom();

this.fire('update');
}
});

Expand Down
2 changes: 2 additions & 0 deletions src/layer/vector/SVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ L.SVG = L.Renderer.extend({
// movement: update container viewBox so that we don't have to change coordinates of individual layers
L.DomUtil.setPosition(container, b.min);
container.setAttribute('viewBox', [b.min.x, b.min.y, size.x, size.y].join(' '));

this.fire('update');
},

// methods below are called by vector layers implementations
Expand Down

0 comments on commit c931d33

Please sign in to comment.