MCPcopy Create free account
hub / github.com/angular/components / getMutableClientRect

Function getMutableClientRect

src/cdk/drag-drop/dom/dom-rect.ts:10–27  ·  view source on GitHub ↗
(element: Element)

Source from the content-addressed store, hash-verified

8
9/** Gets a mutable version of an element's bounding `DOMRect`. */
10export function getMutableClientRect(element: Element): DOMRect {
11 const rect = element.getBoundingClientRect();
12
13 // We need to clone the `clientRect` here, because all the values on it are readonly
14 // and we need to be able to update them. Also we can't use a spread here, because
15 // the values on a `DOMRect` aren't own properties. See:
16 // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
17 return {
18 top: rect.top,
19 right: rect.right,
20 bottom: rect.bottom,
21 left: rect.left,
22 width: rect.width,
23 height: rect.height,
24 x: rect.x,
25 y: rect.y,
26 } as DOMRect;
27}
28
29/**
30 * Checks whether some coordinates are within a `DOMRect`.

Callers 3

cacheMethod · 0.90
_cacheItemPositionsMethod · 0.90

Calls 1

getBoundingClientRectMethod · 0.80

Tested by

no test coverage detected