UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

37 lines (36 loc) 1.38 kB
import { jsx as s } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import { useState as c, useCallback as g, useEffect as v } from "../../../external/preact/hooks/dist/hooks.module.js"; import { PopoverContainerPosition as P } from "./types.js"; import m from "./Popover.js"; /* empty css */ function S(t) { var r; const [p, f] = c(performance.now()), [u, d] = c(), i = g( (n) => n && t.fixedPositioning ? n.scrollHeight > n.offsetHeight : !1, [t.fixedPositioning] ), o = (r = t.targetElement.current) == null ? void 0 : r.offsetParent; return v(() => { if (!i(o)) return; const { height: n, y: l } = o.getBoundingClientRect(); d({ minY: l, maxY: l + n }); let e = null; const a = () => { e && cancelAnimationFrame(e), e = requestAnimationFrame(() => { e = null, f(performance.now()); }); }; return o.addEventListener("scroll", a, { passive: !0 }), () => { o.removeEventListener("scroll", a), e && cancelAnimationFrame(e), e = null; }; }, [o, i]), t.fixedPositioning ? ( // TODO: - Consider using same position from parent element // - Consider adding position prop to components using Popover /* @__PURE__ */ s(m, { ...t, position: P.BOTTOM, additionalStyle: u }) ) : /* @__PURE__ */ s(m, { ...t }); } export { S as default };