Hi,
When a user zoom in a Diagram, I would like to save and restore the view at the same position when a PostBack is made. And if it’s the first load of the page, I want a autoscale on it.
My initialisation is:
myDiagram =
goJs(go.Diagram, “myDiagram”,
{
“toolManager.mouseWheelBehavior”: go.ToolManager.WheelZoom,
allowDrop: false, // support drag-and-drop from the Palette
“linkingTool.direction”: go.LinkingTool.ForwardsOnly,
initialContentAlignment: go.Spot.Center,
layout: goJs(go.LayeredDigraphLayout, { isInitial: false, isOngoing: false, layerSpacing: 100, direction: 90 }),
maxSelectionCount: 1
});
When the page is loaded I call:
if ($("#hdnPositionZoom").val() == “”) {
myDiagram.initialAutoScale = go.Diagram.Uniform;
} else {
myDiagram.initialAutoScale = go.Diagram.None;
myDiagram.scrollToRect(new go.Rect($("#hdnPositionZoom").val()));
}
And in the ViewportBoundsChanged event:
myDiagram.addDiagramListener(“ViewportBoundsChanged”, function (e) {
if (myDiagram.initialAutoScale != go.Diagram.Uniform) {
var aPosition = myDiagram.viewportBounds;
$("#hdnPositionZoom").val(aPosition);
} else {
myDiagram.initialAutoScale = go.Diagram.None;
}
});
I think it exist a easy to do what I want but I don’t find it. Could you help me?
Thanks.