Improve hiding elevation chart when empty

Consider additional cases:
- flag got reset when deleting and adding first waypoint
- don't show empty on load, postpone to update
- don't store state when hidden because empty
This commit is contained in:
Norbert Renner 2020-07-10 12:29:15 +02:00 committed by Gautier P
parent b701a6f298
commit 2df1f617c9
2 changed files with 11 additions and 6 deletions

View file

@ -3,15 +3,11 @@ BR.TrackStats = L.Class.extend({
if (segments.length == 0) {
$('#stats-container').hide();
$('#stats-info').show();
this.shouldRestoreChart = $('#elevation-chart').hasClass('show');
$('#elevation-chart').collapse('hide');
return;
}
$('#stats-container').show();
$('#stats-info').hide();
if (this.shouldRestoreChart === true) $('#elevation-chart').collapse('show');
this.shouldRestoreChart = undefined;
var stats = this.calcStats(polyline, segments),
length1 = L.Util.formatNum(stats.trackLength / 1000, 1).toLocaleString(),