1
This commit is contained in:
parent
7e6d0c8eb5
commit
1958273d55
@ -136,14 +136,19 @@ const Toolbar: React.FC<ToolbarProps> = ({ graph }) => {
|
|||||||
// 缩放画布
|
// 缩放画布
|
||||||
const zoom = (delta: number) => {
|
const zoom = (delta: number) => {
|
||||||
if (!graph) return;
|
if (!graph) return;
|
||||||
const zoom = graph.zoom();
|
const currentZoom = graph.zoom();
|
||||||
graph.zoom(zoom + delta);
|
const nextZoom = delta > 0
|
||||||
|
? Math.min(2, currentZoom + 0.1) // 放大,最大2倍
|
||||||
|
: Math.max(0.5, currentZoom - 0.1); // 缩小,最小0.5倍
|
||||||
|
graph.zoomTo(nextZoom);
|
||||||
|
graph.centerContent(); // 居中显示内容
|
||||||
};
|
};
|
||||||
|
|
||||||
// 适应画布
|
// 适应画布
|
||||||
const fitContent = () => {
|
const fitContent = () => {
|
||||||
if (!graph) return;
|
if (!graph) return;
|
||||||
graph.zoomToFit({ padding: 20 });
|
graph.zoomToFit({ padding: 20, maxScale: 2 });
|
||||||
|
graph.centerContent();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 实际大小
|
// 实际大小
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user