From 4958a2c7dc586a313c5cda8af2c748d133d37037 Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sat, 7 Jan 2023 12:03:55 +0000 Subject: [PATCH] tweak timer --- frontend/src/components/Chooser.vue | 25 ++++++++++++++++--------- frontend/src/components/Player.vue | 8 ++++---- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/Chooser.vue b/frontend/src/components/Chooser.vue index 22fe758..785144c 100644 --- a/frontend/src/components/Chooser.vue +++ b/frontend/src/components/Chooser.vue @@ -3,12 +3,12 @@

{{text}}

- +
-

{{remainingTime}}

{{hintText}}

-
{{realCancelText}}
+

{{remainingTime}}

+
{{realCancelText}} ({{remainingTime}})

{{desc}}

@@ -72,7 +72,15 @@ export default { this.select(this.cards[0]); window.clearInterval(this.intervalID); } - } + }, + internalCancel() { + if (this.intervalID) window.clearInterval(this.intervalID); + this.cancel(); + }, + internalSelect(card) { + if (this.intervalID) window.clearInterval(this.intervalID); + this.select(card); + }, }, mounted() { this.realCancelText = this.cancelText @@ -85,11 +93,10 @@ export default { if (this.playAudio) { (new Audio(show_sfx)).play(); } - if (this.timer > 0) { - this.remainingTime = this.timer; - this.intervalID = window.setInterval(() => { - this.countDown(); - }, 1000); + this.remainingTime = this.timer; + if (this.timer != 0 && this.remainingTime == this.timer) { + if (this.intervalID) window.clearInterval(this.intervalID); + this.intervalID = window.setInterval(this.countDown, 1000); } }, } diff --git a/frontend/src/components/Player.vue b/frontend/src/components/Player.vue index f29f459..39bdfdb 100644 --- a/frontend/src/components/Player.vue +++ b/frontend/src/components/Player.vue @@ -50,15 +50,15 @@ - - + + - + - +