-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
requestAnimationFrame addition to utils. #1107
Conversation
src/util.js
Outdated
window.mozRequestAnimationFrame || | ||
window.oRequestAnimationFrame || | ||
window.msRequestAnimationFrame || | ||
function (callback, element) {window.setTimeout(callback, 1000 / 60);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could you add spaces inside the anonymous function? And no need for window
, setTimeout
is a global also in Node.
src/util.js
Outdated
frame: function (func) { | ||
return function () { | ||
var my = this, args = arguments; | ||
requestAnimationFrame(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, it should be WaveSurfer.util.requestAnimationFrame
defined above?
ping @agamemnus |
Oh sorry. Yes. Fixed. |
src/util.js
Outdated
return function () { | ||
var my = this, args = arguments; | ||
WaveSurfer.util.requestAnimationFrame(function () { | ||
func.apply (my, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the space after apply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for semicolons either... or brackets around a return statement. :P
Merged, thanks much! |
There is a problem that I just realized. Now anything using this becomes asynchronous, so anything using it actually needs a callback, etc. |
You can't do drawWave anymore, or whatever. you have to add a callback parameter, because the function will run asynchronously -- on the next animation frame. There are several dozen lines of code that need to be reworked. It is all interwoven... check out drawPeaks, for example... https://github.com/agamemnus/wavesurfer.js/blob/master/dist/wavesurfer.js |
(But then everything behind that needs callbacks too. So you have a callback pattern for drawPeaks (where I put the frame() call, and then callback pattern for drawBuffer. And then, although I didn't implement it, you need a callback for everything that calls drawBuffer. |
@katspaugh SOS |
A pr that reverts your changes might be necessary then. |
Or just add the callback methods. But maybe for next because this will
break outside code that expects an instant change.
…On Jun 20, 2017 9:32 AM, "Thijs Triemstra" ***@***.***> wrote:
A pr that reverts your changes might be necessary then.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1107 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADFJWGw_NOKYoipZSKPY523ZBuGI14qHks5sF8oFgaJpZM4Noajw>
.
|
* requestAnimationFrame addition to utils. * Update util.js * Update util.js * Update util.js * Update util.js * Update util.js
* requestAnimationFrame addition to utils. * Update util.js * Update util.js * Update util.js * Update util.js * Update util.js
Sorry -- idk how to add to a PR.