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

Drag event issue

NZ-HIPS opened this issue · comments

Hi,

Drag event is attached to the vertical dashed line. Can't make it work, it seems that the drag event is NOT firing when trying to drag for the first time. Instead, the digits of the scale are being selected. And only when those digits remain selected, the drag fires when trying to move the dashed bar for the second time. This is in Chrome. In Firefox, it doesn't work at all.
Block:
https://bl.ocks.org/user1313/a0999345634bd7c7b6ddc955f37609a4

Is this me or a bug? Thanks.

You’re using selection.on to listen for the native dragstart, drag and dragend events rather than using the d3-drag behavior. I don’t think you can use the native drag events for that. Native dragging is typically used when you select some text, click and hold on the selection, and then move the mouse. In macOS, you’ll see the selected text turn transparent and the cursor may change to a special cursor with a green ball underneath.

If you want to use drag to move that vertical line, you probably want to use d3-drag.

If you have more questions, 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! 🤗