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 |