Skip to content

Commit cd22725

Browse files
committed
fix the zoom to fit nodes offsets calculation
1 parent dd68d1f commit cd22725

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/react-diagrams-core/src/DiagramEngine.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,12 @@ export class DiagramEngine extends CanvasEngine<CanvasEngineListener, DiagramMod
270270
zoom: zoomFactor,
271271
x:
272272
canvasRect.width / 2 -
273-
((nodesRect.getWidth() + margin * 2) * zoomFactor) / 2 +
274-
margin -
275-
nodesRect.getTopLeft().x,
273+
((nodesRect.getWidth() + margin * 2) / 2 + nodesRect.getTopLeft().x) * zoomFactor +
274+
margin,
276275
y:
277276
canvasRect.height / 2 -
278-
((nodesRect.getHeight() + margin * 2) * zoomFactor) / 2 +
279-
margin -
280-
nodesRect.getTopLeft().y
277+
((nodesRect.getHeight() + margin * 2) / 2 + nodesRect.getTopLeft().y) * zoomFactor +
278+
margin
281279
};
282280
};
283281

0 commit comments

Comments
 (0)