source: imaps-frontend/node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js.flow

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 821 bytes
Line 
1// @flow
2import type { Rect } from '../types';
3import getBoundingClientRect from './getBoundingClientRect';
4
5// Returns the layout rect of an element relative to its offsetParent. Layout
6// means it doesn't take into account transforms.
7export default function getLayoutRect(element: HTMLElement): Rect {
8 const clientRect = getBoundingClientRect(element);
9
10 // Use the clientRect sizes if it's not been transformed.
11 // Fixes https://github.com/popperjs/popper-core/issues/1223
12 let width = element.offsetWidth;
13 let height = element.offsetHeight;
14
15 if (Math.abs(clientRect.width - width) <= 1) {
16 width = clientRect.width;
17 }
18
19 if (Math.abs(clientRect.height - height) <= 1) {
20 height = clientRect.height;
21 }
22
23 return {
24 x: element.offsetLeft,
25 y: element.offsetTop,
26 width,
27 height,
28 };
29}
Note: See TracBrowser for help on using the repository browser.