Mercurial > hg > webaudioevaluationtool
changeset 2817:6b38dc641812
Using animation callback for playhead
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 28 Apr 2017 11:32:28 +0100 |
parents | 7f2bb5997114 |
children | c241f0aee8a4 98610ac90893 |
files | js/core.js |
diffstat | 1 files changed, 5 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/js/core.js Tue Apr 25 15:31:02 2017 +0100 +++ b/js/core.js Fri Apr 28 11:32:28 2017 +0100 @@ -2903,32 +2903,20 @@ } } } + if (this.playbackObject !== undefined && this.interval === undefined) { + window.requestAnimationFrame(this.update.bind(this)); + } }; playhead.interval = undefined; playhead.start = function () { if (this.playbackObject !== undefined && this.interval === undefined) { - if (this.maxTime < 60) { - this.interval = window.setInterval(function () { - interfaceContext.playhead.update(); - }, 10); - } else { - this.interval = window.setInterval(function () { - interfaceContext.playhead.update(); - }, 100); - } + window.requestAnimationFrame(this.update.bind(this)); } }; playhead.stop = function () { - window.clearInterval(this.interval); - this.interval = undefined; - this.scrubberHead.style.left = '0px'; - if (this.maxTime < 60) { - this.curTimeSpan.textContent = '0.00'; - } else { - this.curTimeSpan.textContent = '00:00'; - } + this.timePerPixel = 0; }; return playhead; })();