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

Expose dx and dy on the DragEvent. #21

Closed
altocumulus opened this issue May 20, 2016 · 2 comments
Closed

Expose dx and dy on the DragEvent. #21

altocumulus opened this issue May 20, 2016 · 2 comments
Assignees

Comments

@altocumulus
Copy link

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?

@mbostock
Copy link
Member

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.

@mbostock mbostock self-assigned this May 21, 2016
@mbostock mbostock changed the title Expose dx and dy on the DragEvent Expose dx and dy on the DragEvent. May 21, 2016
@altocumulus
Copy link
Author

altocumulus commented May 30, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants