don't render when hidden

This commit is contained in:
javi 2013-10-31 13:14:56 +01:00
parent f08fe5bc48
commit 79becc8ae1
2 changed files with 9 additions and 0 deletions

View File

@ -86,14 +86,18 @@ GMapsTorqueLayer.prototype = _.extend({},
}, },
hide: function() { hide: function() {
if(this.hidden) return this;
this.pause(); this.pause();
this.clear(); this.clear();
this.hidden = true; this.hidden = true;
return this;
}, },
show: function() { show: function() {
if(!this.hidden) return this;
this.hidden = false; this.hidden = false;
this.play(); this.play();
return this;
}, },
setSQL: function(sql) { setSQL: function(sql) {

View File

@ -71,14 +71,18 @@ L.TorqueLayer = L.CanvasLayer.extend({
}, },
hide: function() { hide: function() {
if(this.hidden) return this;
this.pause(); this.pause();
this.clear(); this.clear();
this.hidden = true; this.hidden = true;
return this;
}, },
show: function() { show: function() {
if(!this.hidden) return this;
this.hidden = false; this.hidden = false;
this.play(); this.play();
return this;
}, },
setSQL: function(sql) { setSQL: function(sql) {
@ -121,6 +125,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
* requestAnimationFrame. Use redraw to refresh it * requestAnimationFrame. Use redraw to refresh it
*/ */
render: function() { render: function() {
if(this.hidden) return;
var t, tile, pos; var t, tile, pos;
var canvas = this.getCanvas(); var canvas = this.getCanvas();
canvas.width = canvas.width; canvas.width = canvas.width;