Mercurial > hg > webaudioevaluationtool
changeset 2890:29c081e03e6b
Use requestAnimationFrame for timeline
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Tue, 27 Jun 2017 21:45:10 +0100 |
parents | cd1cd3358544 |
children | 22d1f6d9f0bf |
files | interfaces/timeline.js |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/interfaces/timeline.js Tue Jun 27 21:11:29 2017 +0100 +++ b/interfaces/timeline.js Tue Jun 27 21:45:10 2017 +0100 @@ -441,9 +441,15 @@ }; this.startPlayback = function () { // Called when playback has begun - canvasIntervalID = window.setInterval(this.canvas.drawTicker.bind(this.canvas), 100); + var animate = function () { + this.canvas.drawTicker.call(this.canvas); + if (this.playButton.DOM.textContent == "Stop") { + window.requestAnimationFrame(animate); + } + }.bind(this); this.playButton.DOM.textContent = "Stop"; interfaceContext.commentBoxes.highlightById(audioObject.id); + canvasIntervalID = window.requestAnimationFrame(animate); }; this.stopPlayback = function () { // Called when playback has stopped. This gets called even if playback never started!