d3 / d3-drag

Drag and drop SVG, HTML or Canvas using mouse or touch input.

Home Page:https://d3js.org/d3-drag

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remove drag.container?

Fil opened this issue · comments

drag.container was introduced by 8277204 to solve #2, but it doesn't seem necessary for the case mentioned in the issue. In fact I couldn't find an example where it is used directly, and I'm a bit at a loss to create one where it might be useful.

Since event.x and y are computed as relative values (p[0] - initial p[0] + initial x), it does not seem to matter which container we choose. (Except when the container itself is moving during the gesture (!), but that's probably not a common case and would be handled by calling d3.mouse(container) or d3.pointer(event[, node]), for, I guess, a similar effect.)

Addendum: the only impact seems to be on determining the subject, which can certainly be done with the d3.pointer(event[, node]) method instead.

Here's an example "in the wild" where drag.container is used, but it can be removed with no ill effect.