From 7059f27d6a05f83a8083f9c62ae1a583aa12cc79 Mon Sep 17 00:00:00 2001 From: danzel Date: Wed, 29 Aug 2012 10:15:40 +1200 Subject: [PATCH 1/2] Optimize _requestUpdate in Path.Canvas. Don't repeatedly request and cancel animation frames (previous code wasn't actually canceling the requests anyway!). --- src/layer/vector/canvas/Path.Canvas.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/layer/vector/canvas/Path.Canvas.js b/src/layer/vector/canvas/Path.Canvas.js index c8131911..4b8b8c96 100644 --- a/src/layer/vector/canvas/Path.Canvas.js +++ b/src/layer/vector/canvas/Path.Canvas.js @@ -10,7 +10,9 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : statics: { //CLIP_PADDING: 0.02, // not sure if there's a need to set it to a small value CANVAS: true, - SVG: false + SVG: false, + + _updateRequest: null }, redraw: function () { @@ -42,13 +44,14 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : }, _requestUpdate: function () { - if (this._map) { - L.Util.cancelAnimFrame(this._fireMapMoveEnd); - this._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map); + if (this._map && L.Path._updateRequest === null) { + L.Path._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map); + console.log('requested ' + L.Path._updateRequest); } }, _fireMapMoveEnd: function () { + L.Path._updateRequest = null; this.fire('moveend'); }, From fcddcd065fc6072ee27f726d43d645bf6eca2263 Mon Sep 17 00:00:00 2001 From: danzel Date: Mon, 3 Sep 2012 10:50:42 +1200 Subject: [PATCH 2/2] Fix up issues reported by mourner https://github.com/CloudMade/Leaflet/pull/961/files#r1508267 --- src/layer/vector/canvas/Path.Canvas.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/layer/vector/canvas/Path.Canvas.js b/src/layer/vector/canvas/Path.Canvas.js index 4b8b8c96..3a8f0182 100644 --- a/src/layer/vector/canvas/Path.Canvas.js +++ b/src/layer/vector/canvas/Path.Canvas.js @@ -10,9 +10,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : statics: { //CLIP_PADDING: 0.02, // not sure if there's a need to set it to a small value CANVAS: true, - SVG: false, - - _updateRequest: null + SVG: false }, redraw: function () { @@ -44,9 +42,8 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : }, _requestUpdate: function () { - if (this._map && L.Path._updateRequest === null) { + if (this._map && !L.Path._updateRequest) { L.Path._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map); - console.log('requested ' + L.Path._updateRequest); } },