mirror of
https://github.com/LucasVbr/own-workspace.git
synced 2026-05-13 17:21:58 +00:00
hotfix timer lagging
This commit is contained in:
@@ -144,7 +144,13 @@ export default {
|
|||||||
this.changeDots();
|
this.changeDots();
|
||||||
}
|
}
|
||||||
} else {
|
} 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.minutes = parseInt(this.minutes);
|
||||||
this.seconds = parseInt(this.seconds);
|
this.seconds = parseInt(this.seconds);
|
||||||
if (this.seconds === 0) {
|
if (this.seconds === 0) {
|
||||||
@@ -155,9 +161,11 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.seconds -= 1;
|
this.seconds -= 1;
|
||||||
}
|
}
|
||||||
this.prettyTime()
|
this.prettyTime();
|
||||||
this.countDownTimer()
|
expected += interval;
|
||||||
}, 1000)
|
this.timeout = setTimeout(stepFunc, Math.max(0, interval - dt));
|
||||||
|
}
|
||||||
|
this.timeout = setTimeout(stepFunc, interval)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeDots() {
|
changeDots() {
|
||||||
|
|||||||
Reference in New Issue
Block a user