From 1615a629e8eaceb4c5d504a0b17bc04769233fd5 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Tue, 24 May 2022 18:17:47 +1000 Subject: Upon expand-to-view, remove ancestor other-descendants from layout tree --- src/App.vue | 4 ++-- src/components/SearchModal.vue | 2 +- src/layout.ts | 19 +++++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/App.vue b/src/App.vue index c8149e9..da99068 100644 --- a/src/App.vue +++ b/src/App.vue @@ -299,7 +299,7 @@ export default defineComponent({ } // Function for expanding tile let doExpansion = () => { - LayoutNode.hideUpward(layoutNode); + LayoutNode.hideUpward(layoutNode, this.layoutMap); this.activeRoot = layoutNode; this.overflownRoot = false; let lytFnOpts = { @@ -350,7 +350,7 @@ export default defineComponent({ console.log('Ignored expand-to-view on active-root node'); return; } - LayoutNode.hideUpward(layoutNode); + LayoutNode.hideUpward(layoutNode, this.layoutMap); this.activeRoot = layoutNode; tryLayout(this.activeRoot, this.tileAreaPos, this.tileAreaDims, this.lytOpts, {allowCollapse: true, layoutMap: this.layoutMap}); diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue index f86590b..210c87c 100644 --- a/src/components/SearchModal.vue +++ b/src/components/SearchModal.vue @@ -101,7 +101,7 @@ export default defineComponent({ let reqDelay = 0; if (this.pendingSearchSuggReq != 0){ clearTimeout(this.pendingSearchSuggReq); - reqDelay = 300; + reqDelay = 200; } this.pendingSearchSuggReq = setTimeout(() => fetch(url.toString()) 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; -- cgit v1.2.3