BUGFIX: clear interval on exit

This commit is contained in:
Jeroen De Meerleer 2021-05-05 13:39:13 +02:00
parent 6f1a98f65a
commit 9514e4b9fb

View File

@ -66,7 +66,6 @@
</template>
<script>
var Interval;
export default {
name: "Timer",
props: {
@ -79,6 +78,7 @@ export default {
warning: true,
danger: false,
wakeLock: null,
interval: null,
sfxTimeout: this.playsound ? new Audio('sfx/timeout.wav') : null,
sfxWarning: this.playsound ? new Audio('sfx/warning.wav') : null,
sfxNext: this.playsound ? new Audio('sfx/next.wav') : null,
@ -86,6 +86,7 @@ export default {
},
methods: {
resetTime: function() {
clearInterval(this.interval);
this.$emit('set-time', 0);
},
timeleft: function(){
@ -128,7 +129,7 @@ export default {
if(this.playsound) {
this.sfxTimeout.play();
}
clearInterval(Interval);
clearInterval(this.interval);
break;
}
},
@ -142,8 +143,8 @@ export default {
this.countDown = this.time;
this.warning = false;
this.danger = false;
clearInterval(Interval);
Interval = setInterval(() => {
clearInterval(this.interval);
this.interval = setInterval(() => {
this.timeleft()
}, 1000);
},