@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
25 lines (22 loc) • 763 B
JavaScript
import { round } from '../../utils/index.mjs';
import { isHTMLElement } from '../../utils/dom.mjs';
function getCssDimensions(element) {
const css = getComputedStyle(element);
let width = Number.parseFloat(css.width) || 0;
let height = Number.parseFloat(css.height) || 0;
const hasOffset = isHTMLElement(element);
const offsetWidth = hasOffset ? element.offsetWidth : width;
const offsetHeight = hasOffset ? element.offsetHeight : height;
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
if (shouldFallback) {
width = offsetWidth;
height = offsetHeight;
}
return {
width,
height,
$: shouldFallback
};
}
export { getCssDimensions };
//# sourceMappingURL=get-css-demenssions.mjs.map