Skip to content
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

Merged
merged 6 commits into from
May 31, 2017
Merged

requestAnimationFrame addition to utils. #1107

merged 6 commits into from
May 31, 2017

Conversation

agamemnus
Copy link
Contributor

Sorry -- idk how to add to a PR.

src/util.js Outdated
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback, element) {window.setTimeout(callback, 1000 / 60);}
Copy link
Owner

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 () {
Copy link
Owner

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?

@thijstriemstra
Copy link
Contributor

ping @agamemnus

@agamemnus
Copy link
Contributor Author

Oh sorry. Yes. Fixed.

src/util.js Outdated
return function () {
var my = this, args = arguments;
WaveSurfer.util.requestAnimationFrame(function () {
func.apply (my, args);
Copy link
Owner

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

Copy link
Contributor Author

@agamemnus agamemnus May 31, 2017

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

@katspaugh katspaugh merged commit 0552da8 into katspaugh:master May 31, 2017
@katspaugh
Copy link
Owner

Merged, thanks much!

@agamemnus
Copy link
Contributor Author

agamemnus commented Jun 18, 2017

There is a problem that I just realized. Now anything using this becomes asynchronous, so anything using it actually needs a callback, etc.

@agamemnus
Copy link
Contributor Author

@thijstriemstra

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

@agamemnus
Copy link
Contributor Author

(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.

@agamemnus
Copy link
Contributor Author

@katspaugh SOS

@thijstriemstra
Copy link
Contributor

A pr that reverts your changes might be necessary then.

@agamemnus
Copy link
Contributor Author

agamemnus commented Jun 20, 2017 via email

mspae pushed a commit to mspae/wavesurfer.js that referenced this pull request Aug 18, 2017
* requestAnimationFrame addition to utils.

* Update util.js

* Update util.js

* Update util.js

* Update util.js

* Update util.js
mspae pushed a commit that referenced this pull request Aug 19, 2017
* requestAnimationFrame addition to utils.

* Update util.js

* Update util.js

* Update util.js

* Update util.js

* Update util.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants