Skip to content

Node Extents

Four ways to limit where a node can be dragged: a rectangle of its own (Extent), its parent's box (ExtentParent), a parent that grows to keep its child enclosed (ExpandParent), and a rectangle no root node may leave (the canvas's NodeExtent).

Dashed outlines show the allowed areas
Own extent
Free node
ExtentParent
ExpandParent
Pinned inside
Push the edges
bit Blow

Try it

  • Drag Own extent around: it stops at the amber outline, the rectangle in its own Extent.
  • Drag Pinned inside towards its group's border: it stops there.
  • Drag Push the edges past its group's border: the group grows to keep it enclosed. Past the left or top edge the group's corner moves out instead, so nothing else on screen jumps.
  • Tick fence in the root nodes: a violet outline appears, and neither the free node nor the two groups can be dragged out of it. Own extent keeps to its own rectangle, which takes precedence.
  • Select a node and use the arrow keys: the nudges respect the same limits.
  • Press Reset positions to put everything back.

How it works

  • BlowNode.Extent is a BlowRect the node cannot leave, written in its own coordinate space - relative to its parent when it has one.
  • ExtentParent = true keeps a child inside its parent's box (React Flow's extent: 'parent').
  • ExpandParent = true grows the parent instead when the child is dragged past its edge. It is ignored when ExtentParent is set.
  • The canvas's NodeExtent is a rectangle no root node may leave - bound to null here while the box is unticked. It does not apply to children, whose positions are in their parent's space.
  • ExtentParent wins over Extent, which wins over NodeExtent. The same limits hold for arrow-key nudges, align and distribute, and resizing.
  • The outlines are plain elements in a BlowViewportPortal, which renders inside the zoomed layer, so they pan and zoom with the nodes.
An unhandled error has occurred. Reload 🗙