Skip to content

Commit e4848b4

Browse files
authored
Merge pull request #875 from GaryPan-1515/GP-fix-zoom-to-fit-nodes
Fix the zoomToFitNodes offsets calculation
2 parents c4d0136 + cd22725 commit e4848b4

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)