Starting timer on first letter
This commit is contained in:
parent
996cee66a7
commit
ed3776204e
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user