MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getOffset

Function getOffset

packages/react-aria/src/utils/getOffset.ts:15–25  ·  view source on GitHub ↗
(
  element: HTMLElement,
  reverse?: boolean,
  orientation: Orientation = 'horizontal'
)

Source from the content-addressed store, hash-verified

13import {Orientation} from '@react-types/shared';
14
15export function getOffset(
16 element: HTMLElement,
17 reverse?: boolean,
18 orientation: Orientation = 'horizontal'
19): number {
20 let rect = element.getBoundingClientRect();
21 if (reverse) {
22 return orientation === 'horizontal' ? rect.right : rect.bottom;
23 }
24 return orientation === 'horizontal' ? rect.left : rect.top;
25}

Callers 1

getNextOffsetFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected