Don't update TrackAnalysis when tab is hidden

- add missing show/hide methods called by sidebar and maintain active state
- rename inconsistent tab id
This commit is contained in:
Norbert Renner 2020-06-30 21:35:51 +02:00
parent 5ad12a7c68
commit 4892c2a1db
2 changed files with 28 additions and 2 deletions

View file

@ -50,6 +50,28 @@ BR.TrackAnalysis = L.Class.extend({
*/
trackPolyline: null,
/**
* true when tab is shown, false when hidden
*
* @type {boolean}
*/
active: false,
/**
* Called by BR.Sidebar when tab is activated
*/
show: function() {
this.active = true;
this.options.requestUpdate(this);
},
/**
* Called by BR.Sidebar when tab is deactivated
*/
hide: function() {
this.active = false;
},
/**
* Everytime the track changes this method is called:
*
@ -63,6 +85,10 @@ BR.TrackAnalysis = L.Class.extend({
* @param {Array} segments
*/
update: function(polyline, segments) {
if (!this.active) {
return;
}
if (segments.length === 0) {
$('#track_statistics').html('');
return;