UNPKG

@primer/react-brand

Version:

Primer Brand is a GitHub's design system for creating React-based marketing websites and digital experiences.

25 lines (24 loc) 728 B
import { useResizeObserver as e } from "./useResizeObserver.js"; import { useCallback as t, useEffect as n, useState as r } from "react"; import { getAnchoredPosition as i } from "@primer/behaviors"; //#region src/hooks/useAnchoredPosition.ts function a(a, o = []) { let s = a?.floatingElementRef, c = a?.anchorElementRef, [l, u] = r(void 0), d = t(() => { s.current instanceof Element && c.current instanceof Element ? u(i(s.current, c.current, { side: a?.side, align: a?.align })) : u(void 0); }, [ s, c, ...o ]); return n(d, [d]), e(d), { floatingElementRef: s, anchorElementRef: c, position: l }; } //#endregion export { a as useAnchoredPosition }; //# sourceMappingURL=useAnchoredPosition.js.map