visualizer: ensure canvas loop is running when starting its own loop

This commit is contained in:
bordun 2020-04-16 18:44:31 +02:00
parent 8229526b16
commit b11e3d0d20
2 changed files with 9 additions and 4 deletions

View file

@ -19,11 +19,15 @@ class CanvasQueue extends EventEmitter{
this.queue[widget.hash] = widget
this.flushed = 0
if (!this.running) this.startLoop()
if (!this.running) {
this.running = true
requestAnimationFrame(this.bindedLoop)
}
}
startLoop() {
this.running = true
this.flushed = 0
requestAnimationFrame(this.bindedLoop)
}

View file

@ -53,6 +53,7 @@ module.exports = class Visualizer extends StaticProperties(Plot, {rangeX: {min:
if (!this.looping) {
this.lastUpdate = Date.now()
canvasQueue.on('frame', this.bindedLoop)
if (!canvasQueue.running) canvasQueue.startLoop()
this.looping = true
this.ticks = 0
}