diff options
Diffstat (limited to 'src/layout.ts')
| -rw-r--r-- | src/layout.ts | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/layout.ts b/src/layout.ts index ece1c1a..5a3ca5c 100644 --- a/src/layout.ts +++ b/src/layout.ts @@ -124,7 +124,7 @@ export class LayoutNode { map.set(node.name, node); } }); - LayoutNode.updateDCounts(layoutNode, layoutNode.children.length); + LayoutNode.updateDCounts(layoutNode, layoutNode.children.length - 1); // Get matching child node let childNode = layoutNode.children.find(n => n.name == childName); if (childNode == null){ @@ -141,17 +141,20 @@ export class LayoutNode { } } // These are used to hide/show parent nodes upon an expand-to-view - static hideUpward(node: LayoutNode): void { + static hideUpward(node: LayoutNode, map: LayoutMap): void { if (node.parent != null){ node.parent.hidden = true; - node.parent.children.filter(n => n != node).forEach(n => LayoutNode.hideDownward(n)); - LayoutNode.hideUpward(node.parent); + node.parent.children.filter(child => child != node).forEach(sibling => { + sibling.hidden = true; + // Remove sibling children from layout tree + LayoutNode.updateDCounts(sibling, 1 - sibling.children.length); + sibling.children.forEach(n => removeFromLayoutMap(n, map)); + sibling.children = []; + }); + // Recurse + LayoutNode.hideUpward(node.parent, map); } } - static hideDownward(node: LayoutNode): void { - node.hidden = true; - node.children.forEach(n => LayoutNode.hideDownward(n)); - } static showDownward(node: LayoutNode): void { if (node.hidden){ node.hidden = false; |
