-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
create debounce method in util.js #964
Conversation
Can be used as follows with a resize event to prevent drawBuffer() from running concurrently when resizing the browser window. preview: http://codepen.io/entonbiba/pen/jyKrEz var responsiveWave = debounce(function() { wavesurfer.empty(); wavesurfer.drawBuffer(); }, 150); window.addEventListener(‘resize’, responsiveWave);
Hey awesome! Maybe you might want to checkout the next branch (thats where my previous PR was directed) - as far as I'm concerned we can do the same for master for this feature though. |
I'm a bit reluctant to add code that is not used inside wavesurfer.js itself, or inside any plugins. Why can't the app authors define or import the debounce function themselves? |
The original idea came up in the context of this PR #963 (responsive option) I would like to add debounce to the next version to enable debouncing of event listeners which are called constantly (mostly I have also though about how this could be kept seperate from the wavesurfer lib so we don't have to maintain it. But apart from providing a debounce parameter where the function can be specified I couldn't think of a good way of doing it. – and IMHO that would be even more complicated than just exposing the well-tested debounce package. (documenting, answering questions, maintaining extra code for parameter checking etc.) Note that this is my opinion regarding the next branch/version. |
OK, if it's going to be used in the code, let's add it. Thanks, @entonbiba! |
I've published version 1.3.1 on npm. Also, @entonbiba I've invited you as a collaborator, I hope you don't mind. |
@katspaugh thanks! Yes, I'm going to update a couple of the plugins to include the debounce feature on the windows resize event. This feature also comes in handy when having more than one wavesurfer initialized on the page and in case the user keeps resizing the window. |
Can be used with a resize event to prevent drawBuffer() from running concurrently when resizing the browser window. @mspae @thijstriemstra #963
preview:
http://codepen.io/entonbiba/pen/jyKrEz