getRectOfNodes()
Source on GitHub (opens in a new tab)
⚠️
This function is deprecated and will be removed in v12. Use getNodesBounds instead.
Returns the bounding box that contains all the given nodes in an array. This can
be useful when combined with getViewportForBounds
to calculate the correct transform to fit the given nodes in a viewport.
import { getRectOfNodes } from 'reactflow';
const nodes = [
{
id: 'a',
position: { x: 0, y: 0 },
data: { label: 'a' },
width: 50,
height: 25,
},
{
id: 'b',
position: { x: 100, y: 100 },
data: { label: 'b' },
width: 50,
height: 25,
},
];
const rectOfNodes = getRectOfNodes(nodes);
Signature
Name | Type |
---|---|
#Params |
|
# nodes | Node[] |
#Returns |
|
Rect |