@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
25 lines • 789 B
JavaScript
import { isClientRectVisualViewportBased } from './is.utils';
export const getViewportRect = (strategy) => {
const html = window.document.documentElement;
const visualViewport = window.visualViewport;
let width = html.clientWidth;
let height = html.clientHeight;
let x = 0;
let y = 0;
if (visualViewport) {
width = visualViewport.width;
height = visualViewport.height;
const visualViewportBased = isClientRectVisualViewportBased();
if (!visualViewportBased || (visualViewportBased && strategy === 'fixed')) {
x = visualViewport.offsetLeft;
y = visualViewport.offsetTop;
}
}
return {
width,
height,
x,
y,
};
};
//# sourceMappingURL=getViewportRect.js.map