@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
15 lines (14 loc) • 416 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getOffset = getOffset;
function getOffset(element, prop, axis) {
if (!element) {
return 0;
}
const styles = getComputedStyle(element);
const start = axis === 'x' ? 'Left' : 'Top';
const end = axis === 'x' ? 'Right' : 'Bottom';
return parseFloat(styles[`${prop}${start}`]) + parseFloat(styles[`${prop}${end}`]);
}
;