source: imaps-frontend/node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.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: 1.2 KB
Line 
1// @flow
2import type { Rect } from '../types';
3import getDocumentElement from './getDocumentElement';
4import getComputedStyle from './getComputedStyle';
5import getWindowScrollBarX from './getWindowScrollBarX';
6import getWindowScroll from './getWindowScroll';
7import { max } from '../utils/math';
8
9// Gets the entire size of the scrollable document area, even extending outside
10// of the `<html>` and `<body>` rect bounds if horizontally scrollable
11export default function getDocumentRect(element: HTMLElement): Rect {
12 const html = getDocumentElement(element);
13 const winScroll = getWindowScroll(element);
14 const body = element.ownerDocument?.body;
15
16 const width = max(
17 html.scrollWidth,
18 html.clientWidth,
19 body ? body.scrollWidth : 0,
20 body ? body.clientWidth : 0
21 );
22 const height = max(
23 html.scrollHeight,
24 html.clientHeight,
25 body ? body.scrollHeight : 0,
26 body ? body.clientHeight : 0
27 );
28
29 let x = -winScroll.scrollLeft + getWindowScrollBarX(element);
30 const y = -winScroll.scrollTop;
31
32 if (getComputedStyle(body || html).direction === 'rtl') {
33 x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
34 }
35
36 return { width, height, x, y };
37}
Note: See TracBrowser for help on using the repository browser.