diff options
Diffstat (limited to 'src/lib.ts')
| -rw-r--r-- | src/lib.ts | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -144,7 +144,7 @@ export type LayoutOptions = { layoutType: 'sqr' | 'rect' | 'sweep'; // The LayoutFn function to use rectMode: 'horz' | 'vert' | 'linear' | 'auto' | 'auto first-row'; // Rect layout in 1 row, 1 column, 1 row or column, or multiple rows (with/without first-row-heuristic) - rectSepLeaves: boolean; // Rect layout moves leaf nodes to start + rectSepLeaves: 'none' | 'start' | 'end'; // Rect layout moves leaf nodes none/to_start/to_end sweepMode: 'left' | 'top' | 'shorter' | 'auto'; // Sweep to left, top, shorter-side, or to minimise empty space sweptNodesPrio: 'linear' | 'sqrt' | 'pow-2/3'; // Specifies allocation of space to swept-vs-remaining nodes sweepingToParent: boolean; // Allow swept nodes to occupy empty space in a parent's swept-leaves area @@ -344,7 +344,7 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, } // Reorder children if applicable let oldNode: LayoutNode, oldChildIdxs: number[]; - if (opts.rectSepLeaves){ // Change 'node' to leaves-to-start version, and store old-child-order indices + if (opts.rectSepLeaves != 'none'){ // Change 'node' to leaves-moved version, and store old-child-order indices oldNode = node; let leaves: LayoutNode[] = [], nonLeaves: LayoutNode[] = []; let leafIdxs = [] as number[], nonLeafIdxs = [] as number[]; @@ -357,8 +357,13 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, nonLeafIdxs.push(idx); } }); - node = new LayoutNode(node.tolNode, leaves.concat(...nonLeaves)); - oldChildIdxs = leafIdxs.concat(...nonLeafIdxs); + if (opts.rectSepLeaves == 'start'){ + node = new LayoutNode(node.tolNode, leaves.concat(...nonLeaves)); + oldChildIdxs = leafIdxs.concat(...nonLeafIdxs); + } else { + node = new LayoutNode(node.tolNode, nonLeaves.concat(...leaves)); + oldChildIdxs = nonLeafIdxs.concat(...leafIdxs); + } } // Try finding arrangement with low empty space // Done by searching possible rows groupings, allocating within rows using dCounts, and trimming empty space @@ -549,7 +554,7 @@ let rectLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, return false; } // Create layout - if (opts.rectSepLeaves){ // Restore old 'node', and reorder 'usedTree's children to match + if (opts.rectSepLeaves != 'none'){ // Restore old 'node', and reorder 'usedTree's children to match node = oldNode!; let usedChildren = [...usedTree.children]; range(numChildren).forEach(idx => usedTree!.children[oldChildIdxs[idx]] = usedChildren[idx]); |
