Use Connection
OnConnectionChange reports the connection being drawn on every move - where it started, where the pointer is, whether letting go would connect and, if not, why the nearest handle refuses - and null once it ends. It is React Flow's useConnection, for hints or panels that follow the drag.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Drag from the handle under "Drag from here" and move around: the panel under the canvas updates on every move, with the pointer position in flow coordinates.
- Bring the pointer near the top handle of Node B or Node C: IsValid turns to yes before you are exactly on it, because a release that close would snap to it.
- Bring it near Node B's bottom handle instead: Rejection says SameHandleType - a source cannot be joined to a source. Connect to Node B once and approach its top handle again for Duplicate.
- Let go or press Escape: the canvas sends a final null, and the panel says how many updates the gesture took. Drag from a target handle (the top of B or C) to see FromHandleType change.
How it works
OnConnectionChangeis anEventCallback<BlowConnectionLineContext?>: raised when a connection starts, on every pointer move while it is drawn, and once withnullwhen it ends, however it ends.FromNode,FromHandleandFromHandleTypename the handle the drag started at;Fromis its anchor andFromPositionits side.Tois the pointer, in flow coordinates, andToPositionthe side the line arrives on - the opposite ofFromPosition, for drawing a path.IsValidis true when releasing now would connect: the pointer is over a handle that accepts the connection, or withinConnectionRadius(20 screen pixels) of one.Rejectionis theBlowConnectionRejectionof the handle the line ends at - the one under the pointer, or the nearest within snapping distance - andNonewhen it would accept, or when no handle is near. The sentence beside it isBlowAriaLabels.Default.ConnectionRejected, what a screen reader hears when such a drop is refused.- The same context is what a
ConnectionLineTemplatedraws from (see Custom Connection Line). Each update re-renders this page, so keep the handler light.