Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →
ReferenceUtils

getNodesBounds()

Source on GitHub 

The getNodesBounds util returns the bounding Rect that contains all of the given nodes — handy for centering the view on a subset of nodes or measuring a group.

import { getNodesBounds, useVueFlow } from '@xyflow/vue'; const { getNodes } = useVueFlow(); const bounds = getNodesBounds(getNodes.value);

Signature

Parameters:
NameTypeDefault
nodes(string | NodeType | InternalNodeBase<NodeType>)[]

Nodes to calculate the bounds for.

params.nodeOriginNodeOrigin

Origin of the nodes: [0, 0] for top-left, [0.5, 0.5] for center.

[0, 0]
params.nodeLookupNodeLookup<InternalNodeBase<NodeType>>
Returns:
Rect

Bounding box enclosing all nodes.