PageSourceSearch

https://ght-unyon.fr/libraries/popperjs/dist/esm/dom-utils/getCompositeRect.js

js ght-unyon.fr collected 2026-10-08 07:55:46 UTC 2,072 bytes, 58 lines download raw bytes

vendor: 2,072 bytes, lines 1-58
1import getBoundingClientRect from "./getBoundingClientRect.js";
2import getNodeScroll from "./getNodeScroll.js";
3import getNodeName from "./getNodeName.js";
4import { isHTMLElement } from "./instanceOf.js";
5import getWindowScrollBarX from "./getWindowScrollBarX.js";
6import getDocumentElement from "./getDocumentElement.js";
7import isScrollParent from "./isScrollParent.js";
8import { round } from "../utils/math.js";
9
10function isElementScaled(element) {
11  var rect = element.getBoundingClientRect();
12  var scaleX = round(rect.width) / element.offsetWidth || 1;
13  var scaleY = round(rect.height) / element.offsetHeight || 1;
14  return scaleX !== 1 || scaleY !== 1;
15} // Returns the composite rect of an element relative to its offsetParent.
16// Composite means it takes into account transforms as well as layout.
17
18
19export default function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
20  if (isFixed === void 0) {
21    isFixed = false;
22  }
23
24  var isOffsetParentAnElement = isHTMLElement(offsetParent);
25  var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
26  var documentElement = getDocumentElement(offsetParent);
27  var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
28  var scroll = {
29    scrollLeft: 0,
30    scrollTop: 0
31  };
32  var offsets = {
33    x: 0,
34    y: 0
35  };
36
37  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
38    if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
39    isScrollParent(documentElement)) {
40      scroll = getNodeScroll(offsetParent);
41    }
42
43    if (isHTMLElement(offsetParent)) {
44      offsets = getBoundingClientRect(offsetParent, true);
45      offsets.x += offsetParent.clientLeft;
46      offsets.y += offsetParent.clientTop;
47    } else if (documentElement) {
48      offsets.x = getWindowScrollBarX(documentElement);
49    }
50  }
51
52  return {
53    x: rect.left + scroll.scrollLeft - offsets.x,
54    y: rect.top + scroll.scrollTop - offsets.y,
55    width: rect.width,
56    height: rect.height
57  };
58}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.