(children: MindMapTreeNode[])
| 190 | }; |
| 191 | |
| 192 | const splitTopLevelChildren = (children: MindMapTreeNode[]) => { |
| 193 | const left: MindMapTreeNode[] = []; |
| 194 | const right: MindMapTreeNode[] = []; |
| 195 | let leftHeight = 0; |
| 196 | let rightHeight = 0; |
| 197 | |
| 198 | [...children] |
| 199 | .sort((a, b) => measureHeight(b) - measureHeight(a)) |
| 200 | .forEach((child, index) => { |
| 201 | const childHeight = measureHeight(child); |
| 202 | if ((index % 2 === 0 && rightHeight <= leftHeight) || leftHeight > rightHeight) { |
| 203 | right.push(child); |
| 204 | rightHeight += childHeight; |
| 205 | } else { |
| 206 | left.push(child); |
| 207 | leftHeight += childHeight; |
| 208 | } |
| 209 | }); |
| 210 | |
| 211 | return { left, right }; |
| 212 | }; |
| 213 | |
| 214 | const layoutGroup = ( |
| 215 | children: MindMapTreeNode[], |
no test coverage detected