diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-05-24 18:17:47 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-05-24 18:17:47 +1000 |
| commit | 1615a629e8eaceb4c5d504a0b17bc04769233fd5 (patch) | |
| tree | d02551a429fdbed40edf8b61bfc4296063f35807 /src/layout.ts | |
| parent | fa8111c3881a0e37ef203f2e0ceb9b85748bb27d (diff) | |
Upon expand-to-view, remove ancestor other-descendants from layout tree
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; |
