Skip to content

Commit

Permalink
Merge pull request Leaflet#3950 from klaftertief/fix-canvas-zoom_spli…
Browse files Browse the repository at this point in the history
…t-events

Alternative fix for Leaflet#3947
  • Loading branch information
IvanSanchez committed Oct 20, 2015
2 parents 2a5857d + 3e0067f commit f6e9f90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/layer/vector/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ L.Renderer = L.Layer.extend({
getEvents: function () {
var events = {
viewreset: this._reset,
zoomstart: this._onZoomStart,
zoom: this._onZoom,
moveend: this._update
};
Expand All @@ -54,13 +53,6 @@ L.Renderer = L.Layer.extend({
this._updateTransform(this._map.getCenter(), this._map.getZoom());
},

_onZoomStart: function () {
// Drag-then-pinch interactions might mess up the center and zoom.
// In this case, the easiest way to prevent this is re-do the renderer
// bounds and padding when the zooming starts.
this._update();
},

_updateTransform: function (center, zoom) {
var scale = this._map.getZoomScale(zoom, this._zoom),
position = L.DomUtil.getPosition(this._container),
Expand Down
13 changes: 13 additions & 0 deletions src/layer/vector/SVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

L.SVG = L.Renderer.extend({

getEvents: function () {
var events = L.Renderer.prototype.getEvents.call(this);
events.zoomstart = this._onZoomStart;
return events;
},

_initContainer: function () {
this._container = L.SVG.create('svg');

Expand All @@ -14,6 +20,13 @@ L.SVG = L.Renderer.extend({
this._container.appendChild(this._rootGroup);
},

_onZoomStart: function () {
// Drag-then-pinch interactions might mess up the center and zoom.
// In this case, the easiest way to prevent this is re-do the renderer
// bounds and padding when the zooming starts.
this._update();
},

_update: function () {
if (this._map._animatingZoom && this._bounds) { return; }

Expand Down

0 comments on commit f6e9f90

Please sign in to comment.