getNodesBounds()
返回包含数组中所有给定节点的边界框。 这在与getViewportForBounds结合使用时非常有用,可以计算出将给定节点适配到视窗的正确变换。
ℹ️
此函数之前称为getRectOfNodes
import { getNodesBounds } from '@xyflow/react';
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 bounds = getNodesBounds(nodes);签名
| 名称 | 类型 |
|---|---|
#参数 | |
# nodes | Node[] |
#返回值 | |
Rect |