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

Function getLayoutTop

lib/utils/test/scrollElement.ts:73–93  ·  view source on GitHub ↗
(element: Element, root: Element)

Source from the content-addressed store, hash-verified

71
72// The top of the element relative to the top of the root (e.g. the content of a scroll container)
73function getLayoutTop(element: Element, root: Element): number {
74 let top = 0;
75 let node: Element = element;
76 while (node !== root && node.parentElement) {
77 if (isAbsolutelyPositioned(node)) {
78 top += parsePixels(getStyle(node)?.top ?? "") ?? 0;
79 } else {
80 for (
81 let sibling = node.previousElementSibling;
82 sibling;
83 sibling = sibling.previousElementSibling
84 ) {
85 if (!isAbsolutelyPositioned(sibling)) {
86 top += getLayoutHeight(sibling);
87 }
88 }
89 }
90 node = node.parentElement;
91 }
92 return top;
93}
94
95function getClosestContainer(element: Element): Element | null {
96 for (

Callers 1

getBoundingClientRectFunction · 0.85

Calls 4

isAbsolutelyPositionedFunction · 0.85
parsePixelsFunction · 0.85
getStyleFunction · 0.85
getLayoutHeightFunction · 0.85

Tested by

no test coverage detected