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

Remove event by fn, checks && id #767

Closed
agmcleod opened this issue May 15, 2017 · 1 comment
Closed

Remove event by fn, checks && id #767

agmcleod opened this issue May 15, 2017 · 1 comment

Comments

@agmcleod
Copy link

if (fn === events[i].fn && id === events[i].id) {

Was having a look over the code to see if I can remove an event just by ID, and I think I see an issue here. Given that it lists id as optional, but checks it against the event, as well as the function, I don't think one can remove an event by using the function parameter at all.

A simple fix here would be to swap it to an ||. Or one can change it to:

if (fn === events[i].fn && (!id || id === events[i].id))

To cover what the API says it will do :)

@goldfire
Copy link
Owner

This is partially intended behavior. If you passed an ID into on, then you need to pass an ID into off because if you don't pass ID into on it is a different type of listener. However, I just pushed a commit that allows you to cancel like sound.off('play', id); instead of having to pass the function as well.

ringcrl pushed a commit to ringcrl/howler.js that referenced this issue Apr 21, 2019
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

No branches or pull requests

2 participants