From ed3776204e52e23a42d1115a1aedd762397d0ec8 Mon Sep 17 00:00:00 2001 From: theo1 Date: Thu, 4 Feb 2021 21:41:02 +0100 Subject: [PATCH] Starting timer on first letter --- src/components/Screen.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Screen.vue b/src/components/Screen.vue index f69e5c8..fcb43e8 100644 --- a/src/components/Screen.vue +++ b/src/components/Screen.vue @@ -26,7 +26,7 @@ export default { activeIndex: 0, isWrong: false, timer: 60, - timerRunning: true, + timerRunning: false, typingSpeed: "" } }, @@ -34,7 +34,6 @@ export default { const result = await axios.get("https://random-word-api.herokuapp.com//word?number=" + this.number) this.words = result.data this.splitWords() - this.startTimer() }, methods: { isActive(index) { @@ -78,6 +77,7 @@ export default { }, startTimer() { // Launch countdown + this.timerRunning = true setInterval(() => { if(this.timerRunning) { this.timer -- } }, 1000) @@ -108,6 +108,12 @@ export default { this.setTypingSpeed() } }, + userText: function() { + // Start timer on first letter + if(!this.timerRunning && this.userText.length > 0) { + this.startTimer() + } + } } }