UNPKG

@zag-js/dom-query

Version:

The dom helper library for zag.js machines

18 lines (16 loc) 580 B
import "./chunk-QZ7TP4HQ.mjs"; // src/scale.ts function getScale(element) { const rect = element.getBoundingClientRect(); const offsetWidth = element.offsetWidth; const offsetHeight = element.offsetHeight; const hasTransform = Math.round(rect.width) !== offsetWidth || Math.round(rect.height) !== offsetHeight; let x = hasTransform ? Math.round(rect.width) / offsetWidth : 1; let y = hasTransform ? Math.round(rect.height) / offsetHeight : 1; if (!x || !Number.isFinite(x)) x = 1; if (!y || !Number.isFinite(y)) y = 1; return { x, y }; } export { getScale };