1
0
Fork 0

pace: fix distance totalling

master
Rob Pilling 2024-10-10 20:31:17 +01:00
parent fa0a6f2ab8
commit 625f065834
1 changed files with 8 additions and 4 deletions

View File

@ -172,11 +172,15 @@ const onButton = () => {
exs.start(); // aka reset
exs.stats.dist.on("notify", (dist) => {
const prevDist = splits[splits.length - 1]?.dist ?? 0;
const prev = { time: 0, dist: 0 };
for(const s of splits){
prev.time += s.time;
prev.dist += s.dist;
}
const totalDist = dist.getValue();
let thisSplit = totalDist - prevDist;
const prevTime = splits.reduce((t, s) => t + s.time, 0);
let thisTime = exs.state.duration - prevTime;
let thisSplit = totalDist - prev.dist;
let thisTime = exs.state.duration - prev.time;
while(thisSplit > 1000) {
splits.push({ dist: thisSplit as Dist, time: thisTime as Time });