Open Phloog opened 8 months ago
Hello,
How are you doing things now?
Hey, I worked around the problem with a bit of a dirty hack:
Additionally, using CSS, I make the canvas invisible until its FirstRendered Prop is true, and then with a transition I make it visible. This hides the un-arranged nodes that tend to "jump" to their final positions.
All of this does work, but it feels very hacky...
The DiagramCanvas component seems to behave differently on page refreshes / different lifecycle steps. It's a bit nondeterministic, so it's hard to reproduce / describe.
Ultimately, what I want to achieve is reproducable behaviour with auto-arrange (layoutalgorithm using msagl), automatic ZoomToFit (after arranging the nodes) and registering of custom Node components (this only works after the DiagramCanvas finished its initialization / the @ref-Param is set).
The experienced behaviour is:
a) sometimes everything works on initial Page load b) sometimes the canvas is empty (but the diagrams Node- and Link-Lists are set, as can be verified via debugger) c) sometimes the nodes and links are displayed, but not translating together with the grid; the grid can be dragged and zoomed, and single nodes can be dragged, but the nodes don't follow the pan of the canvas / grid d) sometimes everything works, but is zoomed waaaay in (factor 5 or more) initially
when refreshing (F5) the page, most often cases b) and c) are experienced, very seldomly a) when case b) is experienced, sometimes calling ZoomToFit fixes the situation (nodes appear, can be dragged, etc.) also sometimes in case b), the nodes appear as soon as the canvas is dragged/panned.
To summarize into a single question:
how can I ensure the diagram is setup, arranged and "ZoomToFit"ed on load, and custom Nodes are registered?
Thanks!