Skip to content

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.

1 nodes · 0 edges · last drop: -
Drag my handle to empty space
Arrow keys move the view, Home shows the whole flow.
bit Blow

Try 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

  • OnConnectEnd is raised whenever a connection gesture ends, whether it made an edge or not, with a BlowConnectEndInfo.
  • IsValid is true when the gesture connected - released on a handle that accepts it, or within ConnectionRadius (20 screen pixels) of one. The canvas has already added that edge itself.
  • IsDropped is 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. IsReconnect is true when the gesture moved the end of an existing edge.
  • Rejection (a BlowConnectionRejection) is why a handle refused the drop - SameHandleType, Duplicate, RejectedByRule and so on - and None when the drop landed on empty space. So "dropped on empty space" is IsDropped, not IsValid, not IsReconnect, and no rejection.
  • Start (a BlowConnectionStartInfo) names the NodeId, HandleId and HandleType the drag came from: a source handle spawns a node downstream, a target handle one upstream. FlowPosition is the drop point in flow coordinates (ClientX/ClientY on screen).
  • The new node is given an explicit Width and Height (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 in SourceHandle or TargetHandle.
  • FitViewOptions with MaxZoom = 1 keeps FitViewOnInit from blowing the lone starting node up to the canvas's maximum zoom.
An unhandled error has occurred. Reload 🗙