hotfix timer lagging

This commit is contained in:
RemiSaurel
2022-08-24 09:04:28 +02:00
parent 1e16a20543
commit f6f958566e
+12 -4
View File
@@ -144,7 +144,13 @@ export default {
this.changeDots();
}
} else {
this.timeout = setTimeout(() => {
const interval = 1000; // ms
let expected = Date.now() + interval;
let stepFunc = () => {
let dt = Date.now() - expected;
if (dt > interval) {
// handle error?
}
this.minutes = parseInt(this.minutes);
this.seconds = parseInt(this.seconds);
if (this.seconds === 0) {
@@ -155,9 +161,11 @@ export default {
} else {
this.seconds -= 1;
}
this.prettyTime()
this.countDownTimer()
}, 1000)
this.prettyTime();
expected += interval;
this.timeout = setTimeout(stepFunc, Math.max(0, interval - dt));
}
this.timeout = setTimeout(stepFunc, interval)
}
},
changeDots() {