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

drag inhibits mouseup #391

Closed
biovisualize opened this issue Nov 27, 2011 · 11 comments
Closed

drag inhibits mouseup #391

biovisualize opened this issue Nov 27, 2011 · 11 comments

Comments

@biovisualize
Copy link
Contributor

I need to bind a mouseup and a drag on the same selection to be able to discriminate between a mouseup after a drag (dragend) or not (mouseup). This pattern worked with 2.4.6 but seems broken in 2.6.0. Mousedown is still working. Here is an example:

d3.select("body").append("svg:svg")
.append("svg:rect")
.attr("width", 100)
.attr("height", 100)
.attr("fill", "red")
.on("mouseup", mouseup)
.call(d3.behavior.drag()
.on("drag", drag));

function drag(){
console.log("working");
}

function mouseup(){
console.log("non-working in 2.6.0");
}

Do you want me to test further?

@mbostock
Copy link
Member

Hmm, there might be an ordering bug. But I think you should be using click rather than mouseup? Or potentially using a capturing listener.

@biovisualize
Copy link
Contributor Author

You're right, click is more suitable and I can't think of a situation where mouseup can't be replaced by click. Thanks!

@biovisualize
Copy link
Contributor Author

Looks like drag also inhibits the pan behaviour. I thought the events where namespaced and could not interfere.

@mbostock
Copy link
Member

On the same element? Please include an example.

@biovisualize
Copy link
Contributor Author

With a drag on a child element and pointer-events:all on the parent.
http://jsfiddle.net/E7b4E/1/
In 2.5.0, dragging the blue rectangle pans the view, not in 2.6.0. The new behavior is more consistent (why pan and drag at the same time?). But I used the old functionality to pan only on altKey even when over a draggable item.

@mbostock
Copy link
Member

Hmm. I'm not sure how best to support that.

@biovisualize
Copy link
Contributor Author

It's not a big concern. But do you have an idea what changed that inhibited pointer-events:all? Maybe the stoppropagation on line 4356?

0404f35

@biovisualize
Copy link
Contributor Author

Yes that's the one. Commenting it reverts to the old behaviour. But I agree it's still not the right way to use the zoom behaviour.

@mbostock
Copy link
Member

Correct.

@biovisualize
Copy link
Contributor Author

I'm still tracking this one and it seems a little less consistent now. On right click, I have a mousedown when opening the context menu and then only mouseups. If I prevent the context menu, then I always have mousedown but no mouseup. On left click, I have a mouseup only the first release following the opening of the contextual menu.
http://jsfiddle.net/E7b4E/3/

@mbostock mbostock closed this as completed Dec 9, 2011
@mbostock
Copy link
Member

mbostock commented Dec 9, 2011

Closing this, but feel free to reopen if you have suggestions on what to change.

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