pause on zoom

This commit is contained in:
javi 2014-03-21 15:56:38 +01:00
parent 462fea3fd1
commit c7a5799881

View File

@ -88,7 +88,12 @@ L.TorqueLayer = L.CanvasLayer.extend({
onAdd: function (map) {
map.on({
'zoomend': this._clearCaches
'zoomend': this._clearCaches,
'zoomstart': this._pauseOnZoom,
}, this);
map.on({
'zoomend': this._resumeOnZoom
}, this);
L.CanvasLayer.prototype.onAdd.call(this, map);
},
@ -96,11 +101,28 @@ L.TorqueLayer = L.CanvasLayer.extend({
onRemove: function(map) {
this._removeTileLoader();
map.off({
'zoomend': this._clearCaches
'zoomend': this._clearCaches,
'zoomstart': this._pauseOnZoom,
}, this);
map.off({
'zoomend': this._resumeOnZoom
}, this);
L.CanvasLayer.prototype.onRemove.call(this, map);
},
_pauseOnZoom: function() {
this.wasRunning = this.isRunning();
if (this.wasRunning) {
this.pause();
}
},
_resumeOnZoom: function() {
if (this.wasRunning) {
this.play();
}
},
hide: function() {
if(this.hidden) return this;
this.pause();