mirror of
https://github.com/GuerillaStudio/souvenir.git
synced 2024-11-08 10:11:52 +00:00
fix(timer): now wait for the correct duration
This commit is contained in:
parent
b416ec47f3
commit
6daaa915ae
3 changed files with 19 additions and 31 deletions
|
@ -25,48 +25,41 @@ class Countdown extends EventEmitter {
|
|||
if (!this._running && !this._started) {
|
||||
this._running = true
|
||||
this._started = true
|
||||
|
||||
this.emit('started')
|
||||
this._update()
|
||||
|
||||
this.emit('progress', 0)
|
||||
this.emit('update', this._n)
|
||||
this._intervalId = setInterval(() => {
|
||||
this._count++
|
||||
this._update()
|
||||
|
||||
this._intervalId = setInterval(() => this._update(), this._delay)
|
||||
if (this._count >= this._n) {
|
||||
this._cleanup()
|
||||
this.done = true
|
||||
this.emit('done')
|
||||
this._end()
|
||||
}
|
||||
}, this._delay)
|
||||
}
|
||||
}
|
||||
|
||||
cancel () {
|
||||
if (this._running && !this._ended) {
|
||||
this._cleanup()
|
||||
|
||||
this._cancelled = true
|
||||
this.emit('cancelled')
|
||||
|
||||
this.ended = true
|
||||
this.emit('ended')
|
||||
|
||||
this.running = false
|
||||
this._end()
|
||||
}
|
||||
}
|
||||
|
||||
_update () {
|
||||
if (this._running) {
|
||||
if (this._count < this._n) {
|
||||
this._count++
|
||||
this.emit('progress', this._count / this._n)
|
||||
this.emit('update', this._n - this._count)
|
||||
} else {
|
||||
this._cleanup()
|
||||
this.emit('progress', this._count / this._n)
|
||||
this.emit('update', this._n - this._count)
|
||||
}
|
||||
|
||||
this.done = true
|
||||
this.emit('done')
|
||||
|
||||
this.ended = true
|
||||
this.emit('ended')
|
||||
|
||||
this.running = false
|
||||
}
|
||||
}
|
||||
_end () {
|
||||
this.ended = true
|
||||
this.emit('ended')
|
||||
this._running = false
|
||||
}
|
||||
|
||||
_cleanup () {
|
||||
|
|
|
@ -31,7 +31,6 @@ export default new Vuex.Store({
|
|||
state.boomerang = value
|
||||
},
|
||||
updateTimer (state, value) {
|
||||
console.log(typeof value)
|
||||
state.timer = value
|
||||
},
|
||||
updateCamera (state, camera) {
|
||||
|
|
|
@ -104,10 +104,6 @@ export default {
|
|||
this.countdown = null
|
||||
})
|
||||
|
||||
this.countdown.on('cancelled', () => {
|
||||
console.log('cancelled')
|
||||
})
|
||||
|
||||
this.countdown.on('done', () => {
|
||||
this.runCapture()
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue