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

Is React compatible with d3-drag? #40

Closed
alexung opened this issue Sep 26, 2017 · 1 comment
Closed

Is React compatible with d3-drag? #40

alexung opened this issue Sep 26, 2017 · 1 comment

Comments

@alexung
Copy link

alexung commented Sep 26, 2017

My situation is that I have multiple polylines/polygons with circles at each point, and when I click a circle I'd like the polyline to move appropriately. I don't have any id's/className's on any polyline, and the circles are being caught via d3.event.

I have a version of this working (somewhat) at the moment but there are few issues:

  1. My cursor, if moving too fast, will stop dragging the previously-dragged circle
  2. The circle, if it gets too close to another point with a circle on it, will stop moving the point that I was originally moving and instead move the point that I'm close to.
  3. Sometimes, circles are completely dragged off the line and unable to rejoin the line.

screen shot 2017-09-25 at 7 47 00 pm

I'm confused about how to get drag and drop to work with d3/react and if this is even a potentially fruitful pursuit. Would appreciate some help.

@mbostock
Copy link
Member

If the drag behavior is only listening to your circles, then if the mouse “escapes” a circle, you’ll stop receiving mouse events and drag will stop. So typically you need to put something in the background to capture mouse events, such as a rect with fill: none and pointer-events: all.

Please use Stack Overflow tag d3.js to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly. Stack Overflow provides a better collaborative forum for self-help: tens of thousands of D3-related questions have already been asked there, and some answered questions may be relevant to you.

When asking for help, please include a link to a live example that demonstrates the issue, preferably on bl.ocks.org. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.

If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.

Thank you! 🤗

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