@infinityfx/lively 5.0.0-alpha.5 → 5.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animate.js +1 -1
- package/dist/core/animation-link.js.map +1 -1
- package/dist/core/animator.js +1 -1
- package/dist/core/animator.js.map +1 -1
- package/dist/core/clip.js +1 -1
- package/dist/core/clip.js.map +1 -1
- package/dist/core/track.js +1 -1
- package/dist/core/track.js.map +1 -1
- package/dist/core/utils.js +1 -1
- package/dist/layout-group.js +1 -1
- package/dist/types/core/animation-link.d.ts +2 -1
- package/dist/types/core/animator.d.ts +2 -0
- package/dist/types/core/clip.d.ts +2 -1
- package/dist/types/core/track.d.ts +1 -0
- package/package.json +1 -1
package/dist/animate.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t}from"react/jsx-runtime";import{createContext as n,useId as e,use as r,useRef as i,useImperativeHandle as o,useLayoutEffect as s,useEffect as a,Children as c,isValidElement as m,cloneElement as
|
|
2
|
+
import{jsx as t}from"react/jsx-runtime";import{createContext as n,useId as e,use as r,useRef as i,useImperativeHandle as o,useLayoutEffect as s,useEffect as a,Children as c,isValidElement as m,cloneElement as u}from"react";import d from"./core/animator.js";import l from"./core/clip.js";import{serializeTriggers as f,getLifeCycleAnimations as p,forEachTrigger as g,mergeStyles as y,getInitialStyleFromLinks as h,mergeRefs as j}from"./core/utils.js";import{LayoutGroupContext as k}from"./layout-group.js";import{registerToLayoutGroup as w,getMorphTarget as v,deleteMorphTarget as L,unregisterFromLayoutGroup as E}from"./core/state.js";const C=n("");function b({ref:n,children:b,inherit:x=!1,initial:z={},animate:A={},triggers:D={animate:["mount"]},stagger:I=.07,staggerLimit:S=10,deformCorrection:T,transition:_,morph:M,clips:O,paused:P=!1,onAnimationEnd:q}){const B=D._livelyId??"_la"+e(),F=r(C),G=r(k),H=i(0),J=i(w(G,B)),K=i(null),N=i(f(D)),Q=i(null);if(!Q.current){const t={animate:A instanceof l?A:new l(A,z)};for(const n in O)t[n]=O[n]instanceof l?O[n]:new l(O[n],z);const n=Q.current=new d({id:B,clips:t,lifeCycleAnimations:p(D),deformCorrection:T,transition:_,stagger:I,staggerLimit:S});n.register(F,x,M),n.addLinks(A)}const{current:R}=Q;return o(n,(()=>R),[]),s((()=>{if(H.current=Date.now(),R.register(F,x,M),R.addLinks(A),M){const t=K.current||v(M,B);K.current=t,t&&(R.isMounting=!0,R.transition(t),L(M,t.id),R.state="mounted",t.hide())}w(G,B),J.current&&(R.state="mounted"),document.fonts.ready.finally((()=>R.mount()));const t=()=>R.forEachTrack((t=>t.snapshot()));return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),R.dispose(M),E(G,B)}}),[]),a((()=>{g(D,((t,n,e)=>{const r=N.current[t];n.forEach(((n,i)=>{r[i]!==n&&!1!==n&&R.play(t,Object.assign({tag:t},e[i])),r[i]=n}))}))}),[D]),a((()=>{if(!(A instanceof l||"mounted"!==R.state))for(const t in A){const n=A[t];t in R.links&&"object"!=typeof n&&R.links[t].set(n,{duration:A.duration,easing:A.easing})}}),[A]),a((()=>(q&&R.on("animationend",q),()=>{q&&R.off("animationend",q)})),[q]),a((()=>R.setPlayState(P)),[P]),t(C,{value:B,children:c.map(b,((t,n)=>{if(!m(t))return t;let{ref:e,style:r}=t.props;return r=y(r,R.mergeInitialStyles(z,J.current?"mounted":"unmounted"),h(R.links,n)),u(t,{ref:j(e||null,(t=>R.addTrack(t,n))),style:r,pathLength:"strokeDasharray"in r?1:void 0,"data-lively":B})}))})}export{C as AnimateContext,b as default};
|
|
3
3
|
//# sourceMappingURL=animate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-link.js","sources":["../../src/core/animation-link.ts"],"sourcesContent":[null],"names":["AnimationLink","constructor","initial","getWithIndex","this","options","duration","eventListeners","value","set","Object","assign","dispatch","get","index","on","event","callback","Set","add","delete","forEach"],"mappings":"
|
|
1
|
+
{"version":3,"file":"animation-link.js","sources":["../../src/core/animation-link.ts"],"sourcesContent":[null],"names":["AnimationLink","constructor","initial","getWithIndex","this","options","duration","eventListeners","value","set","Object","assign","dispatch","get","index","on","event","callback","Set","add","delete","forEach"],"mappings":"AAUc,MAAOA,EAWjB,WAAAC,CAAYC,EAAYC,GARxBC,KAAAC,QAA6B,CACzBC,SAAU,IAGdF,KAAAG,eAEI,CAAA,EAGAH,KAAKI,MAAQN,EACbE,KAAKD,aAAeA,QAAuBC,KAAKI,MACpD,CAEA,GAAAC,CAAID,EAAUH,EAA6B,IACvCD,KAAKI,MAAQA,EACbE,OAAOC,OAAOP,KAAKC,QAASA,GAE5BD,KAAKQ,SAAS,SAClB,CAEA,GAAAC,CAAIC,EAAQ,GACR,OAAOV,KAAKD,aAAaW,EAC7B,CAEA,EAAAC,CAAGC,EAA2BC,GAK1B,OAJMD,KAASZ,KAAKG,iBAAiBH,KAAKG,eAAeS,GAAS,IAAIE,KAEtEd,KAAKG,eAAeS,GAAQG,IAAIF,GAEzB,KACHb,KAAKG,eAAeS,IAAQI,OAAOH,EAAS,CAEpD,CAEA,QAAAL,CAASI,GACLZ,KAAKG,eAAeS,IAAQK,SAAQJ,GAAYA,EAASb,KAAKI,QAClE"}
|
package/dist/core/animator.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"./clip.js";import{registerAnimator as i,registerAsMorph as s,getParentAnimator as e,unregisterAnimator as a,deleteMorphTarget as n}from"./state.js";import
|
|
1
|
+
import t from"./clip.js";import{registerAnimator as i,registerAsMorph as s,getParentAnimator as e,unregisterAnimator as a,deleteMorphTarget as n}from"./state.js";import h from"./track.js";import{extractAnimationLinks as r}from"./utils.js";class o{constructor({id:t,clips:i,lifeCycleAnimations:s,deformCorrection:e,transition:a,stagger:n,staggerLimit:h}){this.parent=null,this.dependents=new Set,this.inherit=[],this.links={},this.onDisposeLinks=null,this.tracks=new Set,this.trackList=[],this.initialStyles={},this.eventListeners={},this.state="unmounted",this.isMounting=!0,this.paused=!1,this.timeout=0,this.frame=0;const{cache:r,...o}=a||{};this.id=t,this.clips=i,this.lifeCycleAnimations=s,this.ignoreScaleDeformation=void 0!==e&&!e,this.defaultTransitionOptions=o,this.cache=r||["x","y","sx","sy","rotate","borderRadius"],this.align="object"==typeof e?e:{x:"left",y:"top"},this.stagger=n,this.staggerLimit=h,void 0===e&&this.inherit.push("ignoreScaleDeformation"),void 0===e&&this.inherit.push("align"),a||this.inherit.push("defaultTransitionOptions"),r||this.inherit.push("cache")}register(t,a,n){if(clearTimeout(this.timeout),i(this.id,this),n&&s(n,this.id),t&&!1!==a&&(this.parent=e(t,"boolean"==typeof a?0:a)),this.parent){this.parent.dependents.add(this);for(const t of this.inherit)this[t]=this.parent[t]}}mount(){"unmounted"===this.state&&this.trigger("mount"),this.state="mounted",cancelAnimationFrame(this.frame),this.tick()}dispose(t){this.onDisposeLinks?.(),cancelAnimationFrame(this.frame),this.trackList.forEach((t=>t.cache=t.snapshot())),this.state="unmounted",this.stop(),this.timeout=setTimeout((()=>{a(this.id),t&&n(t,this.id),this.parent&&this.parent.dependents.delete(this)}),1)}on(t,i){t in this.eventListeners||(this.eventListeners[t]=new Set),this.eventListeners[t].add(i)}off(t,i){this.eventListeners[t]?.delete(i)}dispatch(t,...i){this.eventListeners[t]?.forEach((t=>t(...i)))}tick(){this.paused||this.trackList.forEach((t=>{this.ignoreScaleDeformation||t.correct()})),this.frame=requestAnimationFrame(this.tick.bind(this))}addLinks(i){const[s,e]=r(i,((i,s)=>{this.forEachTrack(((e,a)=>{const n=new t({...s.options,composite:"override",[i]:s.get(a)});e.push(n)}))}));this.links=s,this.onDisposeLinks=e}addTrack(t,i){if(!(t instanceof HTMLElement||t instanceof SVGElement)||this.tracks.has(t))return;const s=new h(t,this.cache,this.align),e=this.lifeCycleAnimations.mount;this.tracks.add(t),this.trackList.splice(i,0,s),"mounted"===this.state&&e&&e.forEach((([t,i])=>s.push(this.clips[t],i)))}mergeInitialStyles(i,s){if(s in this.initialStyles)return this.initialStyles[s];const e=(this.lifeCycleAnimations.mount||[]).map((([t])=>this.clips[t])).filter((t=>!t.isEmpty));return e.length?i=t.mergeInitialStyles(e,i,"mounted"===s):this.parent&&(i=this.parent.mergeInitialStyles(i,s)),this.initialStyles[s]=i}pretime(t,i){if(t.isEmpty)return 0;const{duration:s,delay:e,iterations:a}=t.getConfig(i);return(s*a+e)/1e3+Math.max(Math.min(this.tracks.size,this.staggerLimit)-1,0)*this.stagger}trigger(t,i={}){let s=this.lifeCycleAnimations[t],e=0;return s&&s.forEach((([t,s])=>e=Math.max(this.play(t,Object.assign(s,i)),e))),e}play(t,{cascade:i="forward",delay:s=0,tag:e,...a}={}){if(this.paused||this.parent&&!e)return 0;let n="string"==typeof t?this.clips[t]:t;e&&e in this.clips&&(n=this.clips[e]),e||"string"!=typeof t||(e=t);const h=this.pretime(n,a),r=this.cascade(n,{...a,delay:"reverse"===i?s:h+s,tag:e});return this.push(n,{...a,delay:"reverse"===i?r+s:s,tag:e})}cascade(t,i){let s=0;return this.dependents.forEach((e=>{s=Math.max(s,e.play(t,i))})),s}forEachTrack(t){let i=0;for(;i<this.tracks.size;){const s=this.trackList[i];s.element.isConnected?t(s,i++):(this.tracks.delete(s.element),this.trackList.splice(i,1))}}push(t,{override:i,delay:s=0,tag:e,...a}){if(t.isEmpty)return 0;let n=0;return this.forEachTrack(((h,r)=>{i&&h.clear();const o=h.push(t,{...a,delay:s+Math.min(r,this.staggerLimit-1)*this.stagger},r===this.tracks.size-1?()=>this.dispatch("animationend",e):void 0);n=Math.max(n,o)})),n}transition(t,i=this.defaultTransitionOptions){this.paused||(this.trackList.forEach(((s,e)=>{const{cache:a}=t&&e<t.tracks.size?t.trackList[e]:{};s.transition(a,i)})),this.dispatch("transitionstart"))}setPlayState(t){this.trackList.forEach((i=>i.toggle(t))),this.paused=t,this.dependents.forEach((i=>i.setPlayState(t)))}stop(t){this.trackList.forEach((i=>i.clear(t)))}hide(){this.trackList.forEach((t=>t.element.style.visibility="hidden"))}}export{o as default};
|
|
2
2
|
//# sourceMappingURL=animator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animator.js","sources":["../../src/core/animator.ts"],"sourcesContent":[null],"names":["Animator","constructor","id","clips","lifeCycleAnimations","deformCorrection","transition","stagger","staggerLimit","this","parent","dependents","Set","inherit","links","onDisposeLinks","tracks","trackList","initialStyles","eventListeners","state","paused","timeout","frame","cache","options","ignoreScaleDeformation","undefined","defaultTransitionOptions","align","x","y","push","register","parentId","morph","clearTimeout","registerAnimator","registerAsMorph","getParentAnimator","add","key","mount","trigger","cancelAnimationFrame","tick","dispose","
|
|
1
|
+
{"version":3,"file":"animator.js","sources":["../../src/core/animator.ts"],"sourcesContent":[null],"names":["Animator","constructor","id","clips","lifeCycleAnimations","deformCorrection","transition","stagger","staggerLimit","this","parent","dependents","Set","inherit","links","onDisposeLinks","tracks","trackList","initialStyles","eventListeners","state","isMounting","paused","timeout","frame","cache","options","ignoreScaleDeformation","undefined","defaultTransitionOptions","align","x","y","push","register","parentId","morph","clearTimeout","registerAnimator","registerAsMorph","getParentAnimator","add","key","mount","trigger","cancelAnimationFrame","tick","dispose","forEach","track","snapshot","stop","setTimeout","unregisterAnimator","deleteMorphTarget","delete","on","event","callback","off","dispatch","args","correct","requestAnimationFrame","bind","addLinks","animate","disposeLinks","extractAnimationLinks","link","forEachTrack","i","clip","Clip","composite","get","addTrack","element","index","HTMLElement","SVGElement","has","Track","animations","splice","name","mergeInitialStyles","styles","mode","map","filter","isEmpty","length","pretime","duration","delay","iterations","getConfig","Math","max","min","size","elapsed","opts","play","Object","assign","animation","cascade","tag","cascadeDelay","animator","isConnected","override","clear","added","from","setPlayState","toggle","hide","style","visibility"],"mappings":"+OAmBc,MAAOA,EAqCjB,WAAAC,EAAYC,GAAEA,EAAEC,MAAEA,EAAKC,oBAAEA,EAAmBC,iBAAEA,EAAgBC,WAAEA,EAAUC,QAAEA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C,GAAI8C,EAAKmB,QAAS,OAAO,EAEzB,IAAIW,EAAU,EAYd,OAXA7F,KAAK6D,cAAa,CAACrB,EAAOsB,KAClB0C,GAAUhE,EAAMiE,QAEpB,MAAMC,EAAQlE,EAAMhB,KAAKuC,EAAM,IACxB9C,EACHqE,MAAOA,EAAQG,KAAKE,IAAI7B,EAAG9D,KAAKD,aAAe,GAAKC,KAAKF,SAC1DgE,IAAM9D,KAAKO,OAAOqF,KAAO,EAAI,IAAM5F,KAAKmD,SAAS,eAAgBiD,QAAOjF,GAE3E0E,EAAUJ,KAAKC,IAAIG,EAASa,EAAM,IAG/Bb,CACX,CAEA,UAAAhG,CAAW8G,EAAsB1F,EAA6BjB,KAAKoB,0BAC3DpB,KAAKa,SAETb,KAAKQ,UAAU+B,SAAQ,CAACC,EAAOsB,KAC3B,MAAM9C,MAAEA,GAAU2F,GAAQ7C,EAAI6C,EAAKpG,OAAOqF,KAAOe,EAAKnG,UAAUsD,GAAK,CAAA,EAErEtB,EAAM3C,WAAWmB,EAAOC,EAAQ,IAGpCjB,KAAKmD,SAAS,mBAClB,CAEA,YAAAyD,CAAa/F,GACTb,KAAKQ,UAAU+B,SAAQC,GAASA,EAAMqE,OAAOhG,KAC7Cb,KAAKa,OAASA,EAEdb,KAAKE,WAAWqC,SAAQ+D,GAAYA,EAASM,aAAa/F,IAC9D,CAEA,IAAA6B,CAAKwD,GACDlG,KAAKQ,UAAU+B,SAAQC,GAASA,EAAMiE,MAAMP,IAChD,CAEA,IAAAY,GACI9G,KAAKQ,UAAU+B,SAAQC,GAASA,EAAM4B,QAAQ2C,MAAMC,WAAa,UACrE"}
|
package/dist/core/clip.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{parseClipKeyframes as e}from"./utils.js";class t{constructor({duration:t=.5,delay:s=0,repeat:i=1,alternate:a=!1,reverse:r=!1,easing:n="ease",composite:o="none",...l},c={}){this.duration=t,this.delay=s,this.repeat=i,this.alternate=a,this.reverse=r,this.easing=n,this.composite=o,this.keyframes=e(l,c),this.isEmpty=!this.keyframes.length}getConfig({delay:e=0,repeat:t=this.repeat,alternate:s=this.alternate,reverse:i=this.reverse,composite:a=this.composite,commit:r=!0}){return{duration:1e3*this.duration,delay:1e3*(this.delay+e),iterations:t,
|
|
1
|
+
import{parseClipKeyframes as e}from"./utils.js";class t{constructor({duration:t=.5,delay:s=0,repeat:i=1,alternate:a=!1,reverse:r=!1,easing:n="ease",composite:o="none",...l},c={}){this.duration=t,this.delay=s,this.repeat=i,this.alternate=a,this.reverse=r,this.easing=n,this.composite=o,this.keyframes=e(l,c),this.isEmpty=!this.keyframes.length}getConfig({delay:e=0,repeat:t=this.repeat,alternate:s=this.alternate,reverse:i=this.reverse,composite:a=this.composite,commit:r=!0}){return{duration:1e3*this.duration,delay:1e3*(this.delay+e),iterations:t,direction:s?i?"alternate-reverse":"alternate":i?"reverse":"normal",easing:this.easing,composite:"combine"===a?"accumulate":"replace",fill:"both",blendmode:a,commit:r}}static mergeInitialStyles(e,t,s=!1){const i={backfaceVisibility:"hidden",willChange:"transform"};for(const t of e){const e=s!==t.reverse?t.keyframes.length-1:0,{offset:a,...r}=t.keyframes[e];Object.assign(i,r)}return Object.assign(i,t)}}export{t as default};
|
|
2
2
|
//# sourceMappingURL=clip.js.map
|
package/dist/core/clip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip.js","sources":["../../src/core/clip.ts"],"sourcesContent":[null],"names":["Clip","constructor","duration","delay","repeat","alternate","reverse","easing","composite","keyframes","initial","this","parseClipKeyframes","isEmpty","length","getConfig","commit","iterations","
|
|
1
|
+
{"version":3,"file":"clip.js","sources":["../../src/core/clip.ts"],"sourcesContent":[null],"names":["Clip","constructor","duration","delay","repeat","alternate","reverse","easing","composite","keyframes","initial","this","parseClipKeyframes","isEmpty","length","getConfig","commit","iterations","direction","fill","blendmode","mergeInitialStyles","clips","styles","mounted","merged","backfaceVisibility","willChange","clip","index","offset","Object","ass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.js";import{clampLowerBound as e,correctForParentScale as s,scaleCorrectShadow as i,scaleCorrectRadius as n}from"./utils.js";class a{constructor(t,e,s){this.
|
|
1
|
+
import t from"./clip.js";import{clampLowerBound as e,correctForParentScale as s,scaleCorrectShadow as i,scaleCorrectRadius as n}from"./utils.js";class a{constructor(t,e,s){this.correctionAnimation=null,this.queue=[],this.animations=[],this.active=0,this.timeout=0,this.correctAfterEnded=!1,this.element=t,this.shouldCache=e,this.align=s,this.scale=this.getScale(),this.styles=getComputedStyle(t),this.cache=this.snapshot(),this.corrected={borderRadius:this.styles.borderRadius,boxShadow:this.styles.boxShadow}}getScale(){if(this.element instanceof SVGElement)return[1,1];const{width:t,height:s}=this.element.getBoundingClientRect();return[e(t/this.element.offsetWidth),e(s/this.element.offsetHeight)]}snapshot(){const t={x:0,y:0,sx:1,sy:1};if(this.element instanceof SVGElement)return t;for(const e of this.shouldCache)t[e]=this.styles[e];const{width:e,height:s,x:i,y:n}=this.element.getBoundingClientRect();t.sx=e,t.sy=s,t.x=i+e/2,t.y=n+s/2;let a=this.element;for(;a=a?.parentElement;)if(a.dataset.lively){const{x:e,y:s}=a.getBoundingClientRect();t.x-=e,t.y-=s;break}return t}push(t,e={},s){const{commit:i,blendmode:n,...a}=t.getConfig(e),o=this.element.animate(t.keyframes,a);return o.name=e.tag,o.blendmode=n,o.onfinish=()=>{try{i&&o.commitStyles()}catch{}finally{o.cancel(),this.advance(),s?.()}},this.active&&"none"===n?(o.pause(),this.queue.push(o),0):(this.animations.push(o),"none"===n&&this.active++,(a.duration*a.iterations+a.delay)/1e3)}advance(){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.cache=this.snapshot()),1/120),--this.active>0||(this.animations=this.animations.filter((t=>"running"===t.playState)),this.animations.push(...this.queue.splice(0,1)),this.active=this.animations.filter((t=>"none"===t.blendmode)).length,this.correctAfterEnded=!0)}transition(s=this.cache,i={}){const n=this.snapshot(),a={composite:"override",...i},o=[1,1],h=[0,0];for(const t of this.shouldCache)switch(t){case"x":case"y":h["x"===t?0:1]=s[t]-n[t];break;case"sx":case"sy":o["sx"===t?0:1]=s[t]/e(n[t]);break;default:a[t]=[s[t],n[t]]}[new t(a),new t({scale:[o.join(" "),null],translate:[h.map((t=>`${t}px`)).join(" "),null],composite:"combine",...i})].filter((t=>!t.isEmpty)).forEach((t=>this.push(t,{commit:!1}))),this.cache=n}clear(t){this.animations.forEach((e=>{if(!t||e.name===t){e.onfinish=null;try{e.finish()}catch{e.cancel()}}})),this.animations=this.animations.filter((t=>"running"===t.playState)),this.active=this.animations.filter((t=>"none"===t.blendmode)).length}toggle(t){this.animations.forEach((e=>e[t?"pause":"play"]()))}correct(){if(this.element instanceof SVGElement)return;const t=(/none|0px/.test(this.styles.translate)?"0 0":this.styles.translate).split(" ").map(parseFloat);if(s(this.element,t,this.align),!this.animations.length&&!this.correctAfterEnded)return;this.correctAfterEnded=!1,this.correctionAnimation?.cancel();const e=this.styles.borderRadius!==this.corrected.borderRadius?[1,1]:this.scale,a=this.styles.boxShadow!==this.corrected.boxShadow?[1,1]:this.scale;this.scale=this.getScale(),this.corrected={borderRadius:n(this.styles.borderRadius,this.scale,e),boxShadow:i(this.styles.boxShadow,this.scale,a)},this.corrected.borderRadius===this.styles.borderRadius&&this.corrected.boxShadow===this.styles.boxShadow||(this.correctionAnimation=this.element.animate(this.corrected,{duration:0,fill:"forwards"}))}}export{a as default};
|
|
2
2
|
//# sourceMappingURL=track.js.map
|
package/dist/core/track.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track.js","sources":["../../src/core/track.ts"],"sourcesContent":[null],"names":["Track","constructor","element","shouldCache","align","this","
|
|
1
|
+
{"version":3,"file":"track.js","sources":["../../src/core/track.ts"],"sourcesContent":[null],"names":["Track","constructor","element","shouldCache","align","this","correctionAnimation","queue","animations","active","timeout","correctAfterEnded","scale","getScale","styles","getComputedStyle","cache","snapshot","corrected","borderRadius","boxShadow","SVGElement","width","height","getBoundingClientRect","clampLowerBound","offsetWidth","offsetHeight","data","x","y","sx","sy","key","parent","parentElement","dataset","lively","push","clip","options","onEnded","commit","blendmode","config","getConfig","animation","animate","keyframes","name","tag","onfinish","commitStyles","cancel","advance","pause","duration","iterations","delay","clearTimeout","setTimeout","filter","playState","splice","length","transition","from","composite","translate","Clip","join","map","num","isEmpty","forEach","clear","entry","finish","toggle","paused","correct","offset","test","split","parseFloat","correctForParentScale","previousRadiusScale","previousShadowScale","scaleCorrectRadius","scaleCorrectShadow","fill"],"mappings":"iJA0Bc,MAAOA,EAmBjB,WAAAC,CAAYC,EAAmCC,EAAyBC,GAPxEC,KAAAC,oBAAwC,KACxCD,KAAAE,MAA0B,GAC1BF,KAAAG,WAA+B,GAC/BH,KAAAI,OAAS,EACTJ,KAAAK,QAAU,EACVL,KAAAM,mBAAoB,EAGhBN,KAAKH,QAAUA,EACfG,KAAKF,YAAcA,EACnBE,KAAKD,MAAQA,EAEbC,KAAKO,MAAQP,KAAKQ,WAClBR,KAAKS,OAASC,iBAAiBb,GAC/BG,KAAKW,MAAQX,KAAKY,WAClBZ,KAAKa,UAAY,CACbC,aAAcd,KAAKS,OAAOK,aAC1BC,UAAWf,KAAKS,OAAOM,UAE/B,CAEA,QAAAP,GACI,GAAIR,KAAKH,mBAAmBmB,WAAY,MAAO,CAAC,EAAG,GAEnD,MAAMC,MAAEA,EAAKC,OAAEA,GAAWlB,KAAKH,QAAQsB,wBAEvC,MAAO,CACHC,EAAgBH,EAAQjB,KAAKH,QAAQwB,aACrCD,EAAgBF,EAASlB,KAAKH,QAAQyB,cAE9C,CAEA,QAAAV,GACI,MAAMW,EAAmB,CAAEC,EAAG,EAAGC,EAAG,EAAGC,GAAI,EAAGC,GAAI,GAClD,GAAI3B,KAAKH,mBAAmBmB,WAAY,OAAOO,EAG/C,IAAK,MAAMK,KAAO5B,KAAKF,YAAayB,EAAKK,GAAO5B,KAAKS,OAAOmB,GAE5D,MAAMX,MAAEA,EAAKC,OAAEA,EAAMM,E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AUiC,EAAS,QAAU,WACtE,CAEA,OAAAC,GACI,GAAI3E,KAAKH,mBAAmBmB,WAAY,OAExC,MAAM4D,GAAe,WAAWC,KAAK7E,KAAKS,OAAOsD,WAAa,MAAQ/D,KAAKS,OAAOsD,WAAWe,MAAM,KAAKZ,IAAIa,YAG5G,GAFAC,EAAsBhF,KAAKH,QAAS+E,EAAQ5E,KAAKD,QAE5CC,KAAKG,WAAWwD,SAAW3D,KAAKM,kBAAmB,OACxDN,KAAKM,mBAAoB,EAEzBN,KAAKC,qBAAqB+C,SAC1B,MAAMiC,EAAkCjF,KAAKS,OAAOK,eAAiBd,KAAKa,UAAUC,aAAe,CAAC,EAAG,GAAKd,KAAKO,MAC3G2E,EAAkClF,KAAKS,OAAOM,YAAcf,KAAKa,UAAUE,UAAY,CAAC,EAAG,GAAKf,KAAKO,MAE3GP,KAAKO,MAAQP,KAAKQ,WAElBR,KAAKa,UAAY,CACbC,aAAcqE,EAAmBnF,KAAKS,OAAOK,aAAcd,KAAKO,MAAO0E,GACvElE,UAAWqE,EAAmBpF,KAAKS,OAAOM,UAAWf,KAAKO,MAAO2E,IAGjElF,KAAKa,UAAUC,eAAiBd,KAAKS,OAAOK,cAC5Cd,KAAKa,UAAUE,YAAcf,KAAKS,OAAOM,YAAWf,KAAKC,oBAAsBD,KAAKH,QAAQ6C,QAAQ1C,KAAKa,UAAW,CAChHsC,SAAU,EACVkC,KAAM,aAElB"}
|
package/dist/core/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isValidElement as t}from"react";import n from"./clip.js";import e from"./animation-link.js";import{getParentAnimator as o}from"./state.js";const r=1e-4;function s(t,n=8){const e=1/Math.pow(10,n);return isNaN(t)?e:(t<0?-1:1)*Math.max(Math.abs(t),e)}const i=t=>Array.isArray(t)?t:[t];function f(...t){return n=>{t.forEach((t=>{t&&"current"in t&&(t.current=n),t instanceof Function&&t(n)}))}}function c(...t){const n={};for(const e of t)Object.assign(n,e);return"strokeLength"in n&&(n.strokeDashoffset=2-n.strokeLength,delete n.strokeLength),"strokeDashoffset"in n&&(n.strokeDasharray=2),n}function a(t,n){for(const e in t){if("_livelyId"===e)continue;const o=[];n(e,t[e].map((t=>{const{on:n,...e}="object"==typeof t&&"on"in t?t:{on:t};return o.push(e),n})),o)}}function u(t){const n={};return a(t,((t,e)=>{n[t]=e})),n}function l(t){const n={};return a(t,((t,e,o)=>{["mount","unmount"].forEach((r=>{const s=e.indexOf(r);s<0||(r in n||(n[r]=[]),n[r].push([t,o[s]]))}))})),n}function h(t){let n,e=[],o=0;for(let s=0;s<t.length;s++){const i=t[s],f=Math.round(s/(t.length-1)/r)*r;if(null===i)continue;const c="object"!=typeof i?{offset:f,to:i}:i;"offset"in c||(c.offset=f),e.push(c);const a=c.to
|
|
1
|
+
import{isValidElement as t}from"react";import n from"./clip.js";import e from"./animation-link.js";import{getParentAnimator as o}from"./state.js";const r=1e-4;function s(t,n=8){const e=1/Math.pow(10,n);return isNaN(t)?e:(t<0?-1:1)*Math.max(Math.abs(t),e)}const i=t=>Array.isArray(t)?t:[t];function f(...t){return n=>{t.forEach((t=>{t&&"current"in t&&(t.current=n),t instanceof Function&&t(n)}))}}function c(...t){const n={};for(const e of t)Object.assign(n,e);return"strokeLength"in n&&(n.strokeDashoffset=2-n.strokeLength,delete n.strokeLength),"strokeDashoffset"in n&&(n.strokeDasharray=2),n}function a(t,n){for(const e in t){if("_livelyId"===e)continue;const o=[];n(e,t[e].map((t=>{const{on:n,...e}="object"==typeof t&&"on"in t?t:{on:t};return o.push(e),n})),o)}}function u(t){const n={};return a(t,((t,e)=>{n[t]=e})),n}function l(t){const n={};return a(t,((t,e,o)=>{["mount","unmount"].forEach((r=>{const s=e.indexOf(r);s<0||(r in n||(n[r]=[]),n[r].push([t,o[s]]))}))})),n}function h(t){let n,e=[],o=0;for(let s=0;s<t.length;s++){const i=t[s],f=Math.round(s/(t.length-1)/r)*r;if(null===i)continue;const c="object"!=typeof i?{offset:f,to:i}:i;"offset"in c||(c.offset=f),e.push(c);const a=c.to??c.after;n===a&&o++,n=a}return o===e.length?null:e}function p(t,n,e,o){t.has(n)||t.set(n,{offset:n});const r=t.get(n);if("strokeLength"===e)return r.strokeDashoffset=2-o;r[e]=o}function g(t,n){const o=new Map;for(const s in t){const i=t[s];if(i instanceof e)continue;const f=Array.isArray(i)?i:[i];f.length<2&&f.unshift(n[s]??null);const c=h(f);if(c)for(let{to:t,after:n,offset:e}of c)void 0!==n&&(1===e&&(e-=r),p(o,e+r,s,n)),void 0!==t&&p(o,e,s,t)}return Array.from(o.values()).sort(((t,n)=>t.offset-n.offset))}function m(t,n,e){if(/^\s*$|0px/.test(t))return t;const o=t.split(/\s*\/\s*/);return o.length<2&&(o[1]=o[0]),o.map(((t,o)=>t.split(" ").map((t=>parseFloat(t)*e[o]/n[o]+(t.match(/[^\d\.]+$/)?.[0]||"px"))).join(" "))).join("/")}function y(t,n,e){if(/^\s*$|none/.test(t))return t;const[o,r,s]=t.split(/(?<=px),\s?/)[0].split(/(?<=\))\s|\s(?=inset)/);if(!r)return"";const[i,f,c,a]=r.split(" ").map(parseFloat),u=Math.max(...e)/Math.max(...n),l=new Array(3).fill([i*e[0]/n[0],f*e[1]/n[1],c*u,a*u]);return n[0]<n[1]?(l[1][0]-=1/n[0],l[2][0]+=1/n[0]):(l[1][1]-=1/n[1],l[2][1]+=1/n[1]),l.map((t=>`${o} ${t.map((t=>`${t}px`)).join(" ")}${s?" inset":""}`)).join(", ")}function d(t,n,e){let r,i=t;for(;i=i?.parentElement;)if(i.dataset.lively){r=o(i.dataset.lively,0);break}if(!i||!r||!r.trackList.some((t=>t.animations.length||t.correctAfterEnded)))return;const{width:f,height:c}=i.getBoundingClientRect(),a=s(i.offsetWidth/f),u=s(i.offsetHeight/c),l="center"===e.x?0:(t.offsetWidth-t.offsetWidth*a)/2*("right"===e.x?1:-1),h="center"===e.y?0:(t.offsetHeight-t.offsetHeight*u)/2*("bottom"===e.y?1:-1);t.style.transform=`translate(${l-2*n[0]}px, ${h-2*n[1]}px) scale(${a}, ${u}) translate(${n[0]/a}px, ${n[1]/u}px)`}function x(n,e,o="_la"){const r=Array.isArray(n)?n:[n];for(let n=0;n<r.length;n++){if(!t(r[n]))continue;const{props:s,key:i}=r[n],f=o+(null!==i?`${i}_`:n);"object"==typeof s.triggers&&(s.triggers._livelyId=f,e.delete(f)),x(s.children,e,f)}return e}function $(n,e){const o=Array.isArray(n)?n:[n],r=[];for(let n=0;n<o.length;n++){if(!t(o[n]))continue;const{key:s}=o[n],i="_la"+(null!==s?`${s}_`:n);e.has(i)&&r.push([n,o[n]])}return r}const k={duration:0,delay:1,repeat:2,alternate:3,reverse:4,easing:5,composite:6};function j(t,o){const r={},s=[];if(!(t instanceof n))for(const n in t){let i=t[n];"object"==typeof i||n in k||(i=new e(i)),i instanceof e&&(s.push(i.on("change",(()=>o(n,i)))),r[n]=i)}return[r,()=>s.forEach((t=>t()))]}function A(t,n){const e={};for(const o in t)e[o]=t[o].get(n);return e}export{k as ClipConfigKeys,p as addKeyframeEntry,i as asArray,s as clampLowerBound,d as correctForParentScale,j as extractAnimationLinks,x as filterRemovedAnimators,a as forEachTrigger,A as getInitialStyleFromLinks,l as getLifeCycleAnimations,$ as getRemovedAnimators,r as keyframeEpsilon,f as mergeRefs,c as mergeStyles,g as parseClipKeyframes,m as scaleCorrectRadius,y as scaleCorrectShadow,u as serializeTriggers,h as transformKeyframeList};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/dist/layout-group.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t}from"react/jsx-runtime";import{createContext as r,useId as e,useRef as n,useState as o,useLayoutEffect as i,useEffect as a}from"react";import{filterRemovedAnimators as u,getRemovedAnimators as s}from"./core/utils.js";import{registerLayoutGroup as c,forEachAnimator as m,unregisterLayoutGroup as l}from"./core/state.js";const d=r("");function f({children:r,skipInitialMount:f=!1,mode:p="wait"}){const g="_lg"+e(),h=n(0),
|
|
2
|
+
import{jsx as t}from"react/jsx-runtime";import{createContext as r,useId as e,useRef as n,useState as o,useLayoutEffect as i,useEffect as a}from"react";import{filterRemovedAnimators as u,getRemovedAnimators as s}from"./core/utils.js";import{registerLayoutGroup as c,forEachAnimator as m,unregisterLayoutGroup as l}from"./core/state.js";const d=r("");function f({children:r,skipInitialMount:f=!1,mode:p="wait"}){const g="_lg"+e(),h=n(0),M=n(0),w=n(r),v=c(g,f),[x,j]=o(0),y=u(r,new Set(v.animators));if(y.size){if("sync"===p){const t=Array.isArray(r)?r.slice():[r];for(const[r,e]of s(w.current,y))t.splice(r,0,e);w.current=t}let t=0;m(y,(r=>{"mounted"===r.state&&(t=Math.max(t,r.trigger("unmount",{cascade:"reverse",composite:"override"})),t&&(r.state="unmounting",r.dispatch("unmount")))})),M.current=Math.max(M.current,Date.now()+1e3*t)}clearTimeout(h.current);const T=M.current-Date.now();return T>0?(m(v.animators,(t=>{"unmounting"!==t.state||y.has(t.id)||(t.trigger("mount",{override:!0}),t.state="mounted")})),h.current=setTimeout((()=>{w.current=r,j((t=>t+1))}),T)):"wait"===p&&(w.current=r),i((()=>{m(v.animators,(t=>{"mounted"!==t.state||t.isMounting||t.transition(),t.isMounting=!1}))}),[r]),a((()=>(v.skipInitialMount=!1,()=>{l(g),clearTimeout(h.current)})),[]),t(d,{value:g,children:w.current})}export{d as LayoutGroupContext,f as default};
|
|
3
3
|
//# sourceMappingURL=layout-group.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Easing } from "./clip";
|
|
1
|
+
import { BlendMode, Easing } from "./clip";
|
|
2
2
|
export type TransitionOptions = {
|
|
3
3
|
duration?: number;
|
|
4
4
|
easing?: Easing;
|
|
5
|
+
composite?: BlendMode;
|
|
5
6
|
};
|
|
6
7
|
export type AnimationLinkEvent = 'change';
|
|
7
8
|
export default class AnimationLink<T, K = T> {
|
|
@@ -41,6 +41,7 @@ export default class Animator<T extends string> {
|
|
|
41
41
|
[key in AnimatorEvent]?: Set<(...args: any) => void>;
|
|
42
42
|
};
|
|
43
43
|
state: 'unmounted' | 'unmounting' | 'mounted';
|
|
44
|
+
isMounting: boolean;
|
|
44
45
|
paused: boolean;
|
|
45
46
|
timeout: number;
|
|
46
47
|
frame: number;
|
|
@@ -78,4 +79,5 @@ export default class Animator<T extends string> {
|
|
|
78
79
|
transition(from?: Animator<any>, options?: TransitionOptions): void;
|
|
79
80
|
setPlayState(paused: boolean): void;
|
|
80
81
|
stop(animation?: T): void;
|
|
82
|
+
hide(): void;
|
|
81
83
|
}
|
|
@@ -39,9 +39,10 @@ export default class Clip {
|
|
|
39
39
|
duration: number;
|
|
40
40
|
delay: number;
|
|
41
41
|
iterations: number;
|
|
42
|
-
|
|
42
|
+
direction: "reverse" | "alternate" | "alternate-reverse" | "normal";
|
|
43
43
|
easing: Easing;
|
|
44
44
|
composite: "accumulate" | "replace";
|
|
45
|
+
fill: "both";
|
|
45
46
|
blendmode: BlendMode;
|
|
46
47
|
commit: boolean;
|
|
47
48
|
};
|
|
@@ -37,6 +37,7 @@ export default class Track {
|
|
|
37
37
|
timeout: number;
|
|
38
38
|
correctAfterEnded: boolean;
|
|
39
39
|
constructor(element: HTMLElement | SVGElement, shouldCache: CacheKey[], align: CorrectionAlignment);
|
|
40
|
+
getScale(): ScaleTuple;
|
|
40
41
|
snapshot(): StyleCache;
|
|
41
42
|
push(clip: Clip, options?: AnimationOptions, onEnded?: () => void): number;
|
|
42
43
|
advance(): void;
|