( currentSizes: number[], newContainerSize: number )
| 52 | * Distribute sizes proportionally when container size changes |
| 53 | */ |
| 54 | export function distributeSizes( |
| 55 | currentSizes: number[], |
| 56 | newContainerSize: number |
| 57 | ): number[] { |
| 58 | const totalCurrentSize = currentSizes.reduce((sum, size) => sum + size, 0); |
| 59 | |
| 60 | if (totalCurrentSize === 0) { |
| 61 | // Equal distribution |
| 62 | const equalSize = newContainerSize / currentSizes.length; |
| 63 | return currentSizes.map(() => equalSize); |
| 64 | } |
| 65 | |
| 66 | // Proportional distribution |
| 67 | return currentSizes.map( |
| 68 | (size) => (size / totalCurrentSize) * newContainerSize |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Calculate new sizes after a divider drag |
no outgoing calls
no test coverage detected
searching dependent graphs…