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:
parent
5ad12a7c68
commit
4892c2a1db
2 changed files with 28 additions and 2 deletions
|
|
@ -791,7 +791,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#tab_statistics"
|
||||
href="#tab_analysis"
|
||||
role="tab"
|
||||
data-i18n="[title]sidebar.tab-tooltip"
|
||||
data-i18n-options='{
|
||||
|
|
@ -995,7 +995,7 @@
|
|||
<div id="itinerary" class="flexcolumn flexgrow"></div>
|
||||
</div>
|
||||
|
||||
<div class="leaflet-sidebar-pane" id="tab_statistics">
|
||||
<div class="leaflet-sidebar-pane" id="tab_analysis">
|
||||
<h1 class="leaflet-sidebar-header">
|
||||
<span data-i18n="sidebar.analysis.title">Analysis</span>
|
||||
<span class="leaflet-sidebar-close"><i class="fa fa-caret-right"></i></span>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue