Starting timer on first letter

This commit is contained in:
theo1 2021-02-04 21:41:02 +01:00
parent 996cee66a7
commit ed3776204e

View File

@ -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()
}
}
}
}