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

Mouseup event #133

Closed
wants to merge 4 commits into from
Closed

Mouseup event #133

wants to merge 4 commits into from

Conversation

mwise
Copy link
Contributor

@mwise mwise commented Mar 8, 2014

This PR adds event bubbling for the 'mouseup' event so that external objects (including plugins) can listen for the 'mouseup' event that is triggered by wavesurfer. NOTE: This PR includes #132 and should only be merged if that PR is going to be merged.

@katspaugh - I noticed that when you refactored the drag events, you used document.addEventListener when registering the mouseup callback. What was your motivation for this? In order to properly bubble up a wavesurfer-only mouseup event, I had to add an additional listener for mouseup on the wavesurfer wrapper itself. I imagine there was some consideration that went into the decision to listen for that even on the document, but I couldn't deduce it from the code. Hence the additional listener, which shouldn't have any performance or other impact.

The main benefit of having this event (for our purposes, at least) is to listen for when a user has finished selecting a new region of the waveform.

Cheers,

Mark

Conflicts:
	build/wavesurfer-js-map.json
	build/wavesurfer.amd.js
	build/wavesurfer.min.js
Conflicts:
	build/wavesurfer-js-map.json
	build/wavesurfer.amd.js
	build/wavesurfer.min.js
@katspaugh
Copy link
Owner

The motivation for binding mouseup to the document element is to ensure that when you release the mouse button (anywhere on the page), the drag is over. If you only listen on the waveform container element, and user releases the button elsewhere on the page, we would be thinking the drag is still on.

So I would add an event called drag-end and trigger it from the document.onmouseup handler iff drag.startPercentage is not null (i.e. the user clicked on the waveform before that).

@katspaugh
Copy link
Owner

@mwise I've added the mouseup event in 413a174. Just copied your code, since the PR is out of date. Sorry for the delay.

@katspaugh katspaugh closed this Apr 19, 2014
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.

2 participants