Skip to content

Commit 6c2c08d

Browse files
committed
fix: make restart and reset pause before start
1 parent 883f52d commit 6c2c08d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/useStopwatch.ts

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const useStopwatch = (
5353
}
5454

5555
function reset(offset = 0, newAutoStart = true) {
56+
pause()
5657
isRunning.value = newAutoStart
5758
passedSeconds.value = Time.getSecondsFromExpiry(offset, true).value || 0
5859
start()

src/useTimer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const useTimer = (expiry = 60, autoStart = true): UseTimer => {
5353
}
5454

5555
function restart(newExpiryTimestamp: number = expiry, newAutoStart = true) {
56+
pause()
5657
state.delay = getDelayFromExpiryTimestamp(newExpiryTimestamp)
5758
state.didStart = newAutoStart
5859
state.isExpired = false

0 commit comments

Comments
 (0)