diff --git a/src/components/timer.vue b/src/components/timer.vue index 20e6014..e8c2be2 100644 --- a/src/components/timer.vue +++ b/src/components/timer.vue @@ -11,7 +11,8 @@ categories:[], running: false, startTime:0, - savedPreviousSeconds:0 + savedPreviousSeconds:0, + totalSeconds:0 } }, methods: { @@ -25,13 +26,18 @@ start(event){ this.startTime = Date.now(); this.running = true; + this.intervalID = setInterval(()=>{ + this.totalSeconds = getAccumulatedSeconds(Date.now(), this.startTime) + this.savedPreviousSeconds; + }, 1000); }, stop(event){ this.running = false; this.savedPreviousSeconds += getAccumulatedSeconds(Date.now(), this.startTime); + clearInterval(this.intervalID); }, reset(event){ this.savedPreviousSeconds = 0; + this.totalSeconds = 0; } }, mounted() { @@ -47,13 +53,13 @@

Timer

- +
- +