The way the TreeExpanderButton animates an expanding tree branch without any modification has the child nodes start from on top of the parent node. While this looks fine when the child nodes are the same length or shorter than the parent nodes this looks fine, however when they are longer it looks awkward and derpy, with the back end of the node initially sticking out the back of the parent.
Is there a way to change this by altering the node positions, ports, spots, or link formats? Overriding the actual animation seems like it will be difficult and counterproductive. I would like the animation to start with the child nodes in a location directly adjacent to the parent. It would also be nice to be able to skip it entirely as in nodecollapse, in the case of large diagrams.
Thanks, here is my code. I am basically just trying to get a mindmap type thing set up, which I later hope to integrate with cloud storage and a bunch of other things.
var $ = go.GraphObject.make;
mainDiagram = $(go.Diagram, “mainDiagramDiv”,
<span =“Apple-tab-span” style=“white-space:pre”> {
<span =“Apple-tab-span” style=“white-space:pre”> allowMove: true,
<span =“Apple-tab-span” style=“white-space:pre”> allowCopy: true,
<span =“Apple-tab-span” style=“white-space:pre”> allowDelete: true,
<span =“Apple-tab-span” style=“white-space:pre”> allowHorizontalScroll: true,
<span =“Apple-tab-span” style=“white-space:pre”> layout:
<span =“Apple-tab-span” style=“white-space:pre”> $(go.TreeLayout,
<span =“Apple-tab-span” style=“white-space:pre”> {
<span =“Apple-tab-span” style=“white-space:pre”> angle: 0,
<span =“Apple-tab-span” style=“white-space:pre”> compaction: go.TreeLayout.CompactionNone,
<span =“Apple-tab-span” style=“white-space:pre”> layerSpacing: 60,
<span =“Apple-tab-span” style=“white-space:pre”> layerSpacingParentOverlap: 0,
<span =“Apple-tab-span” style=“white-space:pre”> nodeIndent: 2,
<span =“Apple-tab-span” style=“white-space:pre”> nodeIndentPastParent: 0.88,
<span =“Apple-tab-span” style=“white-space:pre”> nodeSpacing: 2,
<span =“Apple-tab-span” style=“white-space:pre”> setsPortSpot: false,
<span =“Apple-tab-span” style=“white-space:pre”> setsChildPortSpot: false
<span =“Apple-tab-span” style=“white-space:pre”> }
<span =“Apple-tab-span” style=“white-space:pre”> )
<span =“Apple-tab-span” style=“white-space:pre”> }
);
mainDiagram.initialContentAlignment = go.Spot.Center;
mainDiagram.nodeTemplate = $(go.Node, “Horizontal”,
{ selectionAdorned: false }, // no Adornment: instead change panel background color by binding to Node.isSelected
$(go.Panel, “Auto”,
<span =“Apple-tab-span” style=“white-space:pre”> $(go.Shape, “RoundedRectangle”, {fill: “transparent”}),
<span =“Apple-tab-span” style=“white-space:pre”> { position: new go.Point(0, 0) },
new go.Binding(“background”, “isSelected”,
<span =“Apple-tab-span” style=“white-space:pre”> function (s) { return (s ? “lightblue” : “white”); }).ofObject(),
$(go.TextBlock,
<span =“Apple-tab-span” style=“white-space:pre”> new go.Binding(“text”, “key”, function(s) { return " " + s; })
<span =“Apple-tab-span” style=“white-space:pre”> ) //end TextBlock
), // end Horizontal Panel
<span =“Apple-tab-span” style=“white-space:pre”> $(“TreeExpanderButton”)
); // end Node
mainDiagram.linkTemplate = $(go.Link,
<span =“Apple-tab-span” style=“white-space:pre”> {
<span =“Apple-tab-span” style=“white-space:pre”> selectable: false,
<span =“Apple-tab-span” style=“white-space:pre”> corner: 0,
<span =“Apple-tab-span” style=“white-space:pre”> fromEndSegmentLength: 4,
<span =“Apple-tab-span” style=“white-space:pre”> fromSpot: go.Spot.Right,
<span =“Apple-tab-span” style=“white-space:pre”> toSpot: go.Spot.Left
<span =“Apple-tab-span” style=“white-space:pre”> },
<span =“Apple-tab-span” style=“white-space:pre”> $(go.Shape)
);
var nodeDataArray = [
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Home” },
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Research”, parent: “Home” },
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Contact”, parent: “Home” },
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Systems Factorial Technology”, parent: “Research” },
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Fractal Geometry”, parent: “Research” },
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Network Theory”, parent: “Research” },
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Email”, parent: “Contact”},
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Facebook”, parent: “Contact”},
<span =“Apple-tab-span” style=“white-space:pre”> { key: “Phone”, parent: “Contact”},
<span =“Apple-tab-span” style=“white-space:pre”> { key: “LinkedIn”, parent: “Contact”},
];
mainDiagram.model = new go.TreeModel(nodeDataArray);