Comparing version 0.1.0 to 0.2.0
@@ -1,1 +0,1 @@ | ||
/*! effekt 0.1.0 | https://github.com/ivodolenc/effekt | MIT License | Ivo Dolenc (c) 2024 */var Effekt=function(f){"use strict";function S(e){return e*1e3}function E(e){return e/1e3}function yt(e,t=2){return t=10**t,Math.round(e*t)/t}function C(e,t,s){return Math.min(Math.max(s,e),t)}function R(e,t,s){return-s*e+s*t+e}function B(e,t,s){const i=e*e;return Math.sqrt(Math.max(0,s*(t*t-i)+i))}function P(e,t,s){const i=t-e;return i===0?1:(s-e)/i}function z(...e){return t=>e.reduce((s,i)=>i(s),t)}const vt=e=>Object.prototype.toString.call(e).slice(8,-1),T=e=>typeof e=="number"&&!isNaN(e),Rt=e=>typeof e=="string",$=e=>e===null,O=e=>typeof e>"u",W=e=>vt(e)==="Object",y=e=>Array.isArray(e),Tt=e=>e instanceof Function,wt=e=>e instanceof Element,St=e=>e instanceof HTMLElement,$t=e=>e instanceof SVGElement,H=e=>!!(e&&(St(e)||$t(e)));function Dt(e,t){return s=>R(e,t,s)}function xt(e,t){return s=>{const i=[],r=[];for(let n=0,a=e.length;n<a;n++)i.push(o=>R(e[n],t[n],o)),r[n]=i[n](s);return r}}function L(e,t){return s=>{const i=[],r=[],{round:n}=Math,a=3;for(let o=0;o<a;o++)i.push(h=>B(e[o],t[o],h)),r[o]=n(C(0,255,i[o](s)));return i.push(o=>R(e[a],t[a],o)),r[a]=n(C(0,1,i[a](s))*1e5)/1e5,r}}function Mt(e,t){return s=>{const i=[],r=[];for(let n=0,a=e.length;n<a;n++)T(e[n])?i.push(o=>R(e[n],t[n],o)):i.push(o=>L(e[n],t[n])(o)),r[n]=i[n](s);return r}}function bt(e,t={}){return t.type==="color"?L:t.type==="shadow"?Mt:y(e)?xt:Dt}function kt(e,t={}){const{ease:s,type:i}=t,r=[],n=bt(e[0],{type:i});for(let a=0,o=e.length-1;a<o;a++){let h=n(e[a],e[a+1]);if(s){const l=y(s)?s[a]:s;h=z(l,h)}r.push(h)}return r}function v(e,t,s={}){const i=t.length,r=i-1;t[0]>t[r]&&(t=[...t].reverse(),e=[...e].reverse());const n=kt(e,s),a=n.length;return o=>{let h=0;if(a>1)for(;h<i-2&&!(o<t[h+1]);h++);const l=P(t[h],t[h+1],o);return n[h](l)}}function G(e){let t=e.slice(1);t.length===3&&(t=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`);const s=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16),n=parseInt(t.slice(6,8),16)/255||1;return[s,i,r,n]}function A(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<.16666666666666666?e+(t-e)*6*s:s<.5?t:s<.6666666666666666?e+(t-e)*(.6666666666666666-s)*6:e}function Q(e,t,s,i){let r,n,a;if(e/=360,t/=100,s/=100,t===0)r=n=a=s;else{const{round:o}=Math,h=s<.5?s*(1+t):s+t-s*t,l=2*s-h;r=o(A(l,h,e+.3333333333333333)*255),n=o(A(l,h,e)*255),a=o(A(l,h,e-.3333333333333333)*255)}return[r,n,a,i]}function Et(e,t){if(T(e))return e;if(e==="first")return 0;const s=t-1;return e==="last"?s:s/2}function Ct(e=.1,t={}){const{delay:s=0,from:i=0,ease:r,grid:n,axis:a}=t,{floor:o,sqrt:h,abs:l}=Math;return(u,c)=>{const p=Et(i,c),d=!T(p)&&p==="center";let m=0;if(!n)m=l(p-u);else{const w=d?(n[0]-1)/2:p%n[0],b=d?(n[1]-1)/2:o(p/n[0]),N=u%n[0],k=o(u/n[0]),Z=w-N,V=b-k;let q=h(Z*Z+V*V);a==="x"&&(q=-Z),a==="y"&&(q=-V),m=q}let g=e*m;if(r){const w=c*e;g=r(g/w)*w}return s+g}}function X(e){const t=[];if(e)for(let s=0,i=e.length;s<i;s++){const r=e[s];H(r)&&t.push(r)}return t}function Y(e){if(wt(e)){if(H(e))return[e]}else if(Rt(e)){const t=X(document.querySelectorAll(e));if(t.length)return t}else{const t=X(e);if(t.length)return t}throw new TypeError("Animation target not found.")}function D(e,t,s){const i=t;if(!O(e.style[i]))return e.style[i]=s;throw new TypeError(`Unsupported '${t}' property.`)}class J{order=[];scheduled=new Set;add(t){if(!this.scheduled.has(t))return this.scheduled.add(t),this.order.push(t),!0}remove(t){const s=this.order.indexOf(t);s!==-1&&(this.order.splice(s,1),this.scheduled.delete(t))}clear(){this.order.length=0,this.scheduled.clear()}}function _(e){let t=new J,s=new J,i=0,r=!1,n=!1;const a=new WeakSet,o={schedule:(h,l=!1,u=!1)=>{const c=u&&r,p=c?t:s;return l&&a.add(h),p.add(h)&&c&&r&&(i=t.order.length),h},cancel:h=>{s.remove(h),a.delete(h)},process:h=>{if(r){n=!0;return}if(r=!0,[t,s]=[s,t],s.clear(),i=t.order.length,i)for(let l=0;l<i;l++){const u=t.order[l];u(h),a.has(u)&&(o.schedule(u),e())}r=!1,n&&(n=!1,o.process(h))}};return o}const M=["read","update","render"],Pt=40;function tt(e=requestAnimationFrame,t=!0){let s=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},n=M.reduce((l,u)=>(l[u]=_(()=>s=!0),l),{}),a=l=>{n[l].process(r)},o=()=>{const l=performance.now();s=!1,r.delta=i?1e3/60:Math.max(Math.min(l-r.timestamp,Pt),1),r.timestamp=l,r.isProcessing=!0,M.forEach(a),r.isProcessing=!1,s&&t&&(i=!1,e(o))},h=()=>{s=!0,i=!0,r.isProcessing||e(o)};return{schedule:M.reduce((l,u)=>{const c=n[u];return l[u]=(p,d=!1,m=!1)=>(s||h(),c.schedule(p,d,m)),l},{}),cancel:l=>M.forEach(u=>n[u].cancel(l)),state:r}}const{schedule:j,cancel:F,state:U}=tt();function et(e,t,s){return e&&!O(t)&&!O(s)?Tt(e)?S(e(t,s)):S(e):0}function Ot(e){return e?e===1/0?1e3:e+1:1}function st(e={}){const{el:t}=e,s=new WeakMap;s.set(t.value,{delta:0,timestamp:0,playState:"idle",promiseState:"pending",time:0,initTime:0,startTime:0,pauseTime:null,totalDuration:600,maxDuration:600,progress:0,totalProgress:1,isReverse:!1,autoplay:e.autoplay??!0,direction:e.direction||"normal",playRate:e.playRate||1,duration:S(e.duration||.6),delay:et(e.delay,t?.index,t?.total),endDelay:et(e.endDelay,t?.index,t?.total),repeat:Ot(e.repeat)});const i=s.get(t.value);return i.totalDuration=i.duration*i.repeat,i.maxDuration=i.totalDuration+i.delay+i.endDelay,i}class it{#s={};#a=new WeakMap;#i;#e;#o=!1;#l=!1;#h=0;constructor(t,s={}){const{onRender:i,onComplete:r}=s;this.#a.set(this.#s,t),i&&(this.#i=new WeakMap,this.#i.set(this.#s,i)),r&&(this.#e=new WeakMap,this.#e.set(this.#s,r)),this.#t.autoplay&&this.play()}#c(){this.#o||(j.update(this.#r,!0),this.#n(!0),this.#o=!0)}#u(){this.#o&&(F(this.#r),this.#i&&F(this.#i.get(this.#s)),this.#o=!1)}#n(t=!1){this.#i&&j.render(this.#i.get(this.#s),t)}#r=({timestamp:t,delta:s})=>{this.#t.timestamp=t,this.#t.delta=s;let i=0;$(this.#t.pauseTime)?this.#t.playRate<0?(this.#l||(this.#l=!0,this.#h=t,this.#t.startTime=this.#t.progress===0?t*this.#t.playRate:this.#t.totalDuration-t-this.#t.time),i=t-this.#t.startTime/this.#t.playRate):this.#t.playRate>0&&(this.#l&&(this.#l=!1,this.#t.startTime=this.#t.progress===0?(t-this.#h)*2+this.#t.initTime:this.#h-(this.#t.totalDuration-t-this.#t.time+this.#h)),i=(t-this.#t.startTime)*this.#t.playRate):i=this.#t.pauseTime,this.#t.time=i,i=Math.max(i-this.#t.delay,0),this.#t.playState==="finished"&&$(this.#t.pauseTime)&&(i=this.#t.totalDuration);const r=i/this.#t.duration;let n=Math.floor(r),a=r%1;!a&&r>=1&&(a=1),a===1&&n--;const o=n%2,h=this.#t.repeat%2,l=this.#t.direction;this.#t.playRate<0||l==="reverse"||l==="alternate"&&o||l==="alternate-reverse"&&!o?(this.#t.isReverse=!0,this.#t.totalProgress=0,l==="alternate"&&h?this.#t.totalProgress=1:l==="alternate-reverse"&&!h&&(this.#t.totalProgress=1),a=1-a):this.#t.isReverse=!1,this.#t.progress=i>=this.#t.totalDuration?this.#t.totalProgress:Math.min(a,1),$(this.#t.pauseTime)&&(this.#t.playState==="finished"||i>=this.#t.totalDuration+this.#t.endDelay)&&(this.#t.playState="finished",this.#u(),this.#n(),this.#e?.get(this.#s)?.())};#p(t){t<0&&(this.#t.totalProgress=0),t>0&&(this.#t.totalProgress=1),this.#t.playRate=t}now(){return U.isProcessing?U.timestamp:performance.now()}play(){if(this.#o)return;const t=this.now();$(this.#t.pauseTime)?this.#t.startTime||(this.#t.initTime=t,this.#t.startTime=t):this.#t.startTime=t-this.#t.pauseTime,this.#t.pauseTime=null,this.#t.playState="running",this.#c()}pause(){this.#t.playState="paused",this.#t.pauseTime=this.#t.time}stop(){this.#t.playState="idle",this.#u(),this.#n()}cancel(){this.#t.playState="idle",this.#u(),this.currentTime=0,this.#n()}finish(){this.#t.playState="finished",this.#u(),this.currentTime=E(this.#t.totalDuration),this.#n()}reverse(){this.#t.playRate===0||this.#t.progress===0||this.#t.progress===1||(this.#t.playRate>0?(this.playRate=1,this.playRate=-1):this.#t.playRate<0&&(this.playRate=-1,this.playRate=1))}get#t(){return this.#a.get(this.#s)}get currentTime(){return E(this.#t.time)}set currentTime(t){const s=S(t);this.#t.time=s,!$(this.#t.pauseTime)||!this.#o||this.#t.playRate===0?this.#t.pauseTime=s:this.#t.startTime=this.now()-s/this.#t.playRate}get playRate(){return this.#t.playRate}set playRate(t){if(t!==this.#t.playRate){if(t===0&&this.#o){this.#t.playRate=0,this.pause();return}if(t!==0&&!this.#o){this.#p(t),this.play();return}this.#p(t)}}}const nt=(...e)=>new RegExp(e.map(t=>t.source).join("|")),Wt=/\((.*?)\)/,At=/(-?[0-9.]+)/g,jt=/^\d+$/,rt=/^(#|rgb|hsl)/,Ft=/(color|background)/i,Ut=/(px|pt|pc|in|cm|mm|em|rem|%|ex|ch|fr|vw|vh|vmin|vmax|deg|rad|turn)/,at=/^(x|y|z|translate|perspective)/,It=/(width|height|margin|padding|inset|top|right|bottom|left)/i,ot=/^(rotate|skew)/,Kt=/^scale/,Nt=nt(at,ot,Kt),Zt=nt(at,It),I=/shadow/i,Vt=/(blur|bright|contrast|dropShadow|gray|hue|invert|opacityFilter|saturate|sepia)/i,x=new WeakMap,K=new WeakMap;class qt{#s=new WeakMap;#a=new WeakMap;#i;#e;constructor(t,s,i){const{type:r,key:n,value:a,units:o,ease:h,offset:l,...u}=s;this.#e=t.value,this.#s.set(this.#e,st({el:t,...u})),this.#a.set(this.#e,{transform:!1,color:!1,other:!1,otherShadow:!1,filter:!1,filterShadow:!1}),r==="transform"&&(this.#r.transform=!0,x.set(this.#e,{}),i&&(n!=="translateZ"&&(x.get(this.#e).translateZ="translateZ(0)"),t.value.style.willChange="transform")),r==="color"&&(this.#r.color=!0),r==="other"&&(this.#r.other=!0,I.test(n)&&(this.#r.otherShadow=!0)),r==="filter"&&(this.#r.filter=!0,I.test(n)&&(this.#r.filterShadow=!0),K.set(this.#e,{}));const c=()=>{this.#r.transform&&(this.#c(s),this.#h("transform",x)),this.#r.color&&this.#o(s),this.#r.other&&this.#l(s,this.#r.otherShadow),this.#r.filter&&(this.#u(s,this.#r.filterShadow),this.#h("filter",K)),this.onRender()},p=()=>{this.#r.transform&&i&&(n!=="translateZ"&&(x.get(this.#e).translateZ=""),t.value.style.willChange="auto"),this.onComplete()};this.#i=new it(this.#n,{onRender:c,onComplete:p})}#o(t){const{key:s,value:i,ease:r,offset:n}=t,a=v(i,n,{ease:r,type:"color"})(this.#n.progress);D(this.#e,s,`rgba(${a})`)}#l(t,s){const{key:i,value:r,units:n,ease:a,offset:o}=t,[h]=n,l=this.#n.progress;if(s){const u=v(r,o,{ease:a,type:"shadow"})(l);let c="";for(let p=0,d=u.length;p<d;p++){const m=u[p];T(m)?c+=`${m}${h||"px"} `:c+=`rgba(${m})`}D(this.#e,i,c)}else{const u=v(r,o,{ease:a})(l);D(this.#e,i,`${u}${h}`)}}#h(t,s){const i=Object.values(s.get(this.#e)).join(" ");D(this.#e,t,i)}#c(t){const{key:s,value:i,units:r,ease:n,offset:a}=t,[o]=r,h=v(i,a,{ease:n})(this.#n.progress);x.get(this.#e)[s]=`${s}(${h}${o})`}#u(t,s){const{key:i,value:r,units:n,ease:a,offset:o}=t,[h]=n,l=this.#n.progress,u=K.get(this.#e);if(s){const c=v(r,o,{ease:a,type:"shadow"})(l);let p="";for(let d=0,m=c.length;d<m;d++){const g=c[d];T(g)?p+=`${g}${h||"px"} `:p+=`rgba(${g})`}u[i]=`${i}(${p})`}else{const c=v(r,o,{ease:a})(l);u[i]=`${i}(${c}${h})`}}onRender(){}onComplete(){}play(){this.#i.play()}pause(){this.#i.pause()}stop(){this.#i.stop()}cancel(){this.#i.cancel()}finish(){this.#i.finish()}reverse(){this.#i.reverse()}get#n(){return this.#s.get(this.#e)}get#r(){return this.#a.get(this.#e)}get currentTime(){return this.#i.currentTime}set currentTime(t){this.#i.currentTime=t}get playRate(){return this.#i.playRate}set playRate(t){this.#i.playRate=t}get data(){return this.#n}}const ht=(e=>t=>1-e(1-t))(e=>Math.pow(e,4));function Bt(e,t){const s=e[e.length-1],i=P(0,t,1);return R(s,1,i)}function lt(e,t){return Zt.test(e)?{value:t,unit:"px"}:ot.test(e)?{value:t,unit:"deg"}:{value:t,unit:""}}function ut(e){const t=e.split(At),s=parseFloat(t[1]),i=t[2];return{value:s,unit:i}}function ct(e){const t="";if(e.startsWith("#"))return{value:G(e),unit:t};const s=e.match(Wt)[1].split(",").map(Number);return e.startsWith("rgb")?{value:[s[0],s[1],s[2],s[3]||1],unit:t}:{value:Q(s[0],s[1],s[2],s[3]||1),unit:t}}function zt(e,t){const s=window.getComputedStyle(document.documentElement);return pt(e,s.getPropertyValue(t))}function Ht(e){const t=e.split(" "),s=[],i=[];for(let r=0,n=t.length;r<n;r++){const a=t[r],o=rt.test(a)?ct(a):ut(a);s.push(o.value),i.push(o.unit)}return{value:s,unit:i[0]}}function pt(e,t){if(T(t))return lt(e,t);if(t.startsWith("--"))return zt(e,t);if(jt.test(t))return lt(e,parseFloat(t));if(rt.test(t))return ct(t);if(I.test(e))return Ht(t);if(Ut.test(t))return ut(t);throw new TypeError(`Unsupported value '${t}' in '${e}' property.`)}function ft(e,t){if(t.size>1)throw new TypeError(`All units of '${e}' property must be of the same type.`)}function dt(e,t,s){if(y(t)&&t.length<e.length)for(;t.length<e.length;)s.push(ht)}function mt(e,t,s,i,r,n,a){const o=W(t)?t.offset:void 0,h=W(t)?t.value:t,l=s===0?o||0:o||Bt(r.offset,i);r.offset.push(l);const u=pt(e,h);r.value.push(u.value),r.units.add(u.unit),y(n)||a.push(n)}function Lt(e,t,s={}){const i={type:"other",key:e,value:[],offset:[],units:new Set,...s},r=i.ease||ht;if(!e.startsWith("on")){if(Nt.test(e)&&(i.type="transform",e.length===1&&(i.key=`translate${e.toUpperCase()}`)),Ft.test(e)&&(i.type="color"),Vt.test(e)&&(i.type="filter",i.key=e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),e.startsWith("opa")&&(i.key="opacity")),y(t)){const n=t.length;if(n<2)return;const a=y(r)?r:[];for(let o=0;o<n;o++){const h=t[o],l=n-i.offset.length;mt(e,h,o,l,i,r,a)}return ft(e,i.units),dt(i.value,r,a),i.ease=a,i}if(W(t)&&!y(t)){const n=t.value.length;if(n<2)return;const a=y(r)?r:[];for(let c=0;c<n;c++){const p=t.value[c],d=n-i.offset.length;mt(e,p,c,d,i,r,a)}ft(e,i.units),dt(i.value,r,a);const{value:o,ease:h,offset:l,...u}=t;return{...i,...u,ease:h||a,offset:l||i.offset,autoplay:i.autoplay,playRate:i.playRate}}}}function Gt(e){const{autoplay:t,direction:s,playRate:i,duration:r,delay:n,endDelay:a,repeat:o,ease:h,force3d:l,...u}=e,c=l??!0,p=Object.keys(u),d=[],m={autoplay:t,direction:s,playRate:i,duration:r,delay:n,endDelay:a,repeat:o,ease:h};for(let g=0,w=p.length;g<w;g++){const b=p[g],N=u[b],k=Lt(b,N,m);k&&d.push(k)}return d.length||d.push(m),{options:d,force3d:c}}function gt(e){return e.reduce((t,s)=>t.data.maxDuration>s.data.maxDuration?t:s)}class Qt{#s;#a=[];constructor(t,s){for(let i=0,r=s.options.length;i<r;i++){const n=new qt(t,s.options[i],s.force3d);this.#a.push(n)}this.#s=gt(this.#a)}#i(t,s){this.#a.forEach(i=>i[t]=s)}#e(t){this.#a.forEach(s=>s[t]())}onRender(t){this.#s.onRender=t}onComplete(t){this.#s.onComplete=t}play(){this.#e("play")}pause(){this.#e("pause")}stop(){this.#e("stop")}cancel(){this.#e("cancel")}finish(){this.#e("finish")}reverse(){this.#e("reverse")}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#i("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#i("playRate",t)}get data(){return this.#s.data}}class Xt{#s;#a=[];#i;#e;#o;#l;#h;#c;constructor(t,s){this.#i=s.onPlay,this.#e=s.onPause,this.#o=s.onStop,this.#l=s.onReverse;const i=Y(t),r=Gt(s);for(let n=0,a=i.length;n<a;n++){const o=i[n],h=new Qt({value:o,index:n,total:a},r);this.#a.push(h)}this.#s=gt(this.#a),this.#s.onComplete(()=>this.#h?.(this.data)),s.onUpdate&&this.#s.onRender(()=>s.onUpdate?.(this.data,i)),s.onStart?.(this.data),this.finished.then(()=>{this.#s.data.playState="finished",this.#s.data.promiseState="fulfilled",s.onComplete?.(this.data)}).catch(n=>{this.#s.data.playState="idle",this.#s.data.promiseState="rejected",s.onCancel?.(this.data,n)})}#u(t,s){this.#a.forEach(i=>i[t]=s)}#n(t){this.#a.forEach(s=>s[t]())}finished=new Promise((t,s)=>{this.#h=t,this.#c=s});play(){this.#n("play"),this.#i?.(this.data)}pause(){this.#n("pause"),this.#e?.(this.data)}stop(){this.#n("stop"),this.#c?.(!1),this.#o?.(this.data)}cancel(){this.#n("cancel"),this.#c?.(!1)}finish(){this.#n("finish"),this.#h?.(this.data)}reverse(){this.#n("reverse"),this.#l?.(this.data)}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#u("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#u("playRate",t)}get data(){return Object.freeze({...this.#s.data})}}function Yt(e,t){return new Xt(e,t)}return f.Driver=it,f.animate=Yt,f.cancelFrame=F,f.clamp=C,f.createDriverData=st,f.createRenderBatcher=tt,f.createRenderStep=_,f.frame=j,f.getElements=Y,f.hexToRgba=G,f.hslaToRgba=Q,f.interpolate=v,f.mix=R,f.mixColor=B,f.msToSec=E,f.pipe=z,f.progress=P,f.round=yt,f.secToMs=S,f.setStyle=D,f.stagger=Ct,f.state=U,f}({}); | ||
/*! effekt 0.2.0 | https://github.com/ivodolenc/effekt | MIT License | Ivo Dolenc (c) 2024 */var Effekt=function(m){"use strict";function $(e){return e*1e3}function E(e){return e/1e3}function gt(e,t=2){return t=10**t,Math.round(e*t)/t}function P(e,t,s){return Math.min(Math.max(s,e),t)}function T(e,t,s){return-s*e+s*t+e}function q(e,t,s){const i=e*e;return Math.sqrt(Math.max(0,s*(t*t-i)+i))}function C(e,t,s){const i=t-e;return i===0?1:(s-e)/i}function z(...e){return t=>e.reduce((s,i)=>i(s),t)}const yt=e=>Object.prototype.toString.call(e).slice(8,-1),w=e=>typeof e=="number"&&!isNaN(e),vt=e=>typeof e=="string",D=e=>e===null,W=e=>typeof e>"u",A=e=>yt(e)==="Object",y=e=>Array.isArray(e),Rt=e=>e instanceof Function,Tt=e=>e instanceof Element,wt=e=>e instanceof HTMLElement,St=e=>e instanceof SVGElement,H=e=>!!(e&&(wt(e)||St(e)));function $t(e,t){return s=>T(e,t,s)}function Dt(e,t){return s=>{const i=[],n=[];for(let a=0,r=e.length;a<r;a++)i.push(o=>T(e[a],t[a],o)),n[a]=i[a](s);return n}}function L(e,t){return s=>{const i=[],n=[],{round:a}=Math,r=3;for(let o=0;o<r;o++)i.push(h=>q(e[o],t[o],h)),n[o]=a(P(0,255,i[o](s)));return i.push(o=>T(e[r],t[r],o)),n[r]=a(P(0,1,i[r](s))*1e5)/1e5,n}}function Mt(e,t){return s=>{const i=[],n=[];for(let a=0,r=e.length;a<r;a++)w(e[a])?i.push(o=>T(e[a],t[a],o)):i.push(o=>L(e[a],t[a])(o)),n[a]=i[a](s);return n}}function bt(e,t={}){return t.type==="color"?L:t.type==="shadow"?Mt:y(e)?Dt:$t}function xt(e,t={}){const{ease:s,type:i}=t,n=[],a=bt(e[0],{type:i});for(let r=0,o=e.length-1;r<o;r++){let h=a(e[r],e[r+1]);if(s){const l=y(s)?s[r]:s;h=z(l,h)}n.push(h)}return n}function R(e,t,s={}){const i=t.length,n=i-1;t[0]>t[n]&&(t=[...t].reverse(),e=[...e].reverse());const a=xt(e,s),r=a.length;return o=>{let h=0;if(r>1)for(;h<i-2&&!(o<t[h+1]);h++);const l=C(t[h],t[h+1],o);return a[h](l)}}function G(e){let t=e.slice(1);t.length===3&&(t=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`);const s=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)/255||1;return[s,i,n,a]}function O(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<.16666666666666666?e+(t-e)*6*s:s<.5?t:s<.6666666666666666?e+(t-e)*(.6666666666666666-s)*6:e}function Q(e,t,s,i){let n,a,r;if(e/=360,t/=100,s/=100,t===0)n=a=r=s;else{const{round:o}=Math,h=s<.5?s*(1+t):s+t-s*t,l=2*s-h;n=o(O(l,h,e+.3333333333333333)*255),a=o(O(l,h,e)*255),r=o(O(l,h,e-.3333333333333333)*255)}return[n,a,r,i]}function kt(e,t){if(w(e))return e;if(e==="first")return 0;const s=t-1;return e==="last"?s:s/2}function Et(e=.1,t={}){const{delay:s=0,from:i=0,ease:n,grid:a,axis:r}=t,{floor:o,sqrt:h,abs:l}=Math;return(c,p)=>{const u=kt(i,p),f=!w(u)&&u==="center";let d=0;if(!a)d=l(u-c);else{const v=f?(a[0]-1)/2:u%a[0],S=f?(a[1]-1)/2:o(u/a[0]),N=c%a[0],k=o(c/a[0]),Z=v-N,B=S-k;let V=h(Z*Z+B*B);r==="x"&&(V=-Z),r==="y"&&(V=-B),d=V}let g=e*d;if(n){const v=p*e;g=n(g/v)*v}return s+g}}function X(e){const t=[];if(e)for(let s=0,i=e.length;s<i;s++){const n=e[s];H(n)&&t.push(n)}return t}function Y(e){if(Tt(e)){if(H(e))return[e]}else if(vt(e)){const t=X(document.querySelectorAll(e));if(t.length)return t}else{const t=X(e);if(t.length)return t}throw new TypeError("Animation target not found.")}function M(e,t,s){const i=t;if(!W(e.style[i]))return e.style[i]=s;throw new TypeError(`Unsupported '${t}' property.`)}function J(e){let t=new Set,s=new Set,i=!1,n=!1;const a=new WeakSet;let r={delta:0,timestamp:0,isProcessing:!1};function o(l){a.has(l)&&(h.schedule(l),e()),l(r)}const h={schedule:(l,c=!1,p=!1)=>{const u=p&&i?t:s;return c&&a.add(l),u.has(l)||u.add(l),l},cancel:l=>{s.delete(l),a.delete(l)},process:l=>{if(r=l,i){n=!0;return}i=!0,[t,s]=[s,t],s.clear(),t.forEach(o),i=!1,n&&(n=!1,h.process(l))}};return h}const x=["read","update","render"],Pt=40;function _(e=requestAnimationFrame,t=!0){let s=!1,i=!0;const n={delta:0,timestamp:0,isProcessing:!1},a=()=>s=!0,r=x.reduce((u,f)=>(u[f]=J(a),u),{}),{read:o,update:h,render:l}=r,c=()=>{const u=performance.now();s=!1,n.delta=i?1e3/60:Math.max(Math.min(u-n.timestamp,Pt),1),n.timestamp=u,n.isProcessing=!0,o.process(n),h.process(n),l.process(n),n.isProcessing=!1,s&&t&&(i=!1,e(c))},p=()=>{s=!0,i=!0,n.isProcessing||e(c)};return{schedule:x.reduce((u,f)=>{const d=r[f];return u[f]=(g,v=!1,S=!1)=>(s||p(),d.schedule(g,v,S)),u},{}),cancel:u=>{for(let f=0;f<x.length;f++)r[x[f]].cancel(u)},state:n}}const{schedule:j,cancel:F,state:U}=_();function tt(e,t,s){return e&&!W(t)&&!W(s)?Rt(e)?$(e(t,s)):$(e):0}function Ct(e){return e?e===1/0?1e3:e+1:1}function et(e={}){const{el:t}=e,s=new WeakMap;s.set(t.value,{delta:0,timestamp:0,playState:"idle",promiseState:"pending",time:0,initTime:0,startTime:0,pauseTime:null,totalDuration:600,maxDuration:600,progress:0,totalProgress:1,isReverse:!1,autoplay:e.autoplay??!0,direction:e.direction||"normal",playRate:e.playRate||1,duration:$(e.duration||.6),delay:tt(e.delay,t?.index,t?.total),endDelay:tt(e.endDelay,t?.index,t?.total),repeat:Ct(e.repeat)});const i=s.get(t.value);return i.totalDuration=i.duration*i.repeat,i.maxDuration=i.totalDuration+i.delay+i.endDelay,i}class st{#s={};#r=new WeakMap;#i;#e;#o=!1;#l=!1;#h=0;constructor(t,s={}){const{onRender:i,onComplete:n}=s;this.#r.set(this.#s,t),i&&(this.#i=new WeakMap,this.#i.set(this.#s,i)),n&&(this.#e=new WeakMap,this.#e.set(this.#s,n)),this.#t.autoplay&&this.play()}#c(){this.#o||(j.update(this.#a,!0),this.#n(!0),this.#o=!0)}#u(){this.#o&&(F(this.#a),this.#i&&F(this.#i.get(this.#s)),this.#o=!1)}#n(t=!1){this.#i&&j.render(this.#i.get(this.#s),t)}#a=({timestamp:t,delta:s})=>{this.#t.timestamp=t,this.#t.delta=s;let i=0;D(this.#t.pauseTime)?this.#t.playRate<0?(this.#l||(this.#l=!0,this.#h=t,this.#t.startTime=this.#t.progress===0?t*this.#t.playRate:this.#t.totalDuration-t-this.#t.time),i=t-this.#t.startTime/this.#t.playRate):this.#t.playRate>0&&(this.#l&&(this.#l=!1,this.#t.startTime=this.#t.progress===0?(t-this.#h)*2+this.#t.initTime:this.#h-(this.#t.totalDuration-t-this.#t.time+this.#h)),i=(t-this.#t.startTime)*this.#t.playRate):i=this.#t.pauseTime,this.#t.time=i,i=Math.max(i-this.#t.delay,0),this.#t.playState==="finished"&&D(this.#t.pauseTime)&&(i=this.#t.totalDuration);const n=i/this.#t.duration;let a=Math.floor(n),r=n%1;!r&&n>=1&&(r=1),r===1&&a--;const o=a%2,h=this.#t.repeat%2,l=this.#t.direction;this.#t.playRate<0||l==="reverse"||l==="alternate"&&o||l==="alternate-reverse"&&!o?(this.#t.isReverse=!0,this.#t.totalProgress=0,l==="alternate"&&h?this.#t.totalProgress=1:l==="alternate-reverse"&&!h&&(this.#t.totalProgress=1),r=1-r):this.#t.isReverse=!1,this.#t.progress=i>=this.#t.totalDuration?this.#t.totalProgress:Math.min(r,1),D(this.#t.pauseTime)&&(this.#t.playState==="finished"||i>=this.#t.totalDuration+this.#t.endDelay)&&(this.#t.playState="finished",this.#u(),this.#n(),this.#e?.get(this.#s)?.())};#p(t){t<0&&(this.#t.totalProgress=0),t>0&&(this.#t.totalProgress=1),this.#t.playRate=t}now(){return U.isProcessing?U.timestamp:performance.now()}play(){if(this.#o)return;const t=this.now();D(this.#t.pauseTime)?this.#t.startTime||(this.#t.initTime=t,this.#t.startTime=t):this.#t.startTime=t-this.#t.pauseTime,this.#t.pauseTime=null,this.#t.playState="running",this.#c()}pause(){this.#t.playState="paused",this.#t.pauseTime=this.#t.time}stop(){this.#t.playState="idle",this.#u(),this.#n()}cancel(){this.#t.playState="idle",this.#u(),this.currentTime=0,this.#n()}finish(){this.#t.playState="finished",this.#u(),this.currentTime=E(this.#t.totalDuration),this.#n()}reverse(){this.#t.playRate===0||this.#t.progress===0||this.#t.progress===1||(this.#t.playRate>0?(this.playRate=1,this.playRate=-1):this.#t.playRate<0&&(this.playRate=-1,this.playRate=1))}get#t(){return this.#r.get(this.#s)}get currentTime(){return E(this.#t.time)}set currentTime(t){const s=$(t);this.#t.time=s,!D(this.#t.pauseTime)||!this.#o||this.#t.playRate===0?this.#t.pauseTime=s:this.#t.startTime=this.now()-s/this.#t.playRate}get playRate(){return this.#t.playRate}set playRate(t){if(t!==this.#t.playRate){if(t===0&&this.#o){this.#t.playRate=0,this.pause();return}if(t!==0&&!this.#o){this.#p(t),this.play();return}this.#p(t)}}}const it=(...e)=>new RegExp(e.map(t=>t.source).join("|")),Wt=/\((.*?)\)/,At=/(-?[0-9.]+)/g,Ot=/^\d+$/,nt=/^(#|rgb|hsl)/,jt=/(color|background)/i,Ft=/(px|pt|pc|in|cm|mm|em|rem|%|ex|ch|fr|vw|vh|vmin|vmax|deg|rad|turn)/,at=/^(x|y|z|translate|perspective)/,Ut=/(width|height|margin|padding|inset|top|right|bottom|left)/i,rt=/^(rotate|skew)/,It=/^scale/,Kt=it(at,rt,It),Nt=it(at,Ut),I=/shadow/i,Zt=/(blur|bright|contrast|dropShadow|gray|hue|invert|opacityFilter|saturate|sepia)/i,b=new WeakMap,K=new WeakMap;class Bt{#s=new WeakMap;#r=new WeakMap;#i;#e;constructor(t,s,i){const{type:n,key:a,value:r,units:o,ease:h,offset:l,...c}=s;this.#e=t.value,this.#s.set(this.#e,et({el:t,...c})),this.#r.set(this.#e,{transform:!1,color:!1,other:!1,otherShadow:!1,filter:!1,filterShadow:!1}),n==="transform"&&(this.#a.transform=!0,b.set(this.#e,{}),i&&(a!=="translateZ"&&(b.get(this.#e).translateZ="translateZ(0)"),t.value.style.willChange="transform")),n==="color"&&(this.#a.color=!0),n==="other"&&(this.#a.other=!0,I.test(a)&&(this.#a.otherShadow=!0)),n==="filter"&&(this.#a.filter=!0,I.test(a)&&(this.#a.filterShadow=!0),K.set(this.#e,{}));const p=()=>{this.#a.transform&&(this.#c(s),this.#h("transform",b)),this.#a.color&&this.#o(s),this.#a.other&&this.#l(s,this.#a.otherShadow),this.#a.filter&&(this.#u(s,this.#a.filterShadow),this.#h("filter",K)),this.onRender()},u=()=>{this.#a.transform&&i&&(a!=="translateZ"&&(b.get(this.#e).translateZ=""),t.value.style.willChange="auto"),this.onComplete()};this.#i=new st(this.#n,{onRender:p,onComplete:u})}#o(t){const{key:s,value:i,ease:n,offset:a}=t,r=R(i,a,{ease:n,type:"color"})(this.#n.progress);M(this.#e,s,`rgba(${r})`)}#l(t,s){const{key:i,value:n,units:a,ease:r,offset:o}=t,[h]=a,l=this.#n.progress;if(s){const c=R(n,o,{ease:r,type:"shadow"})(l);let p="";for(let u=0,f=c.length;u<f;u++){const d=c[u];w(d)?p+=`${d}${h||"px"} `:p+=`rgba(${d})`}M(this.#e,i,p)}else{const c=R(n,o,{ease:r})(l);M(this.#e,i,`${c}${h}`)}}#h(t,s){const i=Object.values(s.get(this.#e)).join(" ");M(this.#e,t,i)}#c(t){const{key:s,value:i,units:n,ease:a,offset:r}=t,[o]=n,h=R(i,r,{ease:a})(this.#n.progress);b.get(this.#e)[s]=`${s}(${h}${o})`}#u(t,s){const{key:i,value:n,units:a,ease:r,offset:o}=t,[h]=a,l=this.#n.progress,c=K.get(this.#e);if(s){const p=R(n,o,{ease:r,type:"shadow"})(l);let u="";for(let f=0,d=p.length;f<d;f++){const g=p[f];w(g)?u+=`${g}${h||"px"} `:u+=`rgba(${g})`}c[i]=`${i}(${u})`}else{const p=R(n,o,{ease:r})(l);c[i]=`${i}(${p}${h})`}}onRender(){}onComplete(){}play(){this.#i.play()}pause(){this.#i.pause()}stop(){this.#i.stop()}cancel(){this.#i.cancel()}finish(){this.#i.finish()}reverse(){this.#i.reverse()}get#n(){return this.#s.get(this.#e)}get#a(){return this.#r.get(this.#e)}get currentTime(){return this.#i.currentTime}set currentTime(t){this.#i.currentTime=t}get playRate(){return this.#i.playRate}set playRate(t){this.#i.playRate=t}get data(){return this.#n}}const ot=(e=>t=>1-e(1-t))(e=>Math.pow(e,4));function Vt(e,t){const s=e[e.length-1],i=C(0,t,1);return T(s,1,i)}function ht(e,t){return Nt.test(e)?{value:t,unit:"px"}:rt.test(e)?{value:t,unit:"deg"}:{value:t,unit:""}}function lt(e){const t=e.split(At),s=parseFloat(t[1]),i=t[2];return{value:s,unit:i}}function ut(e){const t="";if(e.startsWith("#"))return{value:G(e),unit:t};const s=e.match(Wt)[1].split(",").map(Number);return e.startsWith("rgb")?{value:[s[0],s[1],s[2],s[3]||1],unit:t}:{value:Q(s[0],s[1],s[2],s[3]||1),unit:t}}function qt(e,t){const s=window.getComputedStyle(document.documentElement);return ct(e,s.getPropertyValue(t))}function zt(e){const t=e.split(" "),s=[],i=[];for(let n=0,a=t.length;n<a;n++){const r=t[n],o=nt.test(r)?ut(r):lt(r);s.push(o.value),i.push(o.unit)}return{value:s,unit:i[0]}}function ct(e,t){if(w(t))return ht(e,t);if(t.startsWith("--"))return qt(e,t);if(Ot.test(t))return ht(e,parseFloat(t));if(nt.test(t))return ut(t);if(I.test(e))return zt(t);if(Ft.test(t))return lt(t);throw new TypeError(`Unsupported value '${t}' in '${e}' property.`)}function pt(e,t){if(t.size>1)throw new TypeError(`All units of '${e}' property must be of the same type.`)}function ft(e,t,s){if(y(t)&&t.length<e.length)for(;t.length<e.length;)s.push(ot)}function mt(e,t,s,i,n,a,r){const o=A(t)?t.offset:void 0,h=A(t)?t.value:t,l=s===0?o||0:o||Vt(n.offset,i);n.offset.push(l);const c=ct(e,h);n.value.push(c.value),n.units.add(c.unit),y(a)||r.push(a)}function Ht(e,t,s={}){const i={type:"other",key:e,value:[],offset:[],units:new Set,...s},n=i.ease||ot;if(!e.startsWith("on")){if(Kt.test(e)&&(i.type="transform",e.length===1&&(i.key=`translate${e.toUpperCase()}`)),jt.test(e)&&(i.type="color"),Zt.test(e)&&(i.type="filter",i.key=e.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),e.startsWith("opa")&&(i.key="opacity")),y(t)){const a=t.length;if(a<2)return;const r=y(n)?n:[];for(let o=0;o<a;o++){const h=t[o],l=a-i.offset.length;mt(e,h,o,l,i,n,r)}return pt(e,i.units),ft(i.value,n,r),i.ease=r,i}if(A(t)&&!y(t)){const a=t.value.length;if(a<2)return;const r=y(n)?n:[];for(let p=0;p<a;p++){const u=t.value[p],f=a-i.offset.length;mt(e,u,p,f,i,n,r)}pt(e,i.units),ft(i.value,n,r);const{value:o,ease:h,offset:l,...c}=t;return{...i,...c,ease:h||r,offset:l||i.offset,autoplay:i.autoplay,playRate:i.playRate}}}}function Lt(e){const{autoplay:t,direction:s,playRate:i,duration:n,delay:a,endDelay:r,repeat:o,ease:h,force3d:l,...c}=e,p=l??!0,u=Object.keys(c),f=[],d={autoplay:t,direction:s,playRate:i,duration:n,delay:a,endDelay:r,repeat:o,ease:h};for(let g=0,v=u.length;g<v;g++){const S=u[g],N=c[S],k=Ht(S,N,d);k&&f.push(k)}return f.length||f.push(d),{options:f,force3d:p}}function dt(e){return e.reduce((t,s)=>t.data.maxDuration>s.data.maxDuration?t:s)}class Gt{#s;#r=[];constructor(t,s){for(let i=0,n=s.options.length;i<n;i++){const a=new Bt(t,s.options[i],s.force3d);this.#r.push(a)}this.#s=dt(this.#r)}#i(t,s){this.#r.forEach(i=>i[t]=s)}#e(t){this.#r.forEach(s=>s[t]())}onRender(t){this.#s.onRender=t}onComplete(t){this.#s.onComplete=t}play(){this.#e("play")}pause(){this.#e("pause")}stop(){this.#e("stop")}cancel(){this.#e("cancel")}finish(){this.#e("finish")}reverse(){this.#e("reverse")}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#i("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#i("playRate",t)}get data(){return this.#s.data}}class Qt{#s;#r=[];#i;#e;#o;#l;#h;#c;constructor(t,s){this.#i=s.onPlay,this.#e=s.onPause,this.#o=s.onStop,this.#l=s.onReverse;const i=Y(t),n=Lt(s);for(let a=0,r=i.length;a<r;a++){const o=i[a],h=new Gt({value:o,index:a,total:r},n);this.#r.push(h)}this.#s=dt(this.#r),this.#s.onComplete(()=>this.#h?.(this.data)),s.onUpdate&&this.#s.onRender(()=>s.onUpdate?.(this.data,i)),s.onStart?.(this.data),this.finished.then(()=>{this.#s.data.playState="finished",this.#s.data.promiseState="fulfilled",s.onComplete?.(this.data)}).catch(a=>{this.#s.data.playState="idle",this.#s.data.promiseState="rejected",s.onCancel?.(this.data,a)})}#u(t,s){this.#r.forEach(i=>i[t]=s)}#n(t){this.#r.forEach(s=>s[t]())}finished=new Promise((t,s)=>{this.#h=t,this.#c=s});play(){this.#n("play"),this.#i?.(this.data)}pause(){this.#n("pause"),this.#e?.(this.data)}stop(){this.#n("stop"),this.#c?.(!1),this.#o?.(this.data)}cancel(){this.#n("cancel"),this.#c?.(!1)}finish(){this.#n("finish"),this.#h?.(this.data)}reverse(){this.#n("reverse"),this.#l?.(this.data)}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#u("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#u("playRate",t)}get data(){return Object.freeze({...this.#s.data})}}function Xt(e,t){return new Qt(e,t)}return m.Driver=st,m.animate=Xt,m.cancelFrame=F,m.clamp=P,m.createDriverData=et,m.createRenderBatcher=_,m.createRenderStep=J,m.frame=j,m.getElements=Y,m.hexToRgba=G,m.hslaToRgba=Q,m.interpolate=R,m.mix=T,m.mixColor=q,m.msToSec=E,m.pipe=z,m.progress=C,m.round=gt,m.secToMs=$,m.setStyle=M,m.stagger=Et,m.state=U,m}({}); |
@@ -1,1 +0,1 @@ | ||
/*! effekt 0.1.0 | https://github.com/ivodolenc/effekt | MIT License | Ivo Dolenc (c) 2024 */(function(c,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Effekt={}))})(this,function(c){"use strict";function y(e){return e*1e3}function E(e){return e/1e3}function yt(e,t=2){return t=10**t,Math.round(e*t)/t}function C(e,t,s){return Math.min(Math.max(s,e),t)}function T(e,t,s){return-s*e+s*t+e}function B(e,t,s){const i=e*e;return Math.sqrt(Math.max(0,s*(t*t-i)+i))}function P(e,t,s){const i=t-e;return i===0?1:(s-e)/i}function z(...e){return t=>e.reduce((s,i)=>i(s),t)}const vt=e=>Object.prototype.toString.call(e).slice(8,-1),w=e=>typeof e=="number"&&!isNaN(e),Rt=e=>typeof e=="string",$=e=>e===null,O=e=>typeof e>"u",W=e=>vt(e)==="Object",v=e=>Array.isArray(e),Tt=e=>e instanceof Function,wt=e=>e instanceof Element,St=e=>e instanceof HTMLElement,$t=e=>e instanceof SVGElement,H=e=>!!(e&&(St(e)||$t(e)));function xt(e,t){return s=>T(e,t,s)}function Dt(e,t){return s=>{const i=[],r=[];for(let n=0,a=e.length;n<a;n++)i.push(o=>T(e[n],t[n],o)),r[n]=i[n](s);return r}}function L(e,t){return s=>{const i=[],r=[],{round:n}=Math,a=3;for(let o=0;o<a;o++)i.push(h=>B(e[o],t[o],h)),r[o]=n(C(0,255,i[o](s)));return i.push(o=>T(e[a],t[a],o)),r[a]=n(C(0,1,i[a](s))*1e5)/1e5,r}}function bt(e,t){return s=>{const i=[],r=[];for(let n=0,a=e.length;n<a;n++)w(e[n])?i.push(o=>T(e[n],t[n],o)):i.push(o=>L(e[n],t[n])(o)),r[n]=i[n](s);return r}}function Mt(e,t={}){return t.type==="color"?L:t.type==="shadow"?bt:v(e)?Dt:xt}function kt(e,t={}){const{ease:s,type:i}=t,r=[],n=Mt(e[0],{type:i});for(let a=0,o=e.length-1;a<o;a++){let h=n(e[a],e[a+1]);if(s){const l=v(s)?s[a]:s;h=z(l,h)}r.push(h)}return r}function R(e,t,s={}){const i=t.length,r=i-1;t[0]>t[r]&&(t=[...t].reverse(),e=[...e].reverse());const n=kt(e,s),a=n.length;return o=>{let h=0;if(a>1)for(;h<i-2&&!(o<t[h+1]);h++);const l=P(t[h],t[h+1],o);return n[h](l)}}function G(e){let t=e.slice(1);t.length===3&&(t=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`);const s=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16),n=parseInt(t.slice(6,8),16)/255||1;return[s,i,r,n]}function A(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+(t-e)*6*s:s<1/2?t:s<2/3?e+(t-e)*(2/3-s)*6:e}function Q(e,t,s,i){let r,n,a;if(e/=360,t/=100,s/=100,t===0)r=n=a=s;else{const{round:o}=Math,h=s<.5?s*(1+t):s+t-s*t,l=2*s-h;r=o(A(l,h,e+1/3)*255),n=o(A(l,h,e)*255),a=o(A(l,h,e-1/3)*255)}return[r,n,a,i]}function Et(e,t){if(w(e))return e;if(e==="first")return 0;const s=t-1;return e==="last"?s:s/2}function Ct(e=.1,t={}){const{delay:s=0,from:i=0,ease:r,grid:n,axis:a}=t,{floor:o,sqrt:h,abs:l}=Math;return(u,p)=>{const f=Et(i,p),d=!w(f)&&f==="center";let m=0;if(!n)m=l(f-u);else{const S=d?(n[0]-1)/2:f%n[0],M=d?(n[1]-1)/2:o(f/n[0]),N=u%n[0],k=o(u/n[0]),Z=S-N,V=M-k;let q=h(Z*Z+V*V);a==="x"&&(q=-Z),a==="y"&&(q=-V),m=q}let g=e*m;if(r){const S=p*e;g=r(g/S)*S}return s+g}}function X(e){const t=[];if(e)for(let s=0,i=e.length;s<i;s++){const r=e[s];H(r)&&t.push(r)}return t}function Y(e){if(wt(e)){if(H(e))return[e]}else if(Rt(e)){const t=X(document.querySelectorAll(e));if(t.length)return t}else{const t=X(e);if(t.length)return t}throw new TypeError("Animation target not found.")}function x(e,t,s){const i=t;if(!O(e.style[i]))return e.style[i]=s;throw new TypeError(`Unsupported '${t}' property.`)}class J{order=[];scheduled=new Set;add(t){if(!this.scheduled.has(t))return this.scheduled.add(t),this.order.push(t),!0}remove(t){const s=this.order.indexOf(t);s!==-1&&(this.order.splice(s,1),this.scheduled.delete(t))}clear(){this.order.length=0,this.scheduled.clear()}}function _(e){let t=new J,s=new J,i=0,r=!1,n=!1;const a=new WeakSet,o={schedule:(h,l=!1,u=!1)=>{const p=u&&r,f=p?t:s;return l&&a.add(h),f.add(h)&&p&&r&&(i=t.order.length),h},cancel:h=>{s.remove(h),a.delete(h)},process:h=>{if(r){n=!0;return}if(r=!0,[t,s]=[s,t],s.clear(),i=t.order.length,i)for(let l=0;l<i;l++){const u=t.order[l];u(h),a.has(u)&&(o.schedule(u),e())}r=!1,n&&(n=!1,o.process(h))}};return o}const b=["read","update","render"],Pt=40;function tt(e=requestAnimationFrame,t=!0){let s=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},n=b.reduce((l,u)=>(l[u]=_(()=>s=!0),l),{}),a=l=>{n[l].process(r)},o=()=>{const l=performance.now();s=!1,r.delta=i?1e3/60:Math.max(Math.min(l-r.timestamp,Pt),1),r.timestamp=l,r.isProcessing=!0,b.forEach(a),r.isProcessing=!1,s&&t&&(i=!1,e(o))},h=()=>{s=!0,i=!0,r.isProcessing||e(o)};return{schedule:b.reduce((l,u)=>{const p=n[u];return l[u]=(f,d=!1,m=!1)=>(s||h(),p.schedule(f,d,m)),l},{}),cancel:l=>b.forEach(u=>n[u].cancel(l)),state:r}}const{schedule:j,cancel:F,state:U}=tt();function et(e,t,s){return e&&!O(t)&&!O(s)?Tt(e)?y(e(t,s)):y(e):0}function Ot(e){return e?e===1/0?1e3:e+1:1}function st(e={}){const{el:t}=e,s=new WeakMap;s.set(t.value,{delta:0,timestamp:0,playState:"idle",promiseState:"pending",time:0,initTime:0,startTime:0,pauseTime:null,totalDuration:600,maxDuration:600,progress:0,totalProgress:1,isReverse:!1,autoplay:e.autoplay??!0,direction:e.direction||"normal",playRate:e.playRate||1,duration:y(e.duration||.6),delay:et(e.delay,t?.index,t?.total),endDelay:et(e.endDelay,t?.index,t?.total),repeat:Ot(e.repeat)});const i=s.get(t.value);return i.totalDuration=i.duration*i.repeat,i.maxDuration=i.totalDuration+i.delay+i.endDelay,i}class it{#s={};#a=new WeakMap;#i;#e;#o=!1;#l=!1;#h=0;constructor(t,s={}){const{onRender:i,onComplete:r}=s;this.#a.set(this.#s,t),i&&(this.#i=new WeakMap,this.#i.set(this.#s,i)),r&&(this.#e=new WeakMap,this.#e.set(this.#s,r)),this.#t.autoplay&&this.play()}#c(){this.#o||(j.update(this.#r,!0),this.#n(!0),this.#o=!0)}#u(){this.#o&&(F(this.#r),this.#i&&F(this.#i.get(this.#s)),this.#o=!1)}#n(t=!1){this.#i&&j.render(this.#i.get(this.#s),t)}#r=({timestamp:t,delta:s})=>{this.#t.timestamp=t,this.#t.delta=s;let i=0;$(this.#t.pauseTime)?this.#t.playRate<0?(this.#l||(this.#l=!0,this.#h=t,this.#t.startTime=this.#t.progress===0?t*this.#t.playRate:this.#t.totalDuration-t-this.#t.time),i=t-this.#t.startTime/this.#t.playRate):this.#t.playRate>0&&(this.#l&&(this.#l=!1,this.#t.startTime=this.#t.progress===0?(t-this.#h)*2+this.#t.initTime:this.#h-(this.#t.totalDuration-t-this.#t.time+this.#h)),i=(t-this.#t.startTime)*this.#t.playRate):i=this.#t.pauseTime,this.#t.time=i,i=Math.max(i-this.#t.delay,0),this.#t.playState==="finished"&&$(this.#t.pauseTime)&&(i=this.#t.totalDuration);const r=i/this.#t.duration;let n=Math.floor(r),a=r%1;!a&&r>=1&&(a=1),a===1&&n--;const o=n%2,h=this.#t.repeat%2,l=this.#t.direction;this.#t.playRate<0||l==="reverse"||l==="alternate"&&o||l==="alternate-reverse"&&!o?(this.#t.isReverse=!0,this.#t.totalProgress=0,l==="alternate"&&h?this.#t.totalProgress=1:l==="alternate-reverse"&&!h&&(this.#t.totalProgress=1),a=1-a):this.#t.isReverse=!1,this.#t.progress=i>=this.#t.totalDuration?this.#t.totalProgress:Math.min(a,1),$(this.#t.pauseTime)&&(this.#t.playState==="finished"||i>=this.#t.totalDuration+this.#t.endDelay)&&(this.#t.playState="finished",this.#u(),this.#n(),this.#e?.get(this.#s)?.())};#p(t){t<0&&(this.#t.totalProgress=0),t>0&&(this.#t.totalProgress=1),this.#t.playRate=t}now(){return U.isProcessing?U.timestamp:performance.now()}play(){if(this.#o)return;const t=this.now();$(this.#t.pauseTime)?this.#t.startTime||(this.#t.initTime=t,this.#t.startTime=t):this.#t.startTime=t-this.#t.pauseTime,this.#t.pauseTime=null,this.#t.playState="running",this.#c()}pause(){this.#t.playState="paused",this.#t.pauseTime=this.#t.time}stop(){this.#t.playState="idle",this.#u(),this.#n()}cancel(){this.#t.playState="idle",this.#u(),this.currentTime=0,this.#n()}finish(){this.#t.playState="finished",this.#u(),this.currentTime=E(this.#t.totalDuration),this.#n()}reverse(){this.#t.playRate===0||this.#t.progress===0||this.#t.progress===1||(this.#t.playRate>0?(this.playRate=1,this.playRate=-1):this.#t.playRate<0&&(this.playRate=-1,this.playRate=1))}get#t(){return this.#a.get(this.#s)}get currentTime(){return E(this.#t.time)}set currentTime(t){const s=y(t);this.#t.time=s,!$(this.#t.pauseTime)||!this.#o||this.#t.playRate===0?this.#t.pauseTime=s:this.#t.startTime=this.now()-s/this.#t.playRate}get playRate(){return this.#t.playRate}set playRate(t){if(t!==this.#t.playRate){if(t===0&&this.#o){this.#t.playRate=0,this.pause();return}if(t!==0&&!this.#o){this.#p(t),this.play();return}this.#p(t)}}}const nt=(...e)=>new RegExp(e.map(t=>t.source).join("|")),Wt=/\((.*?)\)/,At=/(-?[0-9.]+)/g,jt=/^\d+$/,rt=/^(#|rgb|hsl)/,Ft=/(color|background)/i,Ut=/(px|pt|pc|in|cm|mm|em|rem|%|ex|ch|fr|vw|vh|vmin|vmax|deg|rad|turn)/,at=/^(x|y|z|translate|perspective)/,It=/(width|height|margin|padding|inset|top|right|bottom|left)/i,ot=/^(rotate|skew)/,Kt=/^scale/,Nt=nt(at,ot,Kt),Zt=nt(at,It),I=/shadow/i,Vt=/(blur|bright|contrast|dropShadow|gray|hue|invert|opacityFilter|saturate|sepia)/i,D=new WeakMap,K=new WeakMap;class qt{#s=new WeakMap;#a=new WeakMap;#i;#e;constructor(t,s,i){const{type:r,key:n,value:a,units:o,ease:h,offset:l,...u}=s;this.#e=t.value,this.#s.set(this.#e,st({el:t,...u})),this.#a.set(this.#e,{transform:!1,color:!1,other:!1,otherShadow:!1,filter:!1,filterShadow:!1}),r==="transform"&&(this.#r.transform=!0,D.set(this.#e,{}),i&&(n!=="translateZ"&&(D.get(this.#e).translateZ="translateZ(0)"),t.value.style.willChange="transform")),r==="color"&&(this.#r.color=!0),r==="other"&&(this.#r.other=!0,I.test(n)&&(this.#r.otherShadow=!0)),r==="filter"&&(this.#r.filter=!0,I.test(n)&&(this.#r.filterShadow=!0),K.set(this.#e,{}));const p=()=>{this.#r.transform&&(this.#c(s),this.#h("transform",D)),this.#r.color&&this.#o(s),this.#r.other&&this.#l(s,this.#r.otherShadow),this.#r.filter&&(this.#u(s,this.#r.filterShadow),this.#h("filter",K)),this.onRender()},f=()=>{this.#r.transform&&i&&(n!=="translateZ"&&(D.get(this.#e).translateZ=""),t.value.style.willChange="auto"),this.onComplete()};this.#i=new it(this.#n,{onRender:p,onComplete:f})}#o(t){const{key:s,value:i,ease:r,offset:n}=t,a=R(i,n,{ease:r,type:"color"})(this.#n.progress);x(this.#e,s,`rgba(${a})`)}#l(t,s){const{key:i,value:r,units:n,ease:a,offset:o}=t,[h]=n,l=this.#n.progress;if(s){const u=R(r,o,{ease:a,type:"shadow"})(l);let p="";for(let f=0,d=u.length;f<d;f++){const m=u[f];w(m)?p+=`${m}${h||"px"} `:p+=`rgba(${m})`}x(this.#e,i,p)}else{const u=R(r,o,{ease:a})(l);x(this.#e,i,`${u}${h}`)}}#h(t,s){const i=Object.values(s.get(this.#e)).join(" ");x(this.#e,t,i)}#c(t){const{key:s,value:i,units:r,ease:n,offset:a}=t,[o]=r,h=R(i,a,{ease:n})(this.#n.progress);D.get(this.#e)[s]=`${s}(${h}${o})`}#u(t,s){const{key:i,value:r,units:n,ease:a,offset:o}=t,[h]=n,l=this.#n.progress,u=K.get(this.#e);if(s){const p=R(r,o,{ease:a,type:"shadow"})(l);let f="";for(let d=0,m=p.length;d<m;d++){const g=p[d];w(g)?f+=`${g}${h||"px"} `:f+=`rgba(${g})`}u[i]=`${i}(${f})`}else{const p=R(r,o,{ease:a})(l);u[i]=`${i}(${p}${h})`}}onRender(){}onComplete(){}play(){this.#i.play()}pause(){this.#i.pause()}stop(){this.#i.stop()}cancel(){this.#i.cancel()}finish(){this.#i.finish()}reverse(){this.#i.reverse()}get#n(){return this.#s.get(this.#e)}get#r(){return this.#a.get(this.#e)}get currentTime(){return this.#i.currentTime}set currentTime(t){this.#i.currentTime=t}get playRate(){return this.#i.playRate}set playRate(t){this.#i.playRate=t}get data(){return this.#n}}const ht=(e=>t=>1-e(1-t))(e=>Math.pow(e,4));function Bt(e,t){const s=e[e.length-1],i=P(0,t,1);return T(s,1,i)}function lt(e,t){return Zt.test(e)?{value:t,unit:"px"}:ot.test(e)?{value:t,unit:"deg"}:{value:t,unit:""}}function ut(e){const t=e.split(At),s=parseFloat(t[1]),i=t[2];return{value:s,unit:i}}function ct(e){const t="";if(e.startsWith("#"))return{value:G(e),unit:t};const s=e.match(Wt)[1].split(",").map(Number);return e.startsWith("rgb")?{value:[s[0],s[1],s[2],s[3]||1],unit:t}:{value:Q(s[0],s[1],s[2],s[3]||1),unit:t}}function zt(e,t){const s=window.getComputedStyle(document.documentElement);return pt(e,s.getPropertyValue(t))}function Ht(e){const t=e.split(" "),s=[],i=[];for(let r=0,n=t.length;r<n;r++){const a=t[r],o=rt.test(a)?ct(a):ut(a);s.push(o.value),i.push(o.unit)}return{value:s,unit:i[0]}}function pt(e,t){if(w(t))return lt(e,t);if(t.startsWith("--"))return zt(e,t);if(jt.test(t))return lt(e,parseFloat(t));if(rt.test(t))return ct(t);if(I.test(e))return Ht(t);if(Ut.test(t))return ut(t);throw new TypeError(`Unsupported value '${t}' in '${e}' property.`)}function ft(e,t){if(t.size>1)throw new TypeError(`All units of '${e}' property must be of the same type.`)}function dt(e,t,s){if(v(t)&&t.length<e.length)for(;t.length<e.length;)s.push(ht)}function mt(e,t,s,i,r,n,a){const o=W(t)?t.offset:void 0,h=W(t)?t.value:t,l=s===0?o||0:o||Bt(r.offset,i);r.offset.push(l);const u=pt(e,h);r.value.push(u.value),r.units.add(u.unit),v(n)||a.push(n)}function Lt(e,t,s={}){const i={type:"other",key:e,value:[],offset:[],units:new Set,...s},r=i.ease||ht;if(!e.startsWith("on")){if(Nt.test(e)&&(i.type="transform",e.length===1&&(i.key=`translate${e.toUpperCase()}`)),Ft.test(e)&&(i.type="color"),Vt.test(e)&&(i.type="filter",i.key=e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),e.startsWith("opa")&&(i.key="opacity")),v(t)){const n=t.length;if(n<2)return;const a=v(r)?r:[];for(let o=0;o<n;o++){const h=t[o],l=n-i.offset.length;mt(e,h,o,l,i,r,a)}return ft(e,i.units),dt(i.value,r,a),i.ease=a,i}if(W(t)&&!v(t)){const n=t.value.length;if(n<2)return;const a=v(r)?r:[];for(let p=0;p<n;p++){const f=t.value[p],d=n-i.offset.length;mt(e,f,p,d,i,r,a)}ft(e,i.units),dt(i.value,r,a);const{value:o,ease:h,offset:l,...u}=t;return{...i,...u,ease:h||a,offset:l||i.offset,autoplay:i.autoplay,playRate:i.playRate}}}}function Gt(e){const{autoplay:t,direction:s,playRate:i,duration:r,delay:n,endDelay:a,repeat:o,ease:h,force3d:l,...u}=e,p=l??!0,f=Object.keys(u),d=[],m={autoplay:t,direction:s,playRate:i,duration:r,delay:n,endDelay:a,repeat:o,ease:h};for(let g=0,S=f.length;g<S;g++){const M=f[g],N=u[M],k=Lt(M,N,m);k&&d.push(k)}return d.length||d.push(m),{options:d,force3d:p}}function gt(e){return e.reduce((t,s)=>t.data.maxDuration>s.data.maxDuration?t:s)}class Qt{#s;#a=[];constructor(t,s){for(let i=0,r=s.options.length;i<r;i++){const n=new qt(t,s.options[i],s.force3d);this.#a.push(n)}this.#s=gt(this.#a)}#i(t,s){this.#a.forEach(i=>i[t]=s)}#e(t){this.#a.forEach(s=>s[t]())}onRender(t){this.#s.onRender=t}onComplete(t){this.#s.onComplete=t}play(){this.#e("play")}pause(){this.#e("pause")}stop(){this.#e("stop")}cancel(){this.#e("cancel")}finish(){this.#e("finish")}reverse(){this.#e("reverse")}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#i("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#i("playRate",t)}get data(){return this.#s.data}}class Xt{#s;#a=[];#i;#e;#o;#l;#h;#c;constructor(t,s){this.#i=s.onPlay,this.#e=s.onPause,this.#o=s.onStop,this.#l=s.onReverse;const i=Y(t),r=Gt(s);for(let n=0,a=i.length;n<a;n++){const o=i[n],h=new Qt({value:o,index:n,total:a},r);this.#a.push(h)}this.#s=gt(this.#a),this.#s.onComplete(()=>this.#h?.(this.data)),s.onUpdate&&this.#s.onRender(()=>s.onUpdate?.(this.data,i)),s.onStart?.(this.data),this.finished.then(()=>{this.#s.data.playState="finished",this.#s.data.promiseState="fulfilled",s.onComplete?.(this.data)}).catch(n=>{this.#s.data.playState="idle",this.#s.data.promiseState="rejected",s.onCancel?.(this.data,n)})}#u(t,s){this.#a.forEach(i=>i[t]=s)}#n(t){this.#a.forEach(s=>s[t]())}finished=new Promise((t,s)=>{this.#h=t,this.#c=s});play(){this.#n("play"),this.#i?.(this.data)}pause(){this.#n("pause"),this.#e?.(this.data)}stop(){this.#n("stop"),this.#c?.(!1),this.#o?.(this.data)}cancel(){this.#n("cancel"),this.#c?.(!1)}finish(){this.#n("finish"),this.#h?.(this.data)}reverse(){this.#n("reverse"),this.#l?.(this.data)}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#u("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#u("playRate",t)}get data(){return Object.freeze({...this.#s.data})}}function Yt(e,t){return new Xt(e,t)}c.Driver=it,c.animate=Yt,c.cancelFrame=F,c.clamp=C,c.createDriverData=st,c.createRenderBatcher=tt,c.createRenderStep=_,c.frame=j,c.getElements=Y,c.hexToRgba=G,c.hslaToRgba=Q,c.interpolate=R,c.mix=T,c.mixColor=B,c.msToSec=E,c.pipe=z,c.progress=P,c.round=yt,c.secToMs=y,c.setStyle=x,c.stagger=Ct,c.state=U}); | ||
/*! effekt 0.2.0 | https://github.com/ivodolenc/effekt | MIT License | Ivo Dolenc (c) 2024 */(function(c,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(c=typeof globalThis<"u"?globalThis:c||self,g(c.Effekt={}))})(this,function(c){"use strict";function g(e){return e*1e3}function E(e){return e/1e3}function yt(e,t=2){return t=10**t,Math.round(e*t)/t}function P(e,t,s){return Math.min(Math.max(s,e),t)}function w(e,t,s){return-s*e+s*t+e}function q(e,t,s){const i=e*e;return Math.sqrt(Math.max(0,s*(t*t-i)+i))}function C(e,t,s){const i=t-e;return i===0?1:(s-e)/i}function z(...e){return t=>e.reduce((s,i)=>i(s),t)}const gt=e=>Object.prototype.toString.call(e).slice(8,-1),S=e=>typeof e=="number"&&!isNaN(e),vt=e=>typeof e=="string",x=e=>e===null,W=e=>typeof e>"u",A=e=>gt(e)==="Object",v=e=>Array.isArray(e),Rt=e=>e instanceof Function,Tt=e=>e instanceof Element,wt=e=>e instanceof HTMLElement,St=e=>e instanceof SVGElement,H=e=>!!(e&&(wt(e)||St(e)));function $t(e,t){return s=>w(e,t,s)}function xt(e,t){return s=>{const i=[],n=[];for(let a=0,r=e.length;a<r;a++)i.push(o=>w(e[a],t[a],o)),n[a]=i[a](s);return n}}function L(e,t){return s=>{const i=[],n=[],{round:a}=Math,r=3;for(let o=0;o<r;o++)i.push(h=>q(e[o],t[o],h)),n[o]=a(P(0,255,i[o](s)));return i.push(o=>w(e[r],t[r],o)),n[r]=a(P(0,1,i[r](s))*1e5)/1e5,n}}function Dt(e,t){return s=>{const i=[],n=[];for(let a=0,r=e.length;a<r;a++)S(e[a])?i.push(o=>w(e[a],t[a],o)):i.push(o=>L(e[a],t[a])(o)),n[a]=i[a](s);return n}}function bt(e,t={}){return t.type==="color"?L:t.type==="shadow"?Dt:v(e)?xt:$t}function Mt(e,t={}){const{ease:s,type:i}=t,n=[],a=bt(e[0],{type:i});for(let r=0,o=e.length-1;r<o;r++){let h=a(e[r],e[r+1]);if(s){const l=v(s)?s[r]:s;h=z(l,h)}n.push(h)}return n}function T(e,t,s={}){const i=t.length,n=i-1;t[0]>t[n]&&(t=[...t].reverse(),e=[...e].reverse());const a=Mt(e,s),r=a.length;return o=>{let h=0;if(r>1)for(;h<i-2&&!(o<t[h+1]);h++);const l=C(t[h],t[h+1],o);return a[h](l)}}function G(e){let t=e.slice(1);t.length===3&&(t=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`);const s=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)/255||1;return[s,i,n,a]}function O(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+(t-e)*6*s:s<1/2?t:s<2/3?e+(t-e)*(2/3-s)*6:e}function Q(e,t,s,i){let n,a,r;if(e/=360,t/=100,s/=100,t===0)n=a=r=s;else{const{round:o}=Math,h=s<.5?s*(1+t):s+t-s*t,l=2*s-h;n=o(O(l,h,e+1/3)*255),a=o(O(l,h,e)*255),r=o(O(l,h,e-1/3)*255)}return[n,a,r,i]}function kt(e,t){if(S(e))return e;if(e==="first")return 0;const s=t-1;return e==="last"?s:s/2}function Et(e=.1,t={}){const{delay:s=0,from:i=0,ease:n,grid:a,axis:r}=t,{floor:o,sqrt:h,abs:l}=Math;return(p,f)=>{const u=kt(i,f),m=!S(u)&&u==="center";let d=0;if(!a)d=l(u-p);else{const R=m?(a[0]-1)/2:u%a[0],$=m?(a[1]-1)/2:o(u/a[0]),N=p%a[0],k=o(p/a[0]),Z=R-N,B=$-k;let V=h(Z*Z+B*B);r==="x"&&(V=-Z),r==="y"&&(V=-B),d=V}let y=e*d;if(n){const R=f*e;y=n(y/R)*R}return s+y}}function X(e){const t=[];if(e)for(let s=0,i=e.length;s<i;s++){const n=e[s];H(n)&&t.push(n)}return t}function Y(e){if(Tt(e)){if(H(e))return[e]}else if(vt(e)){const t=X(document.querySelectorAll(e));if(t.length)return t}else{const t=X(e);if(t.length)return t}throw new TypeError("Animation target not found.")}function D(e,t,s){const i=t;if(!W(e.style[i]))return e.style[i]=s;throw new TypeError(`Unsupported '${t}' property.`)}function J(e){let t=new Set,s=new Set,i=!1,n=!1;const a=new WeakSet;let r={delta:0,timestamp:0,isProcessing:!1};function o(l){a.has(l)&&(h.schedule(l),e()),l(r)}const h={schedule:(l,p=!1,f=!1)=>{const u=f&&i?t:s;return p&&a.add(l),u.has(l)||u.add(l),l},cancel:l=>{s.delete(l),a.delete(l)},process:l=>{if(r=l,i){n=!0;return}i=!0,[t,s]=[s,t],s.clear(),t.forEach(o),i=!1,n&&(n=!1,h.process(l))}};return h}const M=["read","update","render"],Pt=40;function _(e=requestAnimationFrame,t=!0){let s=!1,i=!0;const n={delta:0,timestamp:0,isProcessing:!1},a=()=>s=!0,r=M.reduce((u,m)=>(u[m]=J(a),u),{}),{read:o,update:h,render:l}=r,p=()=>{const u=performance.now();s=!1,n.delta=i?1e3/60:Math.max(Math.min(u-n.timestamp,Pt),1),n.timestamp=u,n.isProcessing=!0,o.process(n),h.process(n),l.process(n),n.isProcessing=!1,s&&t&&(i=!1,e(p))},f=()=>{s=!0,i=!0,n.isProcessing||e(p)};return{schedule:M.reduce((u,m)=>{const d=r[m];return u[m]=(y,R=!1,$=!1)=>(s||f(),d.schedule(y,R,$)),u},{}),cancel:u=>{for(let m=0;m<M.length;m++)r[M[m]].cancel(u)},state:n}}const{schedule:j,cancel:F,state:U}=_();function tt(e,t,s){return e&&!W(t)&&!W(s)?Rt(e)?g(e(t,s)):g(e):0}function Ct(e){return e?e===1/0?1e3:e+1:1}function et(e={}){const{el:t}=e,s=new WeakMap;s.set(t.value,{delta:0,timestamp:0,playState:"idle",promiseState:"pending",time:0,initTime:0,startTime:0,pauseTime:null,totalDuration:600,maxDuration:600,progress:0,totalProgress:1,isReverse:!1,autoplay:e.autoplay??!0,direction:e.direction||"normal",playRate:e.playRate||1,duration:g(e.duration||.6),delay:tt(e.delay,t?.index,t?.total),endDelay:tt(e.endDelay,t?.index,t?.total),repeat:Ct(e.repeat)});const i=s.get(t.value);return i.totalDuration=i.duration*i.repeat,i.maxDuration=i.totalDuration+i.delay+i.endDelay,i}class st{#s={};#r=new WeakMap;#i;#e;#o=!1;#l=!1;#h=0;constructor(t,s={}){const{onRender:i,onComplete:n}=s;this.#r.set(this.#s,t),i&&(this.#i=new WeakMap,this.#i.set(this.#s,i)),n&&(this.#e=new WeakMap,this.#e.set(this.#s,n)),this.#t.autoplay&&this.play()}#c(){this.#o||(j.update(this.#a,!0),this.#n(!0),this.#o=!0)}#u(){this.#o&&(F(this.#a),this.#i&&F(this.#i.get(this.#s)),this.#o=!1)}#n(t=!1){this.#i&&j.render(this.#i.get(this.#s),t)}#a=({timestamp:t,delta:s})=>{this.#t.timestamp=t,this.#t.delta=s;let i=0;x(this.#t.pauseTime)?this.#t.playRate<0?(this.#l||(this.#l=!0,this.#h=t,this.#t.startTime=this.#t.progress===0?t*this.#t.playRate:this.#t.totalDuration-t-this.#t.time),i=t-this.#t.startTime/this.#t.playRate):this.#t.playRate>0&&(this.#l&&(this.#l=!1,this.#t.startTime=this.#t.progress===0?(t-this.#h)*2+this.#t.initTime:this.#h-(this.#t.totalDuration-t-this.#t.time+this.#h)),i=(t-this.#t.startTime)*this.#t.playRate):i=this.#t.pauseTime,this.#t.time=i,i=Math.max(i-this.#t.delay,0),this.#t.playState==="finished"&&x(this.#t.pauseTime)&&(i=this.#t.totalDuration);const n=i/this.#t.duration;let a=Math.floor(n),r=n%1;!r&&n>=1&&(r=1),r===1&&a--;const o=a%2,h=this.#t.repeat%2,l=this.#t.direction;this.#t.playRate<0||l==="reverse"||l==="alternate"&&o||l==="alternate-reverse"&&!o?(this.#t.isReverse=!0,this.#t.totalProgress=0,l==="alternate"&&h?this.#t.totalProgress=1:l==="alternate-reverse"&&!h&&(this.#t.totalProgress=1),r=1-r):this.#t.isReverse=!1,this.#t.progress=i>=this.#t.totalDuration?this.#t.totalProgress:Math.min(r,1),x(this.#t.pauseTime)&&(this.#t.playState==="finished"||i>=this.#t.totalDuration+this.#t.endDelay)&&(this.#t.playState="finished",this.#u(),this.#n(),this.#e?.get(this.#s)?.())};#p(t){t<0&&(this.#t.totalProgress=0),t>0&&(this.#t.totalProgress=1),this.#t.playRate=t}now(){return U.isProcessing?U.timestamp:performance.now()}play(){if(this.#o)return;const t=this.now();x(this.#t.pauseTime)?this.#t.startTime||(this.#t.initTime=t,this.#t.startTime=t):this.#t.startTime=t-this.#t.pauseTime,this.#t.pauseTime=null,this.#t.playState="running",this.#c()}pause(){this.#t.playState="paused",this.#t.pauseTime=this.#t.time}stop(){this.#t.playState="idle",this.#u(),this.#n()}cancel(){this.#t.playState="idle",this.#u(),this.currentTime=0,this.#n()}finish(){this.#t.playState="finished",this.#u(),this.currentTime=E(this.#t.totalDuration),this.#n()}reverse(){this.#t.playRate===0||this.#t.progress===0||this.#t.progress===1||(this.#t.playRate>0?(this.playRate=1,this.playRate=-1):this.#t.playRate<0&&(this.playRate=-1,this.playRate=1))}get#t(){return this.#r.get(this.#s)}get currentTime(){return E(this.#t.time)}set currentTime(t){const s=g(t);this.#t.time=s,!x(this.#t.pauseTime)||!this.#o||this.#t.playRate===0?this.#t.pauseTime=s:this.#t.startTime=this.now()-s/this.#t.playRate}get playRate(){return this.#t.playRate}set playRate(t){if(t!==this.#t.playRate){if(t===0&&this.#o){this.#t.playRate=0,this.pause();return}if(t!==0&&!this.#o){this.#p(t),this.play();return}this.#p(t)}}}const it=(...e)=>new RegExp(e.map(t=>t.source).join("|")),Wt=/\((.*?)\)/,At=/(-?[0-9.]+)/g,Ot=/^\d+$/,nt=/^(#|rgb|hsl)/,jt=/(color|background)/i,Ft=/(px|pt|pc|in|cm|mm|em|rem|%|ex|ch|fr|vw|vh|vmin|vmax|deg|rad|turn)/,at=/^(x|y|z|translate|perspective)/,Ut=/(width|height|margin|padding|inset|top|right|bottom|left)/i,rt=/^(rotate|skew)/,It=/^scale/,Kt=it(at,rt,It),Nt=it(at,Ut),I=/shadow/i,Zt=/(blur|bright|contrast|dropShadow|gray|hue|invert|opacityFilter|saturate|sepia)/i,b=new WeakMap,K=new WeakMap;class Bt{#s=new WeakMap;#r=new WeakMap;#i;#e;constructor(t,s,i){const{type:n,key:a,value:r,units:o,ease:h,offset:l,...p}=s;this.#e=t.value,this.#s.set(this.#e,et({el:t,...p})),this.#r.set(this.#e,{transform:!1,color:!1,other:!1,otherShadow:!1,filter:!1,filterShadow:!1}),n==="transform"&&(this.#a.transform=!0,b.set(this.#e,{}),i&&(a!=="translateZ"&&(b.get(this.#e).translateZ="translateZ(0)"),t.value.style.willChange="transform")),n==="color"&&(this.#a.color=!0),n==="other"&&(this.#a.other=!0,I.test(a)&&(this.#a.otherShadow=!0)),n==="filter"&&(this.#a.filter=!0,I.test(a)&&(this.#a.filterShadow=!0),K.set(this.#e,{}));const f=()=>{this.#a.transform&&(this.#c(s),this.#h("transform",b)),this.#a.color&&this.#o(s),this.#a.other&&this.#l(s,this.#a.otherShadow),this.#a.filter&&(this.#u(s,this.#a.filterShadow),this.#h("filter",K)),this.onRender()},u=()=>{this.#a.transform&&i&&(a!=="translateZ"&&(b.get(this.#e).translateZ=""),t.value.style.willChange="auto"),this.onComplete()};this.#i=new st(this.#n,{onRender:f,onComplete:u})}#o(t){const{key:s,value:i,ease:n,offset:a}=t,r=T(i,a,{ease:n,type:"color"})(this.#n.progress);D(this.#e,s,`rgba(${r})`)}#l(t,s){const{key:i,value:n,units:a,ease:r,offset:o}=t,[h]=a,l=this.#n.progress;if(s){const p=T(n,o,{ease:r,type:"shadow"})(l);let f="";for(let u=0,m=p.length;u<m;u++){const d=p[u];S(d)?f+=`${d}${h||"px"} `:f+=`rgba(${d})`}D(this.#e,i,f)}else{const p=T(n,o,{ease:r})(l);D(this.#e,i,`${p}${h}`)}}#h(t,s){const i=Object.values(s.get(this.#e)).join(" ");D(this.#e,t,i)}#c(t){const{key:s,value:i,units:n,ease:a,offset:r}=t,[o]=n,h=T(i,r,{ease:a})(this.#n.progress);b.get(this.#e)[s]=`${s}(${h}${o})`}#u(t,s){const{key:i,value:n,units:a,ease:r,offset:o}=t,[h]=a,l=this.#n.progress,p=K.get(this.#e);if(s){const f=T(n,o,{ease:r,type:"shadow"})(l);let u="";for(let m=0,d=f.length;m<d;m++){const y=f[m];S(y)?u+=`${y}${h||"px"} `:u+=`rgba(${y})`}p[i]=`${i}(${u})`}else{const f=T(n,o,{ease:r})(l);p[i]=`${i}(${f}${h})`}}onRender(){}onComplete(){}play(){this.#i.play()}pause(){this.#i.pause()}stop(){this.#i.stop()}cancel(){this.#i.cancel()}finish(){this.#i.finish()}reverse(){this.#i.reverse()}get#n(){return this.#s.get(this.#e)}get#a(){return this.#r.get(this.#e)}get currentTime(){return this.#i.currentTime}set currentTime(t){this.#i.currentTime=t}get playRate(){return this.#i.playRate}set playRate(t){this.#i.playRate=t}get data(){return this.#n}}const ot=(e=>t=>1-e(1-t))(e=>Math.pow(e,4));function Vt(e,t){const s=e[e.length-1],i=C(0,t,1);return w(s,1,i)}function ht(e,t){return Nt.test(e)?{value:t,unit:"px"}:rt.test(e)?{value:t,unit:"deg"}:{value:t,unit:""}}function lt(e){const t=e.split(At),s=parseFloat(t[1]),i=t[2];return{value:s,unit:i}}function ut(e){const t="";if(e.startsWith("#"))return{value:G(e),unit:t};const s=e.match(Wt)[1].split(",").map(Number);return e.startsWith("rgb")?{value:[s[0],s[1],s[2],s[3]||1],unit:t}:{value:Q(s[0],s[1],s[2],s[3]||1),unit:t}}function qt(e,t){const s=window.getComputedStyle(document.documentElement);return ct(e,s.getPropertyValue(t))}function zt(e){const t=e.split(" "),s=[],i=[];for(let n=0,a=t.length;n<a;n++){const r=t[n],o=nt.test(r)?ut(r):lt(r);s.push(o.value),i.push(o.unit)}return{value:s,unit:i[0]}}function ct(e,t){if(S(t))return ht(e,t);if(t.startsWith("--"))return qt(e,t);if(Ot.test(t))return ht(e,parseFloat(t));if(nt.test(t))return ut(t);if(I.test(e))return zt(t);if(Ft.test(t))return lt(t);throw new TypeError(`Unsupported value '${t}' in '${e}' property.`)}function pt(e,t){if(t.size>1)throw new TypeError(`All units of '${e}' property must be of the same type.`)}function ft(e,t,s){if(v(t)&&t.length<e.length)for(;t.length<e.length;)s.push(ot)}function mt(e,t,s,i,n,a,r){const o=A(t)?t.offset:void 0,h=A(t)?t.value:t,l=s===0?o||0:o||Vt(n.offset,i);n.offset.push(l);const p=ct(e,h);n.value.push(p.value),n.units.add(p.unit),v(a)||r.push(a)}function Ht(e,t,s={}){const i={type:"other",key:e,value:[],offset:[],units:new Set,...s},n=i.ease||ot;if(!e.startsWith("on")){if(Kt.test(e)&&(i.type="transform",e.length===1&&(i.key=`translate${e.toUpperCase()}`)),jt.test(e)&&(i.type="color"),Zt.test(e)&&(i.type="filter",i.key=e.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),e.startsWith("opa")&&(i.key="opacity")),v(t)){const a=t.length;if(a<2)return;const r=v(n)?n:[];for(let o=0;o<a;o++){const h=t[o],l=a-i.offset.length;mt(e,h,o,l,i,n,r)}return pt(e,i.units),ft(i.value,n,r),i.ease=r,i}if(A(t)&&!v(t)){const a=t.value.length;if(a<2)return;const r=v(n)?n:[];for(let f=0;f<a;f++){const u=t.value[f],m=a-i.offset.length;mt(e,u,f,m,i,n,r)}pt(e,i.units),ft(i.value,n,r);const{value:o,ease:h,offset:l,...p}=t;return{...i,...p,ease:h||r,offset:l||i.offset,autoplay:i.autoplay,playRate:i.playRate}}}}function Lt(e){const{autoplay:t,direction:s,playRate:i,duration:n,delay:a,endDelay:r,repeat:o,ease:h,force3d:l,...p}=e,f=l??!0,u=Object.keys(p),m=[],d={autoplay:t,direction:s,playRate:i,duration:n,delay:a,endDelay:r,repeat:o,ease:h};for(let y=0,R=u.length;y<R;y++){const $=u[y],N=p[$],k=Ht($,N,d);k&&m.push(k)}return m.length||m.push(d),{options:m,force3d:f}}function dt(e){return e.reduce((t,s)=>t.data.maxDuration>s.data.maxDuration?t:s)}class Gt{#s;#r=[];constructor(t,s){for(let i=0,n=s.options.length;i<n;i++){const a=new Bt(t,s.options[i],s.force3d);this.#r.push(a)}this.#s=dt(this.#r)}#i(t,s){this.#r.forEach(i=>i[t]=s)}#e(t){this.#r.forEach(s=>s[t]())}onRender(t){this.#s.onRender=t}onComplete(t){this.#s.onComplete=t}play(){this.#e("play")}pause(){this.#e("pause")}stop(){this.#e("stop")}cancel(){this.#e("cancel")}finish(){this.#e("finish")}reverse(){this.#e("reverse")}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#i("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#i("playRate",t)}get data(){return this.#s.data}}class Qt{#s;#r=[];#i;#e;#o;#l;#h;#c;constructor(t,s){this.#i=s.onPlay,this.#e=s.onPause,this.#o=s.onStop,this.#l=s.onReverse;const i=Y(t),n=Lt(s);for(let a=0,r=i.length;a<r;a++){const o=i[a],h=new Gt({value:o,index:a,total:r},n);this.#r.push(h)}this.#s=dt(this.#r),this.#s.onComplete(()=>this.#h?.(this.data)),s.onUpdate&&this.#s.onRender(()=>s.onUpdate?.(this.data,i)),s.onStart?.(this.data),this.finished.then(()=>{this.#s.data.playState="finished",this.#s.data.promiseState="fulfilled",s.onComplete?.(this.data)}).catch(a=>{this.#s.data.playState="idle",this.#s.data.promiseState="rejected",s.onCancel?.(this.data,a)})}#u(t,s){this.#r.forEach(i=>i[t]=s)}#n(t){this.#r.forEach(s=>s[t]())}finished=new Promise((t,s)=>{this.#h=t,this.#c=s});play(){this.#n("play"),this.#i?.(this.data)}pause(){this.#n("pause"),this.#e?.(this.data)}stop(){this.#n("stop"),this.#c?.(!1),this.#o?.(this.data)}cancel(){this.#n("cancel"),this.#c?.(!1)}finish(){this.#n("finish"),this.#h?.(this.data)}reverse(){this.#n("reverse"),this.#l?.(this.data)}get currentTime(){return this.#s.currentTime}set currentTime(t){this.#u("currentTime",t)}get playRate(){return this.#s.playRate}set playRate(t){this.#u("playRate",t)}get data(){return Object.freeze({...this.#s.data})}}function Xt(e,t){return new Qt(e,t)}c.Driver=st,c.animate=Xt,c.cancelFrame=F,c.clamp=P,c.createDriverData=et,c.createRenderBatcher=_,c.createRenderStep=J,c.frame=j,c.getElements=Y,c.hexToRgba=G,c.hslaToRgba=Q,c.interpolate=T,c.mix=w,c.mixColor=q,c.msToSec=E,c.pipe=z,c.progress=C,c.round=yt,c.secToMs=g,c.setStyle=D,c.stagger=Et,c.state=U}); |
{ | ||
"name": "effekt", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"author": "Ivo Dolenc", | ||
@@ -46,2 +46,3 @@ "description": "Universal web animation platform.", | ||
"test:utils": "vitest -c test/utils/vitest.config.ts", | ||
"test:easing": "vitest -c test/easing/vitest.config.ts", | ||
"build": "hyperbundler", | ||
@@ -76,9 +77,10 @@ "build:play": "vite -c .config/vite.config.js build playgrounds/browser", | ||
"@hypernym/tsconfig": "^2.0.0", | ||
"@types/node": "^20.14.2", | ||
"eslint": "^9.4.0", | ||
"prettier": "^3.3.1", | ||
"typescript": "^5.4.5", | ||
"vite": "^5.2.12", | ||
"vitest": "^1.6.0" | ||
"@types/node": "^22.5.0", | ||
"eslint": "^9.9.1", | ||
"jsdom": "^24.1.1", | ||
"prettier": "^3.3.2", | ||
"typescript": "^5.5.4", | ||
"vite": "^5.4.2", | ||
"vitest": "^2.0.5" | ||
} | ||
} |
@@ -39,3 +39,3 @@ <p align="center"> | ||
<a title="Hypernym Studio" href="https://github.com/hypernym-studio"> | ||
<img alt="Hypernym Studio" width="244" src=".assets/hypernym-studio_logo.svg"> | ||
<img alt="Hypernym Studio" width="244" src=".assets/hypernym-logo.svg"> | ||
</a> | ||
@@ -42,0 +42,0 @@ </p> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
133351
11
2800