@infinityfx/lively 5.0.0-alpha.6 → 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/core/animation-link.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/types/core/animation-link.d.ts +2 -1
- package/dist/types/core/clip.d.ts +1 -0
- package/dist/types/core/track.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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/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,direction:s?i?"alternate-reverse":"alternate":i?"reverse":"normal",easing:this.easing,composite:"combine"===a?"accumulate":"replace",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};
|
|
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","direction","blendmode","mergeInitialStyles","clips","styles","mounted","merged","backfaceVisibility","willChange","clip","index","offset","Object","assign"],"mappings":"gDAoCc,MAAOA,EAYjB,WAAAC,EAAYC,SACRA,EAAW,GAAEC,MACbA,EAAQ,EAACC,OACTA,EAAS,EAACC,UACVA,GAAY,EAAKC,QACjBA,GAAU,EAAKC,OACfA,EAAS,OAAMC,UACfA,EAAY,UACTC,GACSC,EAAwB,IACpCC,KAAKT,SAAWA,EAChBS,KAAKR,MAAQA,EACbQ,KAAKP,OAASA,EACdO,KAAKN,UAAYA,EACjBM,KAAKL,QAAUA,EACfK,KAAKJ,OAASA,EACdI,KAAKH,UAAYA,EAEjBG,KAAKF,UAAYG,EAAmBH,EAAWC,GAC/CC,KAAKE,SAAWF,KAAKF,UAAUK,MACnC,CAEA,SAAAC,EAAUZ,MACNA,EAAQ,EAACC,OACTA,EAASO,KAAKP,OAAMC,UACpBA,EAAYM,KAAKN,UAASC,QAC1BA,EAAUK,KAAKL,QAAOE,UACtBA,EAAYG,KAAKH,UAASQ,OAC1BA,GAAS,IAGT,MAAO,CACHd,SAA0B,IAAhBS,KAAKT,SACfC,MAA8B,KAAtBQ,KAAKR,MAAQA,GACrBc,WAAYb,EACZc,UAAWb,EACNC,EAAU,oBAA+B,YACzCA,EAAU,UAAqB,SACpCC,OAAQI,KAAKJ,OACbC,UAAyB,YAAdA,EAA0B,aAAwB,
|
|
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","assign"],"mappings":"gDAoCc,MAAOA,EAYjB,WAAAC,EAAYC,SACRA,EAAW,GAAEC,MACbA,EAAQ,EAACC,OACTA,EAAS,EAACC,UACVA,GAAY,EAAKC,QACjBA,GAAU,EAAKC,OACfA,EAAS,OAAMC,UACfA,EAAY,UACTC,GACSC,EAAwB,IACpCC,KAAKT,SAAWA,EAChBS,KAAKR,MAAQA,EACbQ,KAAKP,OAASA,EACdO,KAAKN,UAAYA,EACjBM,KAAKL,QAAUA,EACfK,KAAKJ,OAASA,EACdI,KAAKH,UAAYA,EAEjBG,KAAKF,UAAYG,EAAmBH,EAAWC,GAC/CC,KAAKE,SAAWF,KAAKF,UAAUK,MACnC,CAEA,SAAAC,EAAUZ,MACNA,EAAQ,EAACC,OACTA,EAASO,KAAKP,OAAMC,UACpBA,EAAYM,KAAKN,UAASC,QAC1BA,EAAUK,KAAKL,QAAOE,UACtBA,EAAYG,KAAKH,UAASQ,OAC1BA,GAAS,IAGT,MAAO,CACHd,SAA0B,IAAhBS,KAAKT,SACfC,MAA8B,KAAtBQ,KAAKR,MAAQA,GACrBc,WAAYb,EACZc,UAAWb,EACNC,EAAU,oBAA+B,YACzCA,EAAU,UAAqB,SACpCC,OAAQI,KAAKJ,OACbC,UAAyB,YAAdA,EAA0B,aAAwB,UAC7DW,KAAM,OACNC,UAAWZ,EACXQ,SAER,CAEA,yBAAOK,CAAmBC,EAAeC,EAAsBC,GAAU,GACrE,MAAMC,EAAS,CACXC,mBAAoB,SACpBC,WAAY,aAGhB,IAAK,MAAMC,KAAQN,EAAO,CACtB,MAAMO,EAAQL,IAAYI,EAAKtB,QAAUsB,EAAKnB,UAAUK,OAAS,EAAI,GAC/DgB,OAAEA,KAAWP,GAAWK,EAAKnB,UAAUoB,GAC7CE,OAAOC,OAAOP,EAAQF,EAC1B,CAEA,OAAOQ,OAAOC,OAAOP,EAAQF,EACjC"}
|
package/dist/core/track.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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.
|
|
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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AaH,KAAKG,WAAWqD,QAAOf,GAAqC,YAAxBA,EAAUgB,YAChEzD,KAAKI,OAASJ,KAAKG,WAAWqD,QAAOf,GAAqC,SAAxBA,EAAUH,YAAsBqB,MACtF,CAEA,MAAAc,CAAOC,GACH1E,KAAKG,WAAWkE,SAAQ5B,GAAaA,EAAUiC,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
|
|
@@ -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> {
|
|
@@ -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;
|