fix stats slice bug, closes #67
This commit is contained in:
parent
e10e2412c4
commit
e42dd6e144
2 changed files with 14 additions and 3 deletions
|
@ -1326,6 +1326,17 @@ export class GPXStatistics {
|
||||||
}
|
}
|
||||||
|
|
||||||
slice(start: number, end: number): GPXStatistics {
|
slice(start: number, end: number): GPXStatistics {
|
||||||
|
if (start < 0) {
|
||||||
|
start = 0;
|
||||||
|
} else if (start >= this.local.points.length) {
|
||||||
|
return new GPXStatistics();
|
||||||
|
}
|
||||||
|
if (end < start) {
|
||||||
|
return new GPXStatistics();
|
||||||
|
} else if (end >= this.local.points.length) {
|
||||||
|
end = this.local.points.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
let statistics = new GPXStatistics();
|
let statistics = new GPXStatistics();
|
||||||
|
|
||||||
statistics.local.points = this.local.points.slice(start, end + 1);
|
statistics.local.points = this.local.points.slice(start, end + 1);
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
$selection.hasAnyChildren(new ListRootItem(), true, ['waypoints']) &&
|
$selection.hasAnyChildren(new ListRootItem(), true, ['waypoints']) &&
|
||||||
$gpxStatistics.local.points.length > 0;
|
$gpxStatistics.local.points.length > 0;
|
||||||
|
|
||||||
let maxSliderValue = 100;
|
let maxSliderValue = 1;
|
||||||
let sliderValues = [0, 100];
|
let sliderValues = [0, 1];
|
||||||
|
|
||||||
function updateCanCrop() {
|
function updateCanCrop() {
|
||||||
canCrop = sliderValues[0] != 0 || sliderValues[1] != maxSliderValue;
|
canCrop = sliderValues[0] != 0 || sliderValues[1] != maxSliderValue;
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
if (validSelection && $gpxStatistics.local.points.length > 0) {
|
if (validSelection && $gpxStatistics.local.points.length > 0) {
|
||||||
maxSliderValue = $gpxStatistics.local.points.length - 1;
|
maxSliderValue = $gpxStatistics.local.points.length - 1;
|
||||||
} else {
|
} else {
|
||||||
maxSliderValue = 100;
|
maxSliderValue = 1;
|
||||||
}
|
}
|
||||||
await tick();
|
await tick();
|
||||||
sliderValues = [0, maxSliderValue];
|
sliderValues = [0, maxSliderValue];
|
||||||
|
|
Loading…
Reference in a new issue