Starting timer on first letter
This commit is contained in:
parent
996cee66a7
commit
ed3776204e
@ -26,7 +26,7 @@ export default {
|
|||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
isWrong: false,
|
isWrong: false,
|
||||||
timer: 60,
|
timer: 60,
|
||||||
timerRunning: true,
|
timerRunning: false,
|
||||||
typingSpeed: ""
|
typingSpeed: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -34,7 +34,6 @@ export default {
|
|||||||
const result = await axios.get("https://random-word-api.herokuapp.com//word?number=" + this.number)
|
const result = await axios.get("https://random-word-api.herokuapp.com//word?number=" + this.number)
|
||||||
this.words = result.data
|
this.words = result.data
|
||||||
this.splitWords()
|
this.splitWords()
|
||||||
this.startTimer()
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isActive(index) {
|
isActive(index) {
|
||||||
@ -78,6 +77,7 @@ export default {
|
|||||||
},
|
},
|
||||||
startTimer() {
|
startTimer() {
|
||||||
// Launch countdown
|
// Launch countdown
|
||||||
|
this.timerRunning = true
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if(this.timerRunning) { this.timer -- }
|
if(this.timerRunning) { this.timer -- }
|
||||||
}, 1000)
|
}, 1000)
|
||||||
@ -108,6 +108,12 @@ export default {
|
|||||||
this.setTypingSpeed()
|
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