(dir: 'TB' | 'LR')
| 1015 | // 1) Layout with current (possibly estimated) sizes |
| 1016 | // 2) After ReactFlow updates measured sizes, layout again to eliminate overlaps |
| 1017 | const apply = (dir: 'TB' | 'LR') => { |
| 1018 | const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements( |
| 1019 | nodesRef.current, |
| 1020 | edgesRef.current, |
| 1021 | dir, |
| 1022 | { compact: layoutCompact } |
| 1023 | ); |
| 1024 | setNodes(layoutedNodes); |
| 1025 | setEdges(layoutedEdges); |
| 1026 | }; |
| 1027 | apply(layoutDirection); |
| 1028 | // Next frames: measured sizes (node.measured) are more likely available, then optionally fit the whole graph |
| 1029 | requestAnimationFrame(() => { |
no test coverage detected