Listen to "mouseup" on a "dragend"

1,039 views
Skip to first unread message

s p

unread,
Apr 23, 2012, 3:55:18 PM4/23/12
to d3...@googlegroups.com
Hi !

I am using drag and drop to draw a line between two rect. To detect what is the end rect of the line I'd like to listen to "mouseup" on that rectangle.
I've checked d3's source code, and it seems that "mouseup" event propagation is stopped on "dragend", so I cannot use "mouseup" the way I wanted.
Does somebody know if there is a workaround ?

Thanks !

Sébastien

EightBitBoy

unread,
Apr 23, 2012, 6:29:22 PM4/23/12
to d3...@googlegroups.com
You could check for the "mouseover" event on the target rectangle and set a boolean flag for the mouseover to true; a "mouseout" event sets it to false again. Listen to the "mouseup" event too; when the "mouseup" event fires and the flag is set to true you can execute your desired action.

s p

unread,
Apr 25, 2012, 4:16:57 AM4/25/12
to d3...@googlegroups.com
Yes ... I thought about that. But I hoped there would be a way to change d3's behaviour and let the "mouseup" event be free :)
When you say " Listen to the "mouseup" event too ", I guess you meant "dragend" !?
Thanks for the answer anyway !

EightBitBoy

unread,
Apr 26, 2012, 9:00:39 AM4/26/12
to d3...@googlegroups.com
By "mouseup" I mean the SVG event attribute. Since there is no SVG "dragend" it can be emulated with "mouseup" and a boolean flag.

s p

unread,
Apr 26, 2012, 5:47:53 PM4/26/12
to d3...@googlegroups.com
Ok ... So to be sure that I understand ...
Because you advise to listen to the "mouseup" event, but the problem is actually that the "mouseup" event is NOT triggered (or actually is is just caught and stopped).
Do you mean that I should catch "dragend" on the rectangle (since I cannot catch "mouseup"), and "mouseup" on the whole svg, and then check the state over/out, and act in consequence !?

EightBitBoy

unread,
Apr 30, 2012, 4:14:56 AM4/30/12
to d3...@googlegroups.com
Seriously, I have no Idea! :D

For a project I wanted to use d3's drag events but they somehow did not seem to work so I used the workaround with the "mousedown" / "mouseup" events and the flag which worked just fine.

When you say * "mouseup" is being caught by "dragend" * do you mean "mouseup" actually never works or is it only disabled when using "dragend"?
Reply all
Reply to author
Forward
0 new messages