@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
26 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDocumentRect = void 0;
const getElementScroll_1 = require("./getElementScroll");
const getWindowScrollBarX_1 = require("./getWindowScrollBarX");
/**
* Gets the entire size of the scrollable document area, even extending outside
* of the `<html>` and `<body>` rect bounds if horizontally scrollable.
*/
const getDocumentRect = (element) => {
const html = window.document.documentElement;
const scroll = (0, getElementScroll_1.getElementScroll)(element);
const body = element.ownerDocument.body;
const width = Math.max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
const height = Math.max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
const x = -scroll.scrollLeft + (0, getWindowScrollBarX_1.getWindowScrollBarX)(element);
const y = -scroll.scrollTop;
return {
width,
height,
x,
y,
};
};
exports.getDocumentRect = getDocumentRect;
//# sourceMappingURL=getDocumentRect.js.map