-
Notifications
You must be signed in to change notification settings - Fork 22.9k
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
Removing behaviors #894
Comments
Right, currently you’d need to remove the listeners yourself, which is a bit of a pain: selection
.on("mousedown.zoom", null)
.on("mousewheel.zoom", null)
.on("mousemove.zoom", null)
.on("DOMMouseScroll.zoom", null)
.on("dblclick.zoom", null)
.on("touchstart.zoom", null)
.on("touchmove.zoom", null)
.on("touchend.zoom", null); I think either we’d need a way to remove an entire namespace, say selection.on("*.zoom", null), or the behavior should expose a method for unbinding from a selection and do the same. |
|
Ah, sure, that sounds fine. Related #880. And if you say selection.on(".zoom", listener), it overwrites any current listener in the zoom namespace, but has no effect if there are no existing listeners with that namespace? |
Not sure if we need another way to unbind a behavior now that selection.on(".zoom", null) has been supported since #1140 in 3.1. |
Sorry to ask a possibly dumb question here, but what about the use-case where the user would like to clear all "on" functions that may (or may not) have been bound to any elements over the entire document/DOM, e.g. by some user-generated code? Since the external code might bind the "on" functions to tags like |
Removing all listeners in all namespaces is not supported at the moment, but would be simple enough to add. Removing all namespaced listeners for a particular event type is also not supported, e.g. |
This removes all listeners (namespaced or not) for all elements in a given selection. Related discussion in #894.
We can discuss further in #1855. |
While it's possible to specifically unbind a behavior's handlers, I'm not seeing any clear way to easily remove the behavior itself, in v2 or v3 - if you want an element to be draggable most of the time, but disable the drag handler later.
The text was updated successfully, but these errors were encountered: