MCPcopy Create free account
hub / github.com/bvaughn/react-virtualized / cellPositioner

Function cellPositioner

lib/components/Masonry/createCellPositioner.ts:21–40  ·  view source on GitHub ↗
(index: number)

Source from the content-addressed store, hash-verified

19 initOrResetDerivedValues();
20
21 function cellPositioner(index: number): Position {
22 // Find the shortest column and use it.
23 let columnIndex = 0;
24 for (let i = 1; i < columnHeights.length; i++) {
25 if (columnHeights[i] < columnHeights[columnIndex]) {
26 columnIndex = i;
27 }
28 }
29
30 const left = columnIndex * (columnWidth + spacer);
31 const top = columnHeights[columnIndex] || 0;
32
33 columnHeights[columnIndex] =
34 top + cellMeasurerCache.getHeight(index) + spacer;
35
36 return {
37 left,
38 top
39 };
40 }
41
42 function initOrResetDerivedValues(): void {
43 // Track the height of each column.

Callers 2

populatePositionCacheFunction · 0.70

Calls 1

getHeightMethod · 0.65

Tested by

no test coverage detected