projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.61k stars 1.17k forks source link

How call zoomToFitNodes after first render #674

Open AZbang opened 4 years ago

AZbang commented 4 years ago

I want to do zoomToFit immediately after loading the page, however when I call engine.zoomToFitNodes after engine.repaintCanvas () I get incorrect result. Apparently the sizes of the nodes have not yet been determined by this moment.

dylanvorster commented 3 years ago

Just use something like an _.defer or timeout, and/or hook into the lifecycle methods of the engine and nodes.