Skip to content

Commit 25986d6

Browse files
committed
bugfix
1 parent 4c400ad commit 25986d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/Stopwatch.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,19 @@ class Stopwatch {
9595

9696
stopTimer() {
9797
if (this.state != Stopwatch.states.STOPPED) {
98-
this.state = Stopwatch.states.STOPPED;
9998
clearInterval(this.intervalTimer);
10099
clearInterval(this.pauseTimerInterval);
101-
const time = this.calculateTime();
100+
this.totalPausedTime += this.currentPausedTime;
101+
102+
const time = this.state == Stopwatch.states.PAUSED ? this.timeUi.textContent : this.calculateTime();
102103
this.lastTimeUi.textContent = `Last time: ${time}`;
104+
103105
this.totalPausedTime = this.currentPausedTime = 0;
104106
this.pausedTimeStart = 0;
107+
105108
this.timeUi.textContent = '00:00:00';
106109

110+
this.state = Stopwatch.states.STOPPED;
107111
this.historyResults.push(time);
108112
this.fillArchiveUi();
109113
}

0 commit comments

Comments
 (0)