UNPKG

@vuesax-alpha/nightly

Version:
29 lines (26 loc) 806 B
import { createCoords, round } from '../../utils/index.mjs'; import { isHTMLElement } from '../../utils/dom.mjs'; import { unwrapElement } from '../utils/unwrap-element.mjs'; import { getCssDimensions } from '../utils/get-css-demenssions.mjs'; function getScale(element) { const domElement = unwrapElement(element); if (!isHTMLElement(domElement)) { return createCoords(1); } const rect = domElement.getBoundingClientRect(); const { width, height, $ } = getCssDimensions(domElement); let x = ($ ? round(rect.width) : rect.width) / width; let y = ($ ? round(rect.height) : rect.height) / height; if (!x || !Number.isFinite(x)) { x = 1; } if (!y || !Number.isFinite(y)) { y = 1; } return { x, y }; } export { getScale }; //# sourceMappingURL=get-scale.mjs.map