sigma.js icon indicating copy to clipboard operation
sigma.js copied to clipboard

leaveNode is not fired when node is moved outside of cursor (e.g. due to a ForceSupervisor)

Open nitzanhen opened this issue 2 years ago • 2 comments

I have a graph that uses ForceSupervisor and supports drag & drop. When dragging a node and letting go, the forces might move it away from the cursor - but the leaveNode event isn't fired in that case, until the user manually moves the cursor. This is a problem, for example, when applying "active" styles on a node that's being hovered or dragged - when ending the drag, the "active" styling remains on the element, although it's neither hovered nor dragged anymore.

Sigma.js version: 3.0.0-alpha3 Graphology version: 0.25.4 Operating System: Windows 10 Web browser: Electron 22.3.4 & Firefox 120.0.1

Steps to reproduce

See the CodeSandbox example, which is modified from the interactivity example found on the readme.
To reproduce the error, drag a node from the cluster out, then release without moving the cursor - it should fly back to the cluster and away from the cursor, but the leaveNode event is not fired (only the clickNode event). Moving the cursor does cause the event to be fired.

Expected behavior

The leaveNode event should fire as soon as the cursor is not in its bounds, even if the node moving is what changed.

Actual behavior

The leaveNode event is not fired until the user moves the cursor.

If this is the intended behavior, is there a good workaround to detect that the cursor is no longer on the node?

Thanks for your time, and I appreciate the effort that you've put into this awesome project!

nitzanhen avatar Dec 13 '23 18:12 nitzanhen

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 26 '24 06:01 stale[bot]

Yes, this issue is very legit. It's a bit hard to solve, because of the current split between the mouse captor and the touch captor. I add the "pinned" tag so that it stays open. Thanks a lot for the report!

jacomyal avatar Jan 30 '24 14:01 jacomyal