Skip to content

Connection Mode

ConnectionMode decides which handles may be joined: Strict, the default, only joins a source to a target, while Loose lets any handle connect to any other - a source to a source, a target to a target. Use Loose for undirected diagrams where a handle is just a connection point.

Drag between the handles.
Node 1
targetsource
Node 2
targetsource
Node 3
targetsource
Node 4
targetsource
bit Blow

Try it

  • In Strict mode, drag from Node 1's right-hand (source) handle: only the other nodes' left-hand (target) handles turn green. Release on another node's right-hand handle and nothing is connected; the line beside the toolbar says why.
  • Release on a left-hand handle instead to connect. Dragging the other way, from a target to a source, works too: the edge still runs from the source.
  • Switch Mode to Loose and drag from a right-hand handle again: every handle on the other nodes turns green, and a source dropped on a source connects - so does a target on a target.
  • Switch back to Strict: the edges strict mode would not allow are removed, since this page keeps only what its mode permits. Remove edges clears the rest.

How it works

  • ConnectionMode on the canvas is BlowConnectionMode.Strict by default: two handles of the same type are refused with the Rejection SameHandleType, reported by OnConnectEnd.
  • BlowConnectionMode.Loose drops that rule; the others - no duplicates, no self-connections, your IsValidConnection - still apply.
  • The new edge runs from the handle the drag started at when that is a source, and towards it when it is a target, so a target dropped on a target makes the dropped-on node the edge's Source. OnConnect reports the resulting BlowConnection.
  • In Loose mode an edge can name a source handle as its TargetHandle; the canvas then looks for the handle among both types to anchor the edge. A strict canvas does not, which is why this page removes such edges in ModeChanged when you switch back.
  • The handles' colours come from this page's cm-source and cm-target classes, which set --bit-blow-handle-bg; while a connection is dragged the canvas's green and red take over.
An unhandled error has occurred. Reload 🗙