aboutsummaryrefslogtreecommitdiff
path: root/src/layout.ts
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-07-06 17:49:42 +1000
committerTerry Truong <terry06890@gmail.com>2022-07-06 17:52:06 +1000
commit521c17523070d83e4b5878f56ad61bf37828a27e (patch)
treee6c464ac88f4238f77d4a429bfea1def0a1ddc86 /src/layout.ts
parent983530cffd27a6c633ea91e9ce910779043c7c6a (diff)
Smoothen initial loading where URL has target node
Diffstat (limited to 'src/layout.ts')
-rw-r--r--src/layout.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/layout.ts b/src/layout.ts
index 665c617..ec5b70c 100644
--- a/src/layout.ts
+++ b/src/layout.ts
@@ -221,7 +221,7 @@ function removeFromLayoutMap(node: LayoutNode, map: LayoutMap): void {
node.children.forEach(n => removeFromLayoutMap(n, map));
}
-// Creates a LayoutNode representing a TolNode tree, up to a given depth (0 means just the root)
+// Creates a LayoutNode representing a TolNode tree, up to a given depth (0 means just the root, -1 means no limit)
export function initLayoutTree(tolMap: TolMap, rootName: string, depth: number): LayoutNode {
function initHelper(tolMap: TolMap, nodeName: string, depthLeft: number, atDepth: number = 0): LayoutNode {
if (depthLeft == 0){
@@ -233,7 +233,8 @@ export function initLayoutTree(tolMap: TolMap, rootName: string, depth: number):
if (childNames.length == 0 || !tolMap.has(childNames[0])){
return new LayoutNode(nodeName, []);
} else {
- let children = childNames.map((name: string) => initHelper(tolMap, name, depthLeft-1, atDepth+1));
+ let children = childNames.map((name: string) =>
+ initHelper(tolMap, name, depthLeft != -1 ? depthLeft-1 : -1, atDepth+1));
let node = new LayoutNode(nodeName, children);
children.forEach(n => n.parent = node);
return node;