-
Notifications
You must be signed in to change notification settings - Fork 785
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
Unbinding specific events not working #149
Comments
Thanks for raising this issue. I've released a new version which fixes it. |
Thanks for your quick response. Something's still wrong, though. Removing an action event listener is still not working. interact(el)
.dropzone(true)
.on('drop',function(){
alert('drop');
});
interact(el)
.dropzone(false)
.off('drop',function(){
alert('drop');
}); Logging this._iEvents in :4802 shows that the event listener has been successfully removed, but it will still be called. |
That's because those functions are two different objects. If you do add and remove the events like this instead, then it should work: function dropListener (event){
alert('drop');
}
interact(el)
.dropzone(true)
.on('drop', dropListener);
interact(el)
.dropzone(false)
.off('drop', dropListener); |
Sorry, that's how I'm using it. I just got it wrong in the example. Logging out this._iEvents clearly shows that the listener has been removed, however it'll be fired again somehow after removal. |
Maybe you added the event by including it in the dropzone options. interact(el).dropzone({
ondrop: dropListener
}); In that case, you would have to do: interact(el).ondrop = null; |
I haven't used it that way, but I tried your suggestion and it worked fine. Thanks very much for your help! |
You're welcome :) |
First of all, thanks for all your handwork on interact.js. It's a great library to work with.
Today I've noticed that unbinding events isn't working. When I call .off('drop') on an interactable, the event listener will still be active. I've tried to debug it and found that events.remove() (in line 413) expects an element as opposed to an interactable (which .off() passes through), hence it'll bail out in line 421 as 'target' will be undefined.
The text was updated successfully, but these errors were encountered: