getViewportForBounds()
此工具函数返回给定边界的视窗。您可能可以使用它在服务器上预先计算给定节点集的视窗,或在不直接更改视窗的情况下计算给定边界的视窗。
ℹ️
此函数以前称为 getTransformForBounds
import { getViewportForBounds } from '@xyflow/react';
const { x, y, zoom } = getViewportForBounds(
{
x: 0,
y: 0,
width: 100,
height: 100,
},
1200,
800,
0.5,
2,
);签名
| 名称 | 类型 | 默认值 |
|---|---|---|
#参数 | | |
# bounds | Rect | |
# width | number | |
# height | number | |
# minZoom | number | |
# maxZoom | number | |
# padding? | number | |
#返回值 | | |
# viewport | Viewport转换后的视窗 (`{ x: number, y: number, zoom: number }`)。 | |