UNPKG

1.41 kBJavaScriptView Raw
1import{jsx as r}from"react/jsx-runtime";import{useRef as e,useCallback as t,useEffect as n,Fragment as c,createRef as o}from"react";import u from"animejs";export{default as anime}from"animejs";function l(){return(l=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}function i(r){const e=[];return a(r,e),e}function a(r,e){for(let t=0;t<r.length;t++){const n=r[t];Array.isArray(n)?a(n,e):e.push(n)}}function s(a){const s=e([]),f=e([]),m=e([]),p=e(new Set),h=()=>{for(let r of s.current)r.completed&&(s.current=s.current.filter(e=>e!=r));f.current=f.current.filter(r=>null!=r&&null!=r),m.current=m.current.filter(r=>r&&null!=r.current)},d=t(()=>{(r=>{h(),f.current.length>0&&u.remove(f),f.current=[];for(let r of m.current)r.current&&!p.current.has(r.current)&&f.current.push(r.current);const e=l({},r,{targets:f.current,complete:e=>{r.complete&&r.complete(e),e.animatables.map(r=>p.current.add(r.target)),h()}});delete e.children,s.current.push(u(e))})(a)},[a]);n(()=>{d()},[d]);const g=m.current;let y=Array.isArray(a.children)?a.children:[a.children];return y=i(y),r(c,{children:y.map((e,t)=>(g.push(o()),r(a.component?a.component:"div",Object.assign({ref:g[g.length-1]},{children:e}),`__anime__${t}`)))},void 0)}export default s;
2//# sourceMappingURL=react-anime.modern.js.map