Expose dx and dy on the DragEvent.
altocumulus opened this issue · 2 comments
In v3 the drag event exposed the properties dx
and dy
"representing the element’s coordinates relative to its position at the beginning of the gesture", which on many occasions came in handy. As far as I can tell, these are no longer available in v4, and they are missed already. Is there a chance, we could have them back?
Hmm. That documentation is actually incorrect; event.dx and event.dy represent the change in coordinates relative to the previous drag (or start) event, not the start of the drag gesture. (See this example, which shows how event.dx and event.dy are used to increment the x and y attributes of a rect on each drag event.)
But, incorrect documentation aside, it wouldn’t be hard to also expose the change in position since the previous event. So, okay.
Thank you, very helpful! This paved the way for my approach to "Attaching drag behaviour without using data().enter() in D3 v4.0.0-alpha.40" on SO.