Initial alignment while loading

Hi,

This is how the diagram layout looks when i save the state of the diagram.

Each of those Flow tabs can load a different model and display a different diagram.

When I switch between tabs and come back to load the same diagram again, the entire diagram has changed position and is moved up on the canvas as seen below:

How can this be fixed?

What do you do to save the state of the diagram? Presumably you save the Diagram.model’s state somehow. Does that include the values for Diagram.position and Diagram.scale?

If you are calling Model.toJson, you could first save copies of those values in the Model.modelData object. Then after calling Model.fromJson but before setting Diagram.model, you should set Diagram.initialPosition and Diagram.initialScale to those two loaded values. That way when you set the Diagram.model the values for position and scale will eventually get those initial values.

For example, in GoJS/SnapLinkReshaping.html at 4f7cd6e423df0fd15c50696516371c33c7e08b90 · NorthwoodsSoftware/GoJS · GitHub, look at the save... and load... functions.