Add supporting themes required for Lotusdocs
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { isHTMLElement } from "./instanceOf.js";
|
||||
import { round } from "../utils/math.js";
|
||||
export default function getBoundingClientRect(element, includeScale) {
|
||||
if (includeScale === void 0) {
|
||||
includeScale = false;
|
||||
}
|
||||
|
||||
var rect = element.getBoundingClientRect();
|
||||
var scaleX = 1;
|
||||
var scaleY = 1;
|
||||
|
||||
if (isHTMLElement(element) && includeScale) {
|
||||
var offsetHeight = element.offsetHeight;
|
||||
var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
|
||||
// Fallback to 1 in case both values are `0`
|
||||
|
||||
if (offsetWidth > 0) {
|
||||
scaleX = round(rect.width) / offsetWidth || 1;
|
||||
}
|
||||
|
||||
if (offsetHeight > 0) {
|
||||
scaleY = round(rect.height) / offsetHeight || 1;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
width: rect.width / scaleX,
|
||||
height: rect.height / scaleY,
|
||||
top: rect.top / scaleY,
|
||||
right: rect.right / scaleX,
|
||||
bottom: rect.bottom / scaleY,
|
||||
left: rect.left / scaleX,
|
||||
x: rect.left / scaleX,
|
||||
y: rect.top / scaleY
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user