MCPcopy
hub / github.com/tomkp/react-split-pane / distributeSizes

Function distributeSizes

src/utils/calculations.ts:54–70  ·  view source on GitHub ↗
(
  currentSizes: number[],
  newContainerSize: number
)

Source from the content-addressed store, hash-verified

52 * Distribute sizes proportionally when container size changes
53 */
54export 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

Callers 2

SplitPaneFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…