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

Function getBoundingClientRect

lib/utils/test/scrollElement.ts:108–149  ·  view source on GitHub ↗
(this: Element)

Source from the content-addressed store, hash-verified

106}
107
108function getBoundingClientRect(this: Element): DOMRect {
109 const containerRect = containerRects.get(this);
110 if (containerRect) {
111 return new DOMRect(
112 containerRect.left,
113 containerRect.top,
114 containerRect.width,
115 containerRect.height
116 );
117 }
118
119 const documentElement = document.documentElement;
120 if (this === documentElement) {
121 return new DOMRect(
122 -mutableWindow.scrollX,
123 -mutableWindow.scrollY,
124 mutableWindow.innerWidth,
125 getLayoutHeight(document.body)
126 );
127 }
128
129 const height = getLayoutHeight(this);
130 const width = parsePixels(getStyle(this)?.width ?? "");
131
132 const container = getClosestContainer(this);
133 if (container !== null) {
134 const rect = containerRects.get(container)!;
135 return new DOMRect(
136 rect.left - container.scrollLeft,
137 rect.top + getLayoutTop(this, container) - container.scrollTop,
138 width ?? rect.width,
139 height
140 );
141 }
142
143 return new DOMRect(
144 -mutableWindow.scrollX,
145 getLayoutTop(this, documentElement) - mutableWindow.scrollY,
146 width ?? mutableWindow.innerWidth,
147 height
148 );
149}
150
151/** Installs the layout model (see above); it is restored after each test. */
152export function mockLayout() {

Callers

nothing calls this directly

Calls 5

getLayoutHeightFunction · 0.85
parsePixelsFunction · 0.85
getStyleFunction · 0.85
getClosestContainerFunction · 0.85
getLayoutTopFunction · 0.85

Tested by

no test coverage detected