UNPKG

@ssgoi/react

Version:

React bindings for SSGOI - Native app-like page transitions for React applications

39 lines (38 loc) 889 B
"use client"; import { jsx as g } from "react/jsx-runtime"; import { useRef as n } from "react"; import { transition as y } from "./transition.js"; import { useSsgoi as d } from "./context.js"; import { forkStyleFromElement as b, combineRefs as x } from "./utils.js"; const C = ({ children: s, id: o, as: c, className: f, ...l }) => { const { getTransition: u, getInitialStyle: m } = d(), a = c || "div", r = n(null), i = n(!0), t = n(null); t.current === null && (t.current = m()); let e; i.current ? e = t.current : r.current && t.current && (e = b( r.current, t.current )); const R = y(u(o)), p = x((S) => { r.current = S, i.current = !1; }, R); return /* @__PURE__ */ g( a, { ref: p, "data-ssgoi-transition": o, className: f, style: e, ...l, children: s } ); }; export { C as SsgoiTransition };