()
| 36 | * (The Grid attaches its handle before running its own layout effect, which then processes the invalidations.) |
| 37 | */ |
| 38 | export function createInnerGridRef(): InnerGridRef { |
| 39 | let grid: GridImperativeAPI | null = null; |
| 40 | let pendingInvalidation: CellPosition | null = null; |
| 41 | let pendingRecomputation: CellPosition | null = null; |
| 42 | |
| 43 | return { |
| 44 | getGrid: () => grid, |
| 45 | |
| 46 | setGridRef(value) { |
| 47 | grid = value; |
| 48 | if (grid === null) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | if (pendingRecomputation !== null) { |
| 53 | const cell = pendingRecomputation; |
| 54 | pendingRecomputation = null; |
| 55 | grid.recomputeGridSize(cell); |
| 56 | } |
| 57 | if (pendingInvalidation !== null) { |
| 58 | const cell = pendingInvalidation; |
| 59 | pendingInvalidation = null; |
| 60 | grid.invalidateCellSizeAfterRender(cell); |
| 61 | } |
| 62 | }, |
| 63 | |
| 64 | invalidateCellSizeAfterRender(cell) { |
| 65 | if (grid !== null) { |
| 66 | grid.invalidateCellSizeAfterRender(cell); |
| 67 | } else { |
| 68 | pendingInvalidation = mergeCellPositions(pendingInvalidation, cell); |
| 69 | } |
| 70 | }, |
| 71 | |
| 72 | recomputeGridSize(cell) { |
| 73 | if (grid !== null) { |
| 74 | grid.recomputeGridSize(cell); |
| 75 | } else { |
| 76 | pendingRecomputation = mergeCellPositions(pendingRecomputation, cell); |
| 77 | } |
| 78 | } |
| 79 | }; |
| 80 | } |
no outgoing calls
no test coverage detected