handle timer < 0

This commit is contained in:
cv
2021-04-10 21:12:27 +02:00
parent c71c39b151
commit e51f3e6cd5
+6 -1
View File
@@ -12,6 +12,7 @@ class Timer {
_pausedInterval = null; _pausedInterval = null;
_pausedTotal = null; _pausedTotal = null;
state = 'pause'; state = 'pause';
showNegative = false;
constructor() {} constructor() {}
@@ -45,7 +46,11 @@ class Timer {
switch (this.state) { switch (this.state) {
case 'start': case 'start':
// update current timer // update current timer
this._current = this._finishAt + this._pausedTotal - now; if (!this.showNegative) {
this._current = Math.max(this._finishAt + this._pausedTotal - now, 0);
} else {
(this._current = this._finishAt + this._pausedTotal - now), 0;
}
break; break;
case 'pause': case 'pause':
// update paused time // update paused time