fixes problem with leaks on map move
This commit is contained in:
parent
fc09a86e51
commit
2d22276bfd
@ -31,11 +31,13 @@ L.CanvasLayer = L.Class.extend({
|
|||||||
// backCanvas for zoom animation
|
// backCanvas for zoom animation
|
||||||
this._backCanvas = this._createCanvas();
|
this._backCanvas = this._createCanvas();
|
||||||
this._ctx = this._canvas.getContext('2d');
|
this._ctx = this._canvas.getContext('2d');
|
||||||
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
this.currentAnimationFrame = -1;
|
||||||
|
this.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
|
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
|
||||||
return window.setTimeout(callback, 1000 / 60);
|
return window.setTimeout(callback, 1000 / 60);
|
||||||
};
|
};
|
||||||
this.requestAnimationFrame = requestAnimationFrame;
|
this.cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame ||
|
||||||
|
window.webkitCancelAnimationFrame || window.msCancelAnimationFrame || function(id) { clearTimeout(id); };
|
||||||
},
|
},
|
||||||
|
|
||||||
_createCanvas: function() {
|
_createCanvas: function() {
|
||||||
@ -189,7 +191,10 @@ L.CanvasLayer = L.Class.extend({
|
|||||||
_updateOpacity: function () { },
|
_updateOpacity: function () { },
|
||||||
|
|
||||||
_render: function() {
|
_render: function() {
|
||||||
this.requestAnimationFrame.call(window, this.render);
|
if (this.currentAnimationFrame >= 0) {
|
||||||
|
this.cancelAnimationFrame.call(window, this.currentAnimationFrame);
|
||||||
|
}
|
||||||
|
this.currentAnimationFrame = this.requestAnimationFrame.call(window, this.render);
|
||||||
},
|
},
|
||||||
|
|
||||||
// use direct: true if you are inside an animation frame call
|
// use direct: true if you are inside an animation frame call
|
||||||
|
Loading…
Reference in New Issue
Block a user