UNPKG

@infinityfx/lively

Version:

Feature complete, lightweight react animation library.

4 lines (3 loc) 1.09 kB
"use client"; import{__rest as t}from"tslib";import{jsx as e}from"react/jsx-runtime";import{use as r,useRef as n,useLayoutEffect as o}from"react";import i,{AnimatableContext as u}from"../animatable.js";import{combineRefs as s}from"../core/utils.js";const a={};function m(m){var{children:l,group:c,transition:d}=m,f=t(m,["children","group","transition"]);const p=r(u),g=(null==p?void 0:p.group)?`${p.group}.${c}`:c;g in a||(a[g]=new Map);const v=n(null);return o((()=>{var t,e;const r=null===(t=v.current)||void 0===t?void 0:t.timeline;if(!r)return;if(a[g].has(r)){a[g].get(r).state="mounted"}else a[g].set(r,{state:"mounted"});const n=Array.from(a[g].entries()).find((([t,e])=>"unmounted"===e.state));return n&&!r.mounted?(r.transition(n[0],d),n[1].state="collected"):r.mounted||null===(e=v.current)||void 0===e||e.trigger("mount"),r.mounted=!0,()=>{const t=a[g].get(r);t.state="unmounted",setTimeout((()=>t.state="collected"),1)}}),[]),e(i,Object.assign({},f,{group:g,manual:!0,ref:s(v,f.ref),children:l}))}m.isLively=!0;export{a as Groups,m as default}; //# sourceMappingURL=morph.js.map