Add Node on Edge Drop
A connection dropped on empty space becomes a new node, already connected, right where you let go. The
canvas's OnConnectEnd reports how every connection gesture ended - its
BlowConnectEndInfo says which handle it started from, where it was released, and whether it was
a real drop of a new connection - which is all the page needs to decide.
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 bottom handle of the first node and release on the empty pane: a new node appears with its top handle where you let go, joined to the first by an animated edge.
- Drag from the top handle of a node you spawned - a target handle - into empty space: this time the new node goes upstream, with its bottom handle at the drop point, feeding the node you dragged from.
- Release on a handle that accepts the connection, such as a free top handle: it connects as usual and nothing is added.
- Release on a handle that refuses it, such as another node's bottom handle (two sources): nothing is added, and the line above the canvas names the reason.
- Click a handle without dragging, or press Escape during a drag: the gesture is cancelled and nothing is added.
- Click an edge to select it and drag one of the dots at its ends onto the empty pane: that is a reconnect, not a new connection, so no node is added and the edge stays as it was.
- Press Reset to start again from the single node.
How it works
OnConnectEndis raised whenever a connection gesture ends, whether it made an edge or not, with aBlowConnectEndInfo.IsValidis true when the gesture connected - released on a handle that accepts it, or withinConnectionRadius(20 screen pixels) of one. The canvas has already added that edge itself.IsDroppedis true only when the pointer was released after a real drag - not for a click on a handle, a click-to-connect, Escape, or a pointer the browser cancelled.IsReconnectis true when the gesture moved the end of an existing edge.Rejection(aBlowConnectionRejection) is why a handle refused the drop -SameHandleType,Duplicate,RejectedByRuleand so on - andNonewhen the drop landed on empty space. So "dropped on empty space" isIsDropped, notIsValid, notIsReconnect, and no rejection.Start(aBlowConnectionStartInfo) names theNodeId,HandleIdandHandleTypethe drag came from: a source handle spawns a node downstream, a target handle one upstream.FlowPositionis the drop point in flow coordinates (ClientX/ClientYon screen).- The new node is given an explicit
WidthandHeight(BlowNode.DefaultWidth×DefaultHeight, 150 × 40), so the page knows where its handles are before the browser has measured it. The new edge carries the start handle's id inSourceHandleorTargetHandle. FitViewOptionswithMaxZoom = 1keepsFitViewOnInitfrom blowing the lone starting node up to the canvas's maximum zoom.