From afc2fbef5f9f97460cc5648eedd2f76551bd60c5 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Tue, 28 May 2024 08:41:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E6=97=B6=E6=B5=81=E7=A8=8B=E5=9B=BE?= =?UTF-8?q?=E5=9C=A8=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/pages/Pipeline/editPipeline/index.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/react-ui/src/pages/Pipeline/editPipeline/index.jsx b/react-ui/src/pages/Pipeline/editPipeline/index.jsx index 350f94ec..3701ff25 100644 --- a/react-ui/src/pages/Pipeline/editPipeline/index.jsx +++ b/react-ui/src/pages/Pipeline/editPipeline/index.jsx @@ -51,8 +51,16 @@ const EditPipeline = () => { return item.id === val.id; }); data.nodes[index] = val; + const zoom = graph.getZoom(); + // 在拉取新数据重新渲染页面之前先获取点(0, 0)在画布上的位置 + const lastPoint = graph.getCanvasByPoint(0, 0); graph.changeData(data); graph.render(); + graph.zoomTo(zoom); + // 获取重新渲染之后点(0, 0)在画布的位置 + const newPoint = graph.getCanvasByPoint(0, 0); + // 移动画布相对位移; + graph.translate(lastPoint.x - newPoint.x, lastPoint.y - newPoint.y); } }; const savePipeline = async (val) => { @@ -432,7 +440,7 @@ const EditPipeline = () => { height: graphRef.current.clientHeight || '100%', animate: false, groupByTypes: false, - fitView: false, + fitView: true, plugins: [contextMenu], enabledStack: true, modes: {