UNPKG

@base-ui/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.

21 lines (19 loc) 593 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOffset = getOffset; function getOffset(element, prop, axis) { if (!element) { return 0; } const styles = getComputedStyle(element); const key = `${prop}${axis === 'x' ? 'Inline' : 'Block'}`; const start = parseFloat(styles[`${key}Start`]); // Safari misreports `marginInlineEnd` in RTL. // We have to assume the start/end values are symmetrical, which is likely. if (axis === 'x' && prop === 'margin') { return start * 2; } return start + parseFloat(styles[`${key}End`]); }