MCPcopy
hub / github.com/ankeetmaini/react-infinite-scroll-component / buildRootMargin

Function buildRootMargin

src/utils/buildRootMargin.ts:22–38  ·  view source on GitHub ↗
(
  scrollThreshold: number | string,
  inverse: boolean
)

Source from the content-addressed store, hash-verified

20 * For inverse mode the margin is applied to the top instead of the bottom.
21 */
22export function buildRootMargin(
23 scrollThreshold: number | string,
24 inverse: boolean
25): string {
26 const threshold = parseThreshold(scrollThreshold);
27
28 let margin: string;
29 if (threshold.unit === ThresholdUnits.Pixel) {
30 margin = `${threshold.value}px`;
31 } else {
32 // threshold.value is already in percent (e.g. 80 for 0.8 input)
33 const remaining = 100 - threshold.value;
34 margin = `${remaining}%`;
35 }
36
37 return inverse ? `${margin} 0px 0px 0px` : `0px 0px ${margin} 0px`;
38}

Callers 3

useInfiniteScrollFunction · 0.90
InfiniteScrollFunction · 0.90

Calls 1

parseThresholdFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…