29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
|
import getDocumentElement from "./getDocumentElement.js";
|
||
|
import getComputedStyle from "./getComputedStyle.js";
|
||
|
import getWindowScrollBarX from "./getWindowScrollBarX.js";
|
||
|
import getWindowScroll from "./getWindowScroll.js";
|
||
|
import { max } from "../utils/math.js"; // Gets the entire size of the scrollable document area, even extending outside
|
||
|
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
||
|
|
||
|
export default function getDocumentRect(element) {
|
||
|
var _element$ownerDocumen;
|
||
|
|
||
|
var html = getDocumentElement(element);
|
||
|
var winScroll = getWindowScroll(element);
|
||
|
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
||
|
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
||
|
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
||
|
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
||
|
var y = -winScroll.scrollTop;
|
||
|
|
||
|
if (getComputedStyle(body || html).direction === 'rtl') {
|
||
|
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
width: width,
|
||
|
height: height,
|
||
|
x: x,
|
||
|
y: y
|
||
|
};
|
||
|
}
|