svg-scroll-draw 2.20.1 → 2.23.0
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/README.md +17 -15
- package/dist/angular/index.cjs +3 -3
- package/dist/angular/index.d.mts +1 -1
- package/dist/angular/index.d.ts +1 -1
- package/dist/angular/index.mjs +1 -1
- package/dist/aos/index.cjs +2 -2
- package/dist/aos/index.mjs +1 -1
- package/dist/aos/react/index.cjs +2 -2
- package/dist/aos/react/index.mjs +1 -1
- package/dist/astro/index.cjs +3 -3
- package/dist/astro/index.mjs +1 -1
- package/dist/cdn/aos.global.js +2 -2
- package/dist/cdn/scrollreveal.global.js +2 -2
- package/dist/cdn/svg-scroll-draw.dev.global.js +83 -29
- package/dist/cdn/svg-scroll-draw.global.js +3 -3
- package/dist/cdn/vivus.global.js +1 -1
- package/dist/chunk-2PYLM3E7.mjs +1 -0
- package/dist/chunk-DWK6XXY6.mjs +2 -0
- package/dist/chunk-DY5JCXVR.mjs +1 -0
- package/dist/chunk-EAWFBJUR.mjs +2 -0
- package/dist/{chunk-MTEGM4RR.mjs → chunk-GVBO5GRD.mjs} +1 -1
- package/dist/chunk-HX4SP5WN.mjs +3 -0
- package/dist/chunk-JCXMBI4G.mjs +2 -0
- package/dist/chunk-KV3WCPQ5.mjs +1 -0
- package/dist/chunk-LTCJVVSC.mjs +1 -0
- package/dist/{chunk-SMRTRZSD.mjs → chunk-OTDD2ROH.mjs} +1 -1
- package/dist/{chunk-ECHMYVSK.mjs → chunk-VMUJMXKO.mjs} +1 -1
- package/dist/chunk-WXUOF4NM.mjs +1 -0
- package/dist/chunk-YNNA33A5.mjs +2 -0
- package/dist/cinematic/index.cjs +2 -2
- package/dist/cinematic/index.mjs +1 -1
- package/dist/{engine-DQyBzZDl.d.ts → engine-B7UpB4fT.d.ts} +2 -1
- package/dist/{engine-P8u6OK4m.d.mts → engine-o1VSQ1lX.d.mts} +2 -1
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +2 -2
- package/dist/group/index.d.ts +2 -2
- package/dist/group/index.mjs +1 -1
- package/dist/horizontal/index.cjs +1 -1
- package/dist/horizontal/index.d.mts +2 -1
- package/dist/horizontal/index.d.ts +2 -1
- package/dist/horizontal/index.mjs +1 -1
- package/dist/{index-CMqK0GCT.d.mts → index-BY-CNE8c.d.mts} +1 -1
- package/dist/{index-DPqPEnO-.d.ts → index-DqXXiDIk.d.ts} +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +1 -1
- package/dist/nuxt/index.d.ts +1 -1
- package/dist/nuxt/index.mjs +1 -1
- package/dist/react/index.cjs +3 -3
- package/dist/react/index.d.mts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.mjs +1 -1
- package/dist/reveal/index.cjs +1 -1
- package/dist/reveal/index.mjs +1 -1
- package/dist/scrollreveal/index.cjs +2 -2
- package/dist/scrollreveal/index.mjs +1 -1
- package/dist/scrollreveal/react/index.cjs +2 -2
- package/dist/scrollreveal/react/index.mjs +1 -1
- package/dist/snap/index.mjs +1 -1
- package/dist/solid/index.cjs +3 -3
- package/dist/solid/index.d.mts +1 -1
- package/dist/solid/index.d.ts +1 -1
- package/dist/solid/index.mjs +1 -1
- package/dist/svelte/index.cjs +3 -3
- package/dist/svelte/index.d.mts +1 -1
- package/dist/svelte/index.d.ts +1 -1
- package/dist/svelte/index.mjs +1 -1
- package/dist/text/index.cjs +1 -1
- package/dist/text/index.mjs +1 -1
- package/dist/timeline/index.mjs +1 -1
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.mjs +1 -1
- package/dist/vivus/index.cjs +2 -2
- package/dist/vivus/index.d.mts +3 -0
- package/dist/vivus/index.d.ts +3 -0
- package/dist/vivus/index.mjs +1 -1
- package/dist/vivus/react/index.cjs +2 -2
- package/dist/vivus/react/index.mjs +1 -1
- package/dist/vue/index.cjs +3 -3
- package/dist/vue/index.d.mts +1 -1
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.mjs +1 -1
- package/dist/web-component/index.cjs +3 -3
- package/dist/web-component/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-4T5R3ZTL.mjs +0 -2
- package/dist/chunk-7SBTYJGH.mjs +0 -1
- package/dist/chunk-BFX2CSQ3.mjs +0 -1
- package/dist/chunk-ENACACPZ.mjs +0 -3
- package/dist/chunk-I45LCJUP.mjs +0 -1
- package/dist/chunk-KGAJQP2N.mjs +0 -2
- package/dist/chunk-KHQ7OGQK.mjs +0 -1
- package/dist/chunk-OMI46IXL.mjs +0 -2
- package/dist/chunk-WQZKXAXK.mjs +0 -2
package/dist/svelte/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${m?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",i,{passive:true}),i(),{el:t,destroy(){window.removeEventListener("scroll",i),t.remove();}}}var qt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Bt=/[MmLlHhVvCcSsQqTtAaZz]/g;function yr(e,r,n){if(!Xe)return;let t=(e.match(Bt)??[]).join("").toUpperCase(),i=(r.match(Bt)??[]).join("").toUpperCase(),s=(e.match(qt)??[]).length,l=(r.match(qt)??[]).length;if(t!==i){we(`morphTo: command sequence differs (${t||"\u2205"} \u2192 ${i||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,n);return}s!==l&&we(`morphTo: coordinate count differs (${s} \u2192 ${l}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,n);}function dt(e,r,n){let t=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let l=parseFloat(s),u=t[i++]??l;return String(+(l+(u-l)*n).toFixed(4))})}function gt(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...t}=r,i=n?{...Rt[n],...t}:t,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:l="path, polyline, line, polygon, rect, circle",speed:u=1,fade:m=false,easing:d="linear",trigger:T={},stagger:R=0,direction:A="forward",once:te=false,debug:Pe=false,axis:G="y",scrollContainer:ce,autoReverse:re=false,delay:Y=0,strokeColor:H,strokeWidth:P,fillOpacity:I,waypoints:w,velocityScale:k=false,threshold:x=0,rootMargin:M="0px",repeat:E=0,repeatDelay:ne=0,morphTo:L,clip:oe,autoplay:ve=false,duration:ge=1e3,native:ye=true,onProgress:N,onStart:C,onComplete:f,onEnter:p,onLeave:O,onEnterBack:q,onLeaveBack:Me}=i,v=oe===true?"left":typeof oe=="string"?oe:false,V=typeof d=="function"?d:le[d]??le.linear,ue=be(T.start??"top bottom"),Re=be(T.end??"bottom top"),Ee=typeof ce=="string"?document.querySelector(ce):ce??null,Ae=Array.isArray(H)?H[0]:null,me=Array.isArray(H)?H[1]:typeof H=="string"?H:null,X=Array.isArray(P)?P[0]:null,se=Array.isArray(P)?P[1]:typeof P=="number"?P:null,ie=Array.isArray(I)?I[0]:null,K=Array.isArray(I)?I[1]:typeof I=="number"?I:null;function He(o){let a=o*100;switch(v){case "right":return `inset(0 0 0 ${100-a}%)`;case "top":return `inset(0 0 ${100-a}% 0)`;case "bottom":return `inset(${100-a}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-a}% 0 0)`}}let z=v?[]:Array.from(e.querySelectorAll(l)),D=[],fe=[],J=0,Se=0,c=R,h=0,_=false,B=false,$=0,pe=false,he=-1,Ne=[],ae=-1,j=false,Te=0,Ve=0,ze,lt=null;function Tt(){lt?.destroy(),lt=null;}let _e=new Set,xt=NaN,We=true,Je=-1,Mt=performance.now(),qe=NaN;function Ue(){return Ee?G==="x"?Ee.scrollLeft:Ee.scrollTop:G==="x"?window.scrollX:window.scrollY}function At(){return Ee?G==="x"?Ee.clientWidth:Ee.clientHeight:G==="x"?window.innerWidth:window.innerHeight}function Lt(){let o=ot(e,Ee,G);return Ce(o,o.scroll,At(),ue,Re)}function Jt(){let o=Se-J,a=z.length-1,y=Ee??document.documentElement,Q=G==="x"?"Width":"Height";if(c=R,R>0&&a>0&&o>0){let Le=y[`scroll${Q}`]-y[`client${Q}`]-1-J-o/u;Le>=0&&(c=Math.min(R,Le/(a*o)));}h=Se+a*c*o;}function $t(){(({tStart:J,tEnd:Se}=Lt())),Jt(),Pe&&Xe&&(Tt(),lt=gr(J,Se,G));}function ct(o,a=Lt){Ie(e,{type:"draw",getProgress:()=>o.getProgress(),getTrigger:a});let y=o.destroy;return o.destroy=()=>{y.call(o),Oe(e);},o}function er(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),v){let y=a==="reverse"?1-o:o;e.style.clipPath=He(y);return}z.forEach((y,Q)=>{y.style.strokeDashoffset=a==="reverse"?`${D[Q]*o}`:`${D[Q]*(1-o)}`,m&&(y.style.opacity=a==="reverse"?`${1-o}`:`${o}`),Ae&&me?y.style.stroke=je(Ae,me,o):me&&(y.style.stroke=me),X!==null&&se!==null?y.style.strokeWidth=`${X+(se-X)*o}`:se!==null&&(y.style.strokeWidth=`${se}`),ie!==null&&K!==null?y.style.fillOpacity=`${ie+(K-ie)*o}`:K!==null&&(y.style.fillOpacity=`${K}`),L&&y.tagName.toLowerCase()==="path"&&fe[Q]&&y.setAttribute("d",dt(fe[Q],L,o));});}function et(){if(e.style.setProperty("--scroll-draw-progress","0"),v){e.style.clipPath=He(0);return}z.forEach((o,a)=>{o.style.strokeDasharray=`${D[a]}`,o.style.strokeDashoffset=A==="reverse"?"0":`${D[a]}`,m?o.style.opacity=A==="reverse"?"1":"0":o.style.opacity="",Ae&&(o.style.stroke=Ae),X!==null&&(o.style.strokeWidth=`${X}`),ie!==null&&(o.style.fillOpacity=`${ie}`),L&&o.tagName.toLowerCase()==="path"&&fe[a]&&o.setAttribute("d",fe[a]);});}if(z.forEach(o=>{dr(o);let a=Ge(o);D.push(a);let y=o.tagName.toLowerCase()==="path";y?fe.push(o.getAttribute("d")??""):fe.push(""),L&&(y?yr(fe[fe.length-1],L,o):we(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),s?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=A==="reverse"?`${a}`:"0",m&&(o.style.opacity="1"),me&&(o.style.stroke=me),se!==null&&(o.style.strokeWidth=`${se}`),K!==null&&(o.style.fillOpacity=`${K}`),L&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",L)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=A==="reverse"?"0":`${a}`,m?o.style.opacity=A==="reverse"?"1":"0":o.style.opacity="",Ae&&(o.style.stroke=Ae),X!==null&&(o.style.strokeWidth=`${X}`),ie!==null&&(o.style.fillOpacity=`${ie}`));}),v){if(s)return e.style.clipPath=He(1),f?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=He(0);}else if(s)return f?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let Ct=typeof d=="string"?st(d):null;function tr(){return !(ye===false||!pr()||!z.length||!Ct||v||G!=="y"||Ee||u!==1||R!==0||te||re||k!==false||L||w||E||Y>0||N||C||f||p||O||q||Me||H!=null||P!=null||I!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function rr(){let o=++fr,a=`svg-scroll-draw-${o}`,y=`svg-scroll-draw-host-${o}`,Q=`--svg-scroll-draw-${o}`,Le=A==="reverse"?"0":"var(--ssd-len)",De=A==="reverse"?"var(--ssd-len)":"0",ke=`stroke-dashoffset:${Le};`,S=`stroke-dashoffset:${De};`;m&&(ke+=`opacity:${A==="reverse"?1:0};`,S+=`opacity:${A==="reverse"?0:1};`);let F=document.createElement("style");F.setAttribute("data-svg-scroll-draw",""),F.textContent=`@keyframes ${a}{from{${ke}}to{${S}}}.${y}{view-timeline-name:${Q};view-timeline-axis:block;}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${Ct};animation-fill-mode:both;animation-timeline:${Q};animation-range:cover 0% cover 100%;}`,document.head.appendChild(F),e.classList.add(y);function de(g,Z){g.style.setProperty("--ssd-len",String(D[Z])),g.style.strokeDasharray=`${D[Z]}`,g.style.strokeDashoffset="",g.style.opacity="",g.style.animationPlayState="",g.classList.add(a);}z.forEach(de);let b=false,W=-1;function U(){if(W>=0)return W;let g=e.getBoundingClientRect(),{tStart:Z,tEnd:$e}=Ce({top:g.top,height:g.height},Ue(),At(),ue,Re);return V(ee(Ue(),Z,$e,u))}return {destroy(){e.classList.remove(y),z.forEach(g=>{g.classList.remove(a),g.style.removeProperty("--ssd-len"),g.style.animationPlayState="";}),F.remove();},replay(){b=false,W=-1,z.forEach(de);},pause(){b=true,z.forEach(g=>{g.style.animationPlayState="paused";});},resume(){b&&(b=false,z.forEach(g=>{g.style.animationPlayState="running";}));},seek(g){let Z=Math.min(1,Math.max(0,g));W=Z,b=true,z.forEach(($e,xe)=>{$e.classList.remove(a),$e.style.strokeDashoffset=A==="reverse"?`${D[xe]*Z}`:`${D[xe]*(1-Z)}`,m&&($e.style.opacity=A==="reverse"?`${1-Z}`:`${Z}`);});},getProgress(){return U()},refresh(){z.forEach((g,Z)=>{D[Z]=Ge(g),g.style.setProperty("--ssd-len",String(D[Z])),g.style.strokeDasharray=`${D[Z]}`;});}}}if(tr())return ct(rr());function nr(){let o=Math.max(1,ge),a=0,y=0,Q=false;function Le(b){let W=true;if(v){let U=Math.min(1,Math.max(0,b/o)),g=V(U);Te=g,e.style.setProperty("--scroll-draw-progress",String(g)),e.style.clipPath=He(A==="reverse"?1-g:g),N?.(g),U<1&&(W=false);}else z.forEach((U,g)=>{let Z=g*R*o,$e=Math.min(1,Math.max(0,(b-Z)/o)),xe=V($e);U.style.strokeDashoffset=A==="reverse"?`${D[g]*xe}`:`${D[g]*(1-xe)}`,m&&(U.style.opacity=A==="reverse"?`${1-xe}`:`${xe}`),Ae&&me?U.style.stroke=je(Ae,me,xe):me&&(U.style.stroke=me),X!==null&&se!==null?U.style.strokeWidth=`${X+(se-X)*xe}`:se!==null&&(U.style.strokeWidth=`${se}`),ie!==null&&K!==null?U.style.fillOpacity=`${ie+(K-ie)*xe}`:K!==null&&(U.style.fillOpacity=`${K}`),L&&U.tagName.toLowerCase()==="path"&&fe[g]&&U.setAttribute("d",dt(fe[g],L,xe)),g===0&&(Te=xe,N?.(xe),e.style.setProperty("--scroll-draw-progress",String(xe))),$e<1&&(W=false);});if(w){let U=Math.min(1,Math.max(0,b/o)),g=V(U);for(let Z in w){let $e=parseFloat(Z);g>=$e&&!_e.has($e)&&(_e.add($e),w[Z]?.());}}return W}function De(b){if(j)return;let W=b-a;B||(B=true,C?.());let U=Le(W);if(U&&!_){_=true,Le(o*(1+Math.max(0,z.length-1)*R)),f?.(),Ve<(E==="infinite"?1/0:E??0)&&(Ve++,ze=setTimeout(()=>{a=performance.now(),B=false,_=false,_e.clear(),et(),$=requestAnimationFrame(De);},ne));return}U||($=requestAnimationFrame(De));}function ke(){cancelAnimationFrame($),clearTimeout(ze),a=performance.now(),y=0,j=false,B=false,_=false,Ve=0,Q=true,Te=0,_e.clear(),et(),$=requestAnimationFrame(De);}let S=new IntersectionObserver(b=>{b.forEach(W=>{W.isIntersecting&&!(te&&_)?ke():!W.isIntersecting&&!te&&!_&&(cancelAnimationFrame($),clearTimeout(ze),Q=false);});},{root:Ee??null,threshold:x,rootMargin:M}),F;function de(){clearTimeout(F),F=setTimeout(()=>{z.forEach((b,W)=>{D[W]=Ge(b),b.style.strokeDasharray=`${D[W]}`;});},150);}return window.addEventListener("resize",de),window.addEventListener("orientationchange",de),Y>0?setTimeout(()=>S.observe(e),Y):S.observe(e),{destroy(){cancelAnimationFrame($),clearTimeout(ze),S.disconnect(),window.removeEventListener("resize",de),window.removeEventListener("orientationchange",de),clearTimeout(F);},replay(){Ve=0,ke();},pause(){j||!Q||(j=true,y=performance.now()-a,cancelAnimationFrame($));},resume(){j&&(j=false,Q=true,a=performance.now()-y,$=requestAnimationFrame(De));},seek(b){let W=Math.min(1,Math.max(0,b));Te=W,j=true,y=W*o,a=performance.now()-y,cancelAnimationFrame($),Le(y);},getProgress(){return Te},refresh(){clearTimeout(F),z.forEach((b,W)=>{D[W]=Ge(b),b.style.strokeDasharray=`${D[W]}`;});}}}if(ve)return ct(nr());$t();function Pt(){if(j||!Be)return;let o=performance.now(),a=Ue();if(!We&&k===false&&a===xt){mt(a);return}We=false,xt=a;let y=u;if(k!==false){let S=o-Mt,F=S>0?Math.abs(a-(Je<0?a:Je))/S:0;y=u*Math.max(.2,1+F*(typeof k=="number"?k:1)*.04);}Je=a,Mt=o;let Q=re?ae===-1||a>=ae?"forward":"reverse":A;ae=a;let Le=Se-J,De=true,ke=Le===0?0:(a-J)/Le;if(isNaN(qe)||(qe<=0&&ke>0?p?.():qe>0&&ke<=0&&Me?.(),qe<1&&ke>=1?O?.():qe>=1&&ke<1&&q?.()),qe=ke,v){let S=V(ee(a,J,Se,y));te&&!re&&(he=Math.max(he,S),S=he),Te=S,e.style.setProperty("--scroll-draw-progress",String(S));let F=Q==="reverse"?1-S:S;e.style.clipPath=He(F),N?.(S),!B&&ee(a,J,Se,y)>0&&(B=true,C?.()),S>=1&&!_?(_=true,f?.(),Ve<(E==="infinite"?1/0:E??0)&&(Ve++,ze=setTimeout(()=>{he=-1,B=false,_=false,e.style.clipPath=He(0);},ne))):S<1&&!te&&(_=false),mt(a);return}if(z.forEach((S,F)=>{let de=F*c*Le,b=V(ee(a,J+de,Se+de,y));te&&!re&&(b=Ne[F]=Math.max(Ne[F]??he,b)),S.style.strokeDashoffset=Q==="reverse"?`${D[F]*b}`:`${D[F]*(1-b)}`,m&&(S.style.opacity=Q==="reverse"?`${1-b}`:`${b}`),Ae&&me?S.style.stroke=je(Ae,me,b):me&&(S.style.stroke=me),X!==null&&se!==null?S.style.strokeWidth=`${X+(se-X)*b}`:se!==null&&(S.style.strokeWidth=`${se}`),ie!==null&&K!==null?S.style.fillOpacity=`${ie+(K-ie)*b}`:K!==null&&(S.style.fillOpacity=`${K}`),L&&S.tagName.toLowerCase()==="path"&&fe[F]&&S.setAttribute("d",dt(fe[F],L,b)),F===0&&(Te=b,N?.(b),e.style.setProperty("--scroll-draw-progress",String(b))),b<1&&(De=false);}),w){let S=V(ee(a,J,Se,y));for(let F in w){let de=parseFloat(F);S>=de&&!_e.has(de)&&(_e.add(de),w[F]?.());}}!B&&ee(a,J,Se,y)>0&&(B=true,C?.()),De&&!_?(_=true,f?.(),Ve<(E==="infinite"?1/0:E??0)&&(Ve++,ze=setTimeout(()=>{he=-1,Ne=[],B=false,_=false,_e.clear(),et(),We=true;},ne))):!De&&!te&&(_=false),mt(a);}function ut(o){return o>=Se&&o<h}function mt(o){pe||ut(o)?$=requestAnimationFrame(Pt):Be=false;}function ft(){return pe||ut(Ue())}let Be=false;function tt(){Be||(Be=true,$=requestAnimationFrame(function(){Pt();}));}function rt(){Be=false,cancelAnimationFrame($);}let pt=new IntersectionObserver(o=>{o.forEach(a=>{pe=a.isIntersecting,pe&&!j?(We=true,tt()):Be&&!j&&ut(Ue())||rt();});},{root:Ee??null,threshold:x,rootMargin:M});function kt(){z.forEach((o,a)=>{D[a]=Ge(o),o.style.strokeDasharray=`${D[a]}`;}),$t(),We=true;}let nt;function Ye(){clearTimeout(nt),nt=setTimeout(kt,150);}window.addEventListener("resize",Ye),window.addEventListener("orientationchange",Ye);let or=Fe([e],Ye);return Y>0?setTimeout(()=>pt.observe(e),Y):pt.observe(e),ct({destroy(){cancelAnimationFrame($),clearTimeout(ze),rt(),pt.disconnect(),or(),window.removeEventListener("resize",Ye),window.removeEventListener("orientationchange",Ye),clearTimeout(nt),Tt();},replay(){he=-1,Ne=[],ae=-1,Je=-1,B=false,_=false,Ve=0,j=false,Te=0,_e.clear(),clearTimeout(ze),et(),We=true,ft()&&tt();},pause(){j=true,rt();},resume(){j&&(j=false,We=true,ft()&&tt());},seek(o){let a=Math.min(1,Math.max(0,o));Te=a,he=a,Ne=[],j=true,rt(),er(a,A),We=true;},getProgress(){return Te},refresh(){clearTimeout(nt),kt(),ft()&&!j&&tt();}},()=>({tStart:J,tEnd:Se}))}var Gt=new WeakMap,hr=0;function yt(e){return JSON.stringify(e,(r,n)=>{if(typeof n=="function")return "\u0192";if(typeof Element<"u"&&n instanceof Element){let t=Gt.get(n);return t===void 0&&Gt.set(n,t=++hr),`el#${t}`}return n})}function ht(e,r){let n={...e};for(let t of Object.keys(n))typeof n[t]=="function"&&(n[t]=(...i)=>r()[t]?.(...i));return n}function br(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function jt(e){let r=[],n=/([\w]+)\(([^)]*)\)/g,t;for(;(t=n.exec(e))!==null;){let i=[],s=[],l=t[2].trim();if(l)for(let u of l.split(/[\s,]+/)){let m=u.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(m?parseFloat(m[1]):0),s.push(m?m[2]:"");}r.push({fn:t[1],nums:i,units:s});}return r}function wr(e,r,n){let t=jt(e),i=jt(r);return t.length===0||t.length!==i.length?n<1?e:r:t.map((s,l)=>{let u=i[l];return s.fn!==u.fn||s.nums.length!==u.nums.length?n<1?`${s.fn}(${s.nums.map((m,d)=>`${m}${s.units[d]}`).join(", ")})`:`${u.fn}(${u.nums.map((m,d)=>`${m}${u.units[d]}`).join(", ")})`:`${s.fn}(${s.nums.map((m,d)=>`${m+(u.nums[d]-m)*n}${s.units[d]}`).join(", ")})`}).join(" ")}function Ut(e,r,n){if(typeof e=="number"&&typeof r=="number")return String(e+(r-e)*n);let t=String(e),i=String(r);if(br(t))return je(t,i,n);if(t.includes("("))return wr(t,i,n);let s=t.match(/^([-+]?[\d.]+)(.*)$/),l=i.match(/^([-+]?[\d.]+)(.*)$/);if(s&&l){let u=parseFloat(s[1]),m=parseFloat(l[1]);return `${u+(m-u)*n}${s[2]||l[2]}`}return n<1?t:i}function vr(e){return e.replace(/([A-Z])/g,r=>`-${r.toLowerCase()}`)}var Er=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Sr=0,Yt="--scroll-draw-progress";function Tr(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function bt(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let{props:t,trigger:i={},easing:s="ease-out",speed:l=1,once:u=false,axis:m="y",scrollContainer:d,native:T=true,velocityScale:R=false,respectReducedMotion:A=true,triggerElement:te,onProgress:Pe,onComplete:G,onEnter:ce,onLeave:re,onEnterBack:Y,onLeaveBack:H}=r,P=A&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,I=typeof s=="function"?s:le[s]??le["ease-out"],w=be(i.start??"top bottom"),k=be(i.end??"bottom top"),x=te??e,M=typeof d=="string"?document.querySelector(d):d??null,E=Object.entries(t).map(([c,h])=>({prop:vr(c),from:Array.isArray(h)?h[0]:"",to:Array.isArray(h)?h[1]:h}));function ne(){let c=window.getComputedStyle(e);for(let h of E)h.from===""&&(h.from=c.getPropertyValue(h.prop).trim()||"0");}function L(){for(let c of E)e.style.setProperty(c.prop,String(c.to));}let oe=new Map;for(let c of [...E.map(h=>h.prop),Yt])oe.set(c,e.style.getPropertyValue(c));function ve(){for(let[c,h]of oe)h?e.style.setProperty(c,h):e.style.removeProperty(c);}if(P)return L(),G?.(),{...n,destroy:ve,getProgress:()=>1};ne();let ge=typeof s=="string"?st(s):null;function ye(){if(!T||!Tr()||!ge||m!=="y"||M||x!==e||u||l!==1||Pe||G||ce||re||Y||H||R!==false||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return false;for(let c of E)if(!Er.has(c.prop))return false;return true}function N(){let c=`ssd-a-${++Sr}`,h=E.map(ae=>`${ae.prop}:${ae.from}`).join(";"),_=E.map(ae=>`${ae.prop}:${ae.to}`).join(";"),B=document.createElement("style");B.setAttribute("data-ssd-animate",""),B.textContent=`@keyframes ${c}{from{${h}}to{${_}}}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${ge};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(B),e.classList.add(c);let $=()=>m==="x"?window.scrollX:window.scrollY,pe=()=>m==="x"?window.innerWidth:window.innerHeight,he=()=>{let ae=e.getBoundingClientRect();return Ce({top:ae.top,height:ae.height},$(),pe(),w,k)};Ie(e,{type:"animate",getProgress:()=>Ne.getProgress(),getTrigger:he});let Ne={refresh(){},destroy(){e.classList.remove(c),B.remove(),e.style.animationPlayState="",ve(),Oe(e);},replay(){e.classList.remove(c),e.offsetWidth,e.classList.add(c);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(ae){let j=Math.min(1,Math.max(0,ae));e.classList.remove(c);for(let Te of E)e.style.setProperty(Te.prop,Ut(Te.from,Te.to,j));},getProgress(){let{tStart:ae,tEnd:j}=he();return I(ee($(),ae,j,l))}};return Ne}if(ye())return N();let C=0,f=0,p=0,O=false,q=false,Me=-1,v=0,V=false,ue=NaN,Re=-1,Ee=0,Ae=()=>M?m==="x"?M.scrollLeft:M.scrollTop:m==="x"?window.scrollX:window.scrollY,me=()=>M?m==="x"?M.clientWidth:M.clientHeight:m==="x"?window.innerWidth:window.innerHeight,X=x===e?E:[],se=false;function ie(){let c=e.style,h=X.map(pe=>c.getPropertyValue(pe.prop)),_=c.transition;X.length&&(c.transition="none"),X.forEach(pe=>c.setProperty(pe.prop,oe.get(pe.prop)??""));let B=ot(x,M,m);X.forEach((pe,he)=>c.setProperty(pe.prop,h[he])),X.length&&(e.offsetWidth,c.transition=_);let $=Ce(B,B.scroll,me(),w,k);se&&Math.abs($.tStart-C)<1&&Math.abs($.tEnd-f)<1||(se=true,C=$.tStart,f=$.tEnd);}function K(c){e.style.setProperty(Yt,String(c));for(let h of E)e.style.setProperty(h.prop,Ut(h.from,h.to,c));Pe?.(c);}function He(c){if(isNaN(ue)){ue=c;return}ue<=0&&c>0?ce?.():ue>0&&c<=0&&H?.(),ue<1&&c>=1?re?.():ue>=1&&c<1&&Y?.(),ue=c;}function z(){if(!O||q)return;let c=performance.now(),h=Ae(),_=l;if(R!==false){let pe=c-Ee,he=pe>0?Math.abs(h-(Re<0?h:Re))/pe:0;_=l*Math.max(.2,1+he*(typeof R=="number"?R:1)*.04);}Re=h,Ee=c;let B=f===C?0:(h-C)/(f-C);He(B);let $=I(ee(h,C,f,_));u&&(Me=Math.max(Me,$),$=Me),v=$,K($),$>=1&&!V?(V=true,G?.()):$<1&&!u&&(V=false),p=requestAnimationFrame(z);}ie(),f===C&&we("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let c=I(ee(Ae(),C,f,l));u&&c>0&&(Me=c),v=c,K(c);}let D=new IntersectionObserver(c=>{c.forEach(h=>{O=h.isIntersecting,O&&!q?p=requestAnimationFrame(z):cancelAnimationFrame(p);});},{root:M??null}),fe;function J(){clearTimeout(fe),fe=setTimeout(ie,150);}window.addEventListener("resize",J),window.addEventListener("orientationchange",J);let Se=Fe([x],J);return D.observe(e),Ie(e,{type:"animate",getProgress:()=>v,getTrigger:()=>({tStart:C,tEnd:f})}),{destroy(){cancelAnimationFrame(p),D.disconnect(),window.removeEventListener("resize",J),window.removeEventListener("orientationchange",J),Se(),clearTimeout(fe),ve(),Oe(e);},replay(){Me=-1,V=false,v=0,q=false,K(0);},pause(){q=true,cancelAnimationFrame(p);},resume(){q&&(q=false,O&&(p=requestAnimationFrame(z)));},seek(c){let h=Math.min(1,Math.max(0,c));v=h,Me=h,q=true,cancelAnimationFrame(p),K(h);},getProgress(){return v},refresh(){ie();}}}var wt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function vt(e,r){if(typeof window>"u")return wt;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return we("scrollCounter: element not found:",e),wt;let t=n,{from:i=0,to:s,format:l,easing:u="ease-out",trigger:m={},once:d=true,decimals:T,onComplete:R}=r,A=T!==void 0?f=>f.toFixed(T):l??(f=>String(Math.round(f))),te=typeof u=="function"?u:le[u]??le["ease-out"],Pe=be(m.start??"top 80%"),G=be(m.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=A(s),R?.(),wt;let re=0,Y=0,H=false,P=0,I=false,w=false,k=-1,x=0,M=false,E=()=>window.scrollY,ne=()=>window.innerHeight;function L(){let f=t.getBoundingClientRect(),p=Ce({top:f.top,height:f.height},E(),ne(),Pe,G);H&&Math.abs(p.tStart-re)<1&&Math.abs(p.tEnd-Y)<1||(H=true,re=p.tStart,Y=p.tEnd);}function oe(f){t.textContent=A(i+(s-i)*f),t.style.setProperty("--scroll-draw-progress",String(f));}function ve(){if(!I||w)return;let f=te(ee(E(),re,Y,1));d&&(k=Math.max(k,f),f=k),x=f,oe(f),f>=1&&!M?(M=true,R?.()):f<1&&!d&&(M=false),P=requestAnimationFrame(ve);}L();{let f=te(ee(E(),re,Y,1));d&&f>0&&(k=f),x=f,oe(f);}let ge=new IntersectionObserver(f=>{f.forEach(p=>{I=p.isIntersecting,I&&!w?P=requestAnimationFrame(ve):cancelAnimationFrame(P);});}),ye;function N(){clearTimeout(ye),ye=setTimeout(L,150);}window.addEventListener("resize",N),window.addEventListener("orientationchange",N);let C=Fe([t],N);return ge.observe(t),Ie(t,{type:"counter",getProgress:()=>x,getTrigger:()=>({tStart:re,tEnd:Y})}),{destroy(){cancelAnimationFrame(P),ge.disconnect(),window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N),C(),clearTimeout(ye),Oe(t);},replay(){k=-1,M=false,x=0,w=false,oe(0);},pause(){w=true,cancelAnimationFrame(P);},resume(){w&&(w=false,I&&(P=requestAnimationFrame(ve)));},seek(f){let p=Math.min(1,Math.max(0,f));x=p,k=p,w=true,cancelAnimationFrame(P),oe(p);},getProgress(){return x}}}var Xt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Et(e,r={}){if(typeof window>"u")return Xt;let n=typeof e=="string"?document.querySelector(e):e;if(!n||n.tagName.toLowerCase()!=="video")return we("scrollVideo: <video> element not found:",e),Xt;let t=n,{trigger:i={},easing:s="linear",once:l=false,axis:u="y",preload:m="auto",triggerElement:d,onReady:T,onComplete:R,onProgress:A}=r,te=d??t,Pe=window.matchMedia("(prefers-reduced-motion: reduce)").matches,G=typeof s=="function"?s:le[s]??le.linear,ce=be(i.start??"top top"),re=be(i.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=m);let Y=r.from??0,H=r.to,P=0,I=0,w=0,k=false,x=false,M=-1,E=0,ne=false,L=false,oe=()=>u==="x"?window.scrollX:window.scrollY,ve=()=>u==="x"?window.innerWidth:window.innerHeight;function ge(){let v=te.getBoundingClientRect(),V=u==="x"?v.left:v.top,ue=u==="x"?v.width:v.height,Re=Ce({top:V,height:ue},oe(),ve(),ce,re);P=Re.tStart,I=Re.tEnd,L&&I===P&&we("scrollVideo: zero-length trigger window, so it never scrubs. In a sticky stage, set triggerElement.",t);}let ye=NaN;function N(v){if(!L)return;let V=H??t.duration??0,ue=Y+(V-Y)*v;ue!==ye&&(ye=ue,t.currentTime=ue),t.style.setProperty("--scroll-draw-progress",String(v)),A?.(v);}function C(){if(!k||x||!L||Pe)return;let v=G(ee(oe(),P,I,1));l&&(M=Math.max(M,v),v=M),E=v,N(v),v>=1&&!ne?(ne=true,R?.()):v<1&&!l&&(ne=false),w=requestAnimationFrame(C);}function f(){if(L=true,H===void 0&&(H=t.duration),Pe){N(1),T?.();return}ge(),T?.(),k&&!x&&(w=requestAnimationFrame(C));}t.readyState>=1?f():t.addEventListener("loadedmetadata",f,{once:true}),L||ge();let p=new IntersectionObserver(v=>{v.forEach(V=>{k=V.isIntersecting,k&&!x&&L?w=requestAnimationFrame(C):cancelAnimationFrame(w);});}),O;function q(){clearTimeout(O),O=setTimeout(ge,150);}window.addEventListener("resize",q),window.addEventListener("orientationchange",q);let Me=Fe([te],q);return p.observe(t),Ie(t,{type:"video",getProgress:()=>E,getTrigger:()=>({tStart:P,tEnd:I})}),{destroy(){cancelAnimationFrame(w),p.disconnect(),t.removeEventListener("loadedmetadata",f),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),Me(),clearTimeout(O),Oe(t);},replay(){M=-1,ne=false,E=0,x=false,ye=NaN,N(0);},pause(){x=true,cancelAnimationFrame(w);},resume(){x&&(x=false,k&&L&&(w=requestAnimationFrame(C)));},seek(v){let V=Math.min(1,Math.max(0,v));E=V,M=V,x=true,cancelAnimationFrame(w),ye=NaN,N(V);},getProgress(){return E}}}function Zt(e){let r=e.textContent??"";return e.textContent="",r.split(/(\s+)/).filter(Boolean).map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(t.textContent=n,t.style.whiteSpace="pre"):(t.textContent=n,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(n)?null:t}).filter(n=>n!==null)}function xr(e){let r=e.textContent??"";return e.textContent="",r.split("").map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=n,n===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),n===" "?null:t}).filter(n=>n!==null)}function Kt(e){let r=Zt(e),n=new Map;for(let s of r){let l=s.offsetTop;n.has(l)||n.set(l,[]),n.get(l).push(s);}let t=[],i=Array.from(n.keys()).sort((s,l)=>s-l);for(let s of i){let l=n.get(s),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block",l.forEach((m,d)=>{let T=m.nextElementSibling;u.appendChild(m),d<l.length-1&&T&&T.style.whiteSpace==="pre"&&u.appendChild(T);}),t.push(u);}return e.textContent="",t.forEach((s,l)=>{e.appendChild(s),l<t.length-1&&e.appendChild(document.createTextNode(" "));}),t}function Mr(e,r,n,t){if(n<=1||t===0)return e;let i=(n-1)*t,s=r*t,l=s+(1-i);return l<=s?e>=s?1:0:Math.min(1,Math.max(0,(e-s)/(l-s)))}function Ar(e,r){let n=[];if(r?.y!==void 0&&n.push(`translateY(${r.y*(1-e)}px)`),r?.x!==void 0&&n.push(`translateX(${r.x*(1-e)}px)`),r?.rotate!==void 0&&n.push(`rotate(${r.rotate*(1-e)}deg)`),r?.scale!==void 0){let t=r.scale+(1-r.scale)*e;n.push(`scale(${t})`);}return n.join(" ")||""}var Qt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function St(e,r={}){if(typeof window>"u")return Qt;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return we("scrollText: element not found:",e),Qt;let t=n,{split:i="words",stagger:s=.04,easing:l="ease-out",from:u={opacity:0,y:24},trigger:m={},once:d=true,onComplete:T}=r,R=window.matchMedia("(prefers-reduced-motion: reduce)").matches,A=typeof l=="function"?l:le[l]??le["ease-out"],te=be(m.start??"top 85%"),Pe=be(m.end??"top 40%"),G=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let ce;i==="chars"?ce=xr(t):i==="lines"?ce=Kt(t):ce=Zt(t);let re=ce.length;function Y(p,O){u?.opacity!==void 0&&(p.style.opacity=String(u.opacity+(1-u.opacity)*O));let q=Ar(O,u);q&&(p.style.transform=q);}function H(p){t.style.setProperty("--scroll-draw-progress",String(p)),ce.forEach((O,q)=>{let Me=A(Mr(p,q,re,s));Y(O,Me);});}if(R)return H(1),T?.(),{destroy(){t.innerHTML=G,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};H(0);let P=0,I=0,w=0,k=false,x=false,M=-1,E=0,ne=false,L=()=>window.scrollY,oe=()=>window.innerHeight;function ve(){let p=t.getBoundingClientRect(),O=Ce({top:p.top,height:p.height},L(),oe(),te,Pe);P=O.tStart,I=O.tEnd;}function ge(){if(!k||x)return;let p=ee(L(),P,I,1);d&&(M=Math.max(M,p),p=M),E=p,H(p),p>=1&&!ne?(ne=true,T?.()):p<1&&!d&&(ne=false),w=requestAnimationFrame(ge);}ve();let ye=new IntersectionObserver(p=>{p.forEach(O=>{k=O.isIntersecting,k&&!x?w=requestAnimationFrame(ge):cancelAnimationFrame(w);});}),N;function C(){clearTimeout(N),N=setTimeout(()=>{if(i==="lines"){let p=E;t.innerHTML=G,t.setAttribute("aria-label",t.textContent??""),ce=Kt(t),H(p);}ve();},150);}window.addEventListener("resize",C),window.addEventListener("orientationchange",C);let f=Fe([t],C);return ye.observe(t),Ie(t,{type:"text",getProgress:()=>E,getTrigger:()=>({tStart:P,tEnd:I})}),{destroy(){cancelAnimationFrame(w),ye.disconnect(),window.removeEventListener("resize",C),window.removeEventListener("orientationchange",C),f(),clearTimeout(N),t.innerHTML=G,t.removeAttribute("aria-label"),Oe(t);},replay(){M=-1,ne=false,E=0,x=false,H(0);},pause(){x=true,cancelAnimationFrame(w);},resume(){x&&(x=false,k&&(w=requestAnimationFrame(ge)));},seek(p){let O=Math.min(1,Math.max(0,p));E=O,M=O,x=true,cancelAnimationFrame(w),H(O);},getProgress(){return E}}}function Ze(e,r,n){let t=r,i=yt(r),s=n(e,ht(r,()=>t));return {update(l){t=l;let u=yt(l);u!==i&&(i=u,s.destroy(),s=n(e,ht(l,()=>t)));},destroy(){s.destroy();}}}function In(e,r={}){return Ze(e,r,gt)}function On(e={}){let r=null;function n(t){return r=gt(t,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}function Dn(e,r){return Ze(e,r,bt)}function Fn(e){let r=null;function n(t){return r=bt(t,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}function Rn(e,r){return Ze(e,r,vt)}function Hn(e){let r=null;function n(t){return r=vt(t,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}function Nn(e,r={}){return Ze(e,r,Et)}function Vn(e={}){let r=null;function n(t){return r=Et(t,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}function zn(e,r={}){return Ze(e,r,St)}function _n(e={}){let r=null;function n(t){return r=St(t,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}exports.createScrollAnimate=Fn;exports.createScrollCounter=Hn;exports.createScrollDraw=On;exports.createScrollText=_n;exports.createScrollVideo=Vn;exports.scrollAnimate=Dn;exports.scrollCounterAction=Rn;exports.scrollDraw=In;exports.scrollTextAction=zn;exports.scrollVideoAction=Nn;
|
|
1
|
+
'use strict';function mn({bounces:e=3,decay:t=.5}={}){let n=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,t)),s=Math.sqrt(r),i=0,a=[];for(let d=0;d<n;d++){let x=Math.pow(s,d);a.push(x),i+=x;}let u=[0],f=0;for(let d=0;d<n;d++)f+=a[d]/i,u.push(f);return d=>{if(d<=0)return 0;if(d>=1)return 1;for(let x=0;x<n;x++)if(d<=u[x+1]){let R=(d-u[x])/(u[x+1]-u[x]);if(x===0)return R*(2-R);let C=1-Math.pow(r,x);return C+(1-C)*(2*R-1)*(2*R-1)}return 1}}function fn({amplitude:e=1,period:t=.4}={}){let n=Math.max(1,e),r=Math.max(.1,t),s=n<=1?r/4:r/(2*Math.PI)*Math.asin(1/n);return i=>i<=0?0:i>=1?1:n*Math.pow(2,-10*i)*Math.sin((i-s)*(2*Math.PI)/r)+1}var oe={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:mn(),elastic:fn()};function Dt(e,t,n){return Math.min(n,Math.max(t,e))}function ye(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[n="top",r="bottom"]=t.split(/\s+/).filter(Boolean);return {element:n,viewport:r}}function Ft(e,t,n,r){switch(r){case "top":return e+n;case "center":return e+n+t/2;case "bottom":return e+n+t;default:return e+n}}function Rt(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function ee(e,t,n,r){return n===t?0:Dt((e-t)/(n-t)*r,0,1)}function Le(e,t,n,r,s){let i=Ft(e.top,e.height,t,r.element)-Rt(r.viewport,n),a=Ft(e.top,e.height,t,s.element)-Rt(s.viewport,n);return {tStart:i,tEnd:a}}function st(e,t,n){let r=e.getBoundingClientRect(),s=n==="x"?r.width:r.height;return t?{top:n==="x"?r.left-t.getBoundingClientRect().left+t.scrollLeft:r.top-t.getBoundingClientRect().top+t.scrollTop,height:s,scroll:0}:{top:n==="x"?r.left:r.top,height:s,scroll:n==="x"?window.scrollX:window.scrollY}}function je(e){let t=e.tagName.toLowerCase();if(t==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),r=parseFloat(e.getAttribute("height")??"0");return 2*(n+r)}if(t==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ht(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return [parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let r=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return r?[parseInt(r[1]),parseInt(r[2]),parseInt(r[3])]:null}function Qe(e,t,n){let r=Ht(e),s=Ht(t);return !r||!s?e:`rgb(${Math.round(r[0]+(s[0]-r[0])*n)},${Math.round(r[1]+(s[1]-r[1])*n)},${Math.round(r[2]+(s[2]-r[2])*n)})`}var Nt={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};var Xe=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function he(e,...t){Xe&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var pn="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",dn="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",Vt=33;function gn(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function yn(e){let t=[];for(let n=0;n<Vt;n++){let r=n/(Vt-1);t.push(String(Math.round(e(r)*1e5)/1e5));}return `linear(${t.join(",")})`}function it(e){switch(e){case "linear":return "linear";case "ease-in":return pn;case "ease-out":return dn;case "ease-in-out":return gn()?yn(oe["ease-in-out"]):null;default:return null}}var zt=Symbol.for("svg-scroll-draw.registry");function _t(){let e=globalThis;return e[zt]||(e[zt]=new Map)}function Pe(e,t){_t().set(e,t);}function ke(e){_t().delete(e);}var Ke,at=new Set,lt=new WeakMap,Ze=new Map,Wt=e=>{let t=e.getBoundingClientRect();return t.width+" "+t.height};function hn(e){let t=new Set;for(let n of e)for(;n&&n!==document.body;n=n.parentElement)for(let r=n;r;r=r.previousElementSibling)t.add(r);return t}function Fe(e,t){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let n=()=>t();Ke??(Ke=new ResizeObserver(s=>{let i=false;for(let{target:a}of s)lt.get(a)!==Wt(a)&&(i=true),lt.set(a,"");i&&at.forEach(a=>a());})),at.add(n);let r=hn(e);return [document.body,document.documentElement].forEach(s=>s&&r.add(s)),r.forEach(s=>{lt.has(s)||lt.set(s,Wt(s)),Ze.set(s,(Ze.get(s)??0)+1),Ke.observe(s);}),()=>{at.delete(n)&&(r.forEach(s=>{let i=(Ze.get(s)??1)-1;if(i)return void Ze.set(s,i);Ze.delete(s),Ke?.unobserve(s);}),at.size||(Ke?.disconnect(),Ke=void 0));}}function ct(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),n=s=>e(!!s.matches);if(typeof t.addEventListener=="function")return t.addEventListener("change",n),()=>t.removeEventListener("change",n);let r=t;return r.addListener?.(n),()=>r.removeListener?.(n)}function qe(e,t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t(e,true);let n=t(e,false),r=ct(i=>{if(!i)return;r();let a=(n.getProgress?.()??0)>=1;n.destroy(),n=t(a?{...e,onComplete:void 0}:e,true);}),s={};for(let i of Object.keys(n))s[i]=(...a)=>n[i]?.(...a);return s.destroy=()=>{r(),n.destroy();},s}var bn=0;function wn(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function qt(e,t){let n="";try{n=getComputedStyle(e).getPropertyValue(t).trim();}catch{}return n||(e.getAttribute(t)??"").trim()}var Bt=new Set(["","none","transparent","rgba(0, 0, 0, 0)"]);function vn(e){if(!Xe)return;let t=qt(e,"stroke");if(!t||t==="none"){he("Element has no stroke \u2014 path will not be visible.",e);return}let n=(e.getAttribute("fill")??"").trim();n&&!Bt.has(n)&&!Bt.has(qt(e,"fill"))&&he("Element has a fill \u2014 it may obscure the stroke animation.",e);}function En(e,t,n){let r=document.createElement("div");r.setAttribute("data-svg-scroll-draw-debug",""),r.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function s(){let i=n==="x"?window.scrollX:window.scrollY,a=e-i,u=t-i,f=n==="x";r.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${f?`left:${a}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${a}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
+
<div style="position:absolute;${f?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(r),window.addEventListener("scroll",s,{passive:true}),s(),{el:r,destroy(){window.removeEventListener("scroll",s),r.remove();}}}var Gt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,jt=/[MmLlHhVvCcSsQqTtAaZz]/g;function Sn(e,t,n){if(!Xe)return;let r=(e.match(jt)??[]).join("").toUpperCase(),s=(t.match(jt)??[]).join("").toUpperCase(),i=(e.match(Gt)??[]).length,a=(t.match(Gt)??[]).length;if(r!==s){he(`morphTo: command sequence differs (${r||"\u2205"} \u2192 ${s||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,n);return}i!==a&&he(`morphTo: coordinate count differs (${i} \u2192 ${a}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,n);}function yt(e,t,n){let r=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),s=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,i=>{let a=parseFloat(i),u=r[s++]??a;return String(+(a+(u-a)*n).toFixed(4))})}function ht(e,t={}){return typeof window>"u"?{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0}:qe(t,(n,r)=>Tn(e,n,r))}function Tn(e,t,n){let{preset:r,...s}=t,i=r?{...Nt[r],...s}:s,{selector:a="path, polyline, line, polygon, rect, circle",speed:u=1,fade:f=false,easing:d="linear",trigger:x={},stagger:R=0,direction:C="forward",once:Q=false,debug:me=false,axis:I="y",scrollContainer:se,autoReverse:be=false,delay:D=0,strokeColor:H,strokeWidth:k,fillOpacity:M,waypoints:w,velocityScale:v=false,threshold:T=0,rootMargin:U="0px",repeat:N=0,repeatDelay:B=0,morphTo:L,clip:fe,autoplay:Ee=false,duration:ie=1e3,native:z=true,onProgress:m,onStart:A,onComplete:h,onEnter:O,onLeave:te,onEnterBack:pe,onLeaveBack:Se}=i,Z=fe===true?"left":typeof fe=="string"?fe:false,E=typeof d=="function"?d:oe[d]??oe.linear,de=ye(x.start??"top bottom"),Ae=ye(x.end??"bottom top"),ae=typeof se=="string"?document.querySelector(se):se??null,le=Array.isArray(H)?H[0]:null,ne=Array.isArray(H)?H[1]:typeof H=="string"?H:null,re=Array.isArray(k)?k[0]:null,Y=Array.isArray(k)?k[1]:typeof k=="number"?k:null,ge=Array.isArray(M)?M[0]:null,J=Array.isArray(M)?M[1]:typeof M=="number"?M:null;function Oe(o){let c=o*100;switch(Z){case "right":return `inset(0 0 0 ${100-c}%)`;case "top":return `inset(0 0 ${100-c}% 0)`;case "bottom":return `inset(${100-c}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-c}% 0 0)`}}let _=Z?[]:Array.from(e.querySelectorAll(a)),P=[],we=[],l=0,p=0,$e=R,Te=0,$=false,V=false,G=0,Ne=false,q=-1,Re=[],Ve=-1,ce=false,Ie=0,He=0,ze,ut=null;function Mt(){ut?.destroy(),ut=null;}let _e=new Set,Lt=NaN,We=true,et=-1,At=performance.now(),Be=NaN;function Ue(){return ae?I==="x"?ae.scrollLeft:ae.scrollTop:I==="x"?window.scrollX:window.scrollY}function $t(){return ae?I==="x"?ae.clientWidth:ae.clientHeight:I==="x"?window.innerWidth:window.innerHeight}function Ct(){let o=st(e,ae,I);return Le(o,o.scroll,$t(),de,Ae)}function on(){let o=p-l,c=_.length-1,y=ae??document.documentElement,X=I==="x"?"Width":"Height";if($e=R,R>0&&c>0&&o>0){let xe=y[`scroll${X}`]-y[`client${X}`]-1-l-o/u;xe>=0&&($e=Math.min(R,xe/(c*o)));}Te=p+c*$e*o;}function Pt(){(({tStart:l,tEnd:p}=Ct())),on(),me&&Xe&&(Mt(),ut=En(l,p,I));}function mt(o,c=Ct){Pe(e,{type:"draw",getProgress:()=>o.getProgress(),getTrigger:c});let y=o.destroy;return o.destroy=()=>{y.call(o),ke(e);},o}function sn(o,c){if(e.style.setProperty("--scroll-draw-progress",String(o)),Z){let y=c==="reverse"?1-o:o;e.style.clipPath=Oe(y);return}_.forEach((y,X)=>{y.style.strokeDashoffset=c==="reverse"?`${P[X]*o}`:`${P[X]*(1-o)}`,f&&(y.style.opacity=c==="reverse"?`${1-o}`:`${o}`),le&&ne?y.style.stroke=Qe(le,ne,o):ne&&(y.style.stroke=ne),re!==null&&Y!==null?y.style.strokeWidth=`${re+(Y-re)*o}`:Y!==null&&(y.style.strokeWidth=`${Y}`),ge!==null&&J!==null?y.style.fillOpacity=`${ge+(J-ge)*o}`:J!==null&&(y.style.fillOpacity=`${J}`),L&&y.tagName.toLowerCase()==="path"&&we[X]&&y.setAttribute("d",yt(we[X],L,o));});}function tt(){if(e.style.setProperty("--scroll-draw-progress","0"),Z){e.style.clipPath=Oe(0);return}_.forEach((o,c)=>{o.style.strokeDasharray=`${P[c]}`,o.style.strokeDashoffset=C==="reverse"?"0":`${P[c]}`,f?o.style.opacity=C==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),re!==null&&(o.style.strokeWidth=`${re}`),ge!==null&&(o.style.fillOpacity=`${ge}`),L&&o.tagName.toLowerCase()==="path"&&we[c]&&o.setAttribute("d",we[c]);});}if(_.forEach(o=>{vn(o);let c=je(o);P.push(c);let y=o.tagName.toLowerCase()==="path";y?we.push(o.getAttribute("d")??""):we.push(""),L&&(y?Sn(we[we.length-1],L,o):he(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),n?(o.style.strokeDasharray=`${c}`,o.style.strokeDashoffset=C==="reverse"?`${c}`:"0",f&&(o.style.opacity="1"),ne&&(o.style.stroke=ne),Y!==null&&(o.style.strokeWidth=`${Y}`),J!==null&&(o.style.fillOpacity=`${J}`),L&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",L)):(o.style.strokeDasharray=`${c}`,o.style.strokeDashoffset=C==="reverse"?"0":`${c}`,f?o.style.opacity=C==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),re!==null&&(o.style.strokeWidth=`${re}`),ge!==null&&(o.style.fillOpacity=`${ge}`));}),Z){if(n)return e.style.clipPath=Oe(1),h?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=Oe(0);}else if(n)return h?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let kt=typeof d=="string"?it(d):null;function an(){return !(z===false||!wn()||!_.length||!kt||Z||I!=="y"||ae||u!==1||R!==0||Q||be||v!==false||L||w||N||D>0||m||A||h||O||te||pe||Se||H!=null||k!=null||M!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function ln(){let o=++bn,c=`svg-scroll-draw-${o}`,y=`svg-scroll-draw-host-${o}`,X=`--svg-scroll-draw-${o}`,xe=C==="reverse"?"0":"var(--ssd-len)",De=C==="reverse"?"var(--ssd-len)":"0",Ce=`stroke-dashoffset:${xe};`,S=`stroke-dashoffset:${De};`;f&&(Ce+=`opacity:${C==="reverse"?1:0};`,S+=`opacity:${C==="reverse"?0:1};`);let F=document.createElement("style");F.setAttribute("data-svg-scroll-draw",""),F.textContent=`@keyframes ${c}{from{${Ce}}to{${S}}}.${y}{view-timeline-name:${X};view-timeline-axis:block;}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${kt};animation-fill-mode:both;animation-timeline:${X};animation-range:cover 0% cover 100%;}`,document.head.appendChild(F),e.classList.add(y);function ue(g,K){g.style.setProperty("--ssd-len",String(P[K])),g.style.strokeDasharray=`${P[K]}`,g.style.strokeDashoffset="",g.style.opacity="",g.style.animationPlayState="",g.classList.add(c);}_.forEach(ue);let b=false,W=-1;function j(){if(W>=0)return W;let g=e.getBoundingClientRect(),{tStart:K,tEnd:Me}=Le({top:g.top,height:g.height},Ue(),$t(),de,Ae);return E(ee(Ue(),K,Me,u))}return {destroy(){e.classList.remove(y),_.forEach(g=>{g.classList.remove(c),g.style.removeProperty("--ssd-len"),g.style.animationPlayState="";}),F.remove();},replay(){b=false,W=-1,_.forEach(ue);},pause(){b=true,_.forEach(g=>{g.style.animationPlayState="paused";});},resume(){b&&(b=false,_.forEach(g=>{g.style.animationPlayState="running";}));},seek(g){let K=Math.min(1,Math.max(0,g));W=K,b=true,_.forEach((Me,ve)=>{Me.classList.remove(c),Me.style.strokeDashoffset=C==="reverse"?`${P[ve]*K}`:`${P[ve]*(1-K)}`,f&&(Me.style.opacity=C==="reverse"?`${1-K}`:`${K}`);});},getProgress(){return j()},refresh(){_.forEach((g,K)=>{P[K]=je(g),g.style.setProperty("--ssd-len",String(P[K])),g.style.strokeDasharray=`${P[K]}`;});}}}if(an())return mt(ln());function cn(){let o=Math.max(1,ie),c=0,y=0,X=false;function xe(b){let W=true;if(Z){let j=Math.min(1,Math.max(0,b/o)),g=E(j);Ie=g,e.style.setProperty("--scroll-draw-progress",String(g)),e.style.clipPath=Oe(C==="reverse"?1-g:g),m?.(g),j<1&&(W=false);}else _.forEach((j,g)=>{let K=g*R*o,Me=Math.min(1,Math.max(0,(b-K)/o)),ve=E(Me);j.style.strokeDashoffset=C==="reverse"?`${P[g]*ve}`:`${P[g]*(1-ve)}`,f&&(j.style.opacity=C==="reverse"?`${1-ve}`:`${ve}`),le&&ne?j.style.stroke=Qe(le,ne,ve):ne&&(j.style.stroke=ne),re!==null&&Y!==null?j.style.strokeWidth=`${re+(Y-re)*ve}`:Y!==null&&(j.style.strokeWidth=`${Y}`),ge!==null&&J!==null?j.style.fillOpacity=`${ge+(J-ge)*ve}`:J!==null&&(j.style.fillOpacity=`${J}`),L&&j.tagName.toLowerCase()==="path"&&we[g]&&j.setAttribute("d",yt(we[g],L,ve)),g===0&&(Ie=ve,m?.(ve),e.style.setProperty("--scroll-draw-progress",String(ve))),Me<1&&(W=false);});if(w){let j=Math.min(1,Math.max(0,b/o)),g=E(j);for(let K in w){let Me=parseFloat(K);g>=Me&&!_e.has(Me)&&(_e.add(Me),w[K]?.());}}return W}function De(b){if(ce)return;let W=b-c;V||(V=true,A?.());let j=xe(W);if(j&&!$){$=true,xe(o*(1+Math.max(0,_.length-1)*R)),h?.(),He<(N==="infinite"?1/0:N??0)&&(He++,ze=setTimeout(()=>{c=performance.now(),V=false,$=false,_e.clear(),tt(),G=requestAnimationFrame(De);},B));return}j||(G=requestAnimationFrame(De));}function Ce(){cancelAnimationFrame(G),clearTimeout(ze),c=performance.now(),y=0,ce=false,V=false,$=false,He=0,X=true,Ie=0,_e.clear(),tt(),G=requestAnimationFrame(De);}let S=new IntersectionObserver(b=>{b.forEach(W=>{W.isIntersecting&&!(Q&&$)?Ce():!W.isIntersecting&&!Q&&!$&&(cancelAnimationFrame(G),clearTimeout(ze),X=false);});},{root:ae??null,threshold:T,rootMargin:U}),F;function ue(){clearTimeout(F),F=setTimeout(()=>{_.forEach((b,W)=>{P[W]=je(b),b.style.strokeDasharray=`${P[W]}`;});},150);}return window.addEventListener("resize",ue),window.addEventListener("orientationchange",ue),D>0?setTimeout(()=>S.observe(e),D):S.observe(e),{destroy(){cancelAnimationFrame(G),clearTimeout(ze),S.disconnect(),window.removeEventListener("resize",ue),window.removeEventListener("orientationchange",ue),clearTimeout(F);},replay(){He=0,Ce();},pause(){ce||!X||(ce=true,y=performance.now()-c,cancelAnimationFrame(G));},resume(){ce&&(ce=false,X=true,c=performance.now()-y,G=requestAnimationFrame(De));},seek(b){let W=Math.min(1,Math.max(0,b));Ie=W,ce=true,y=W*o,c=performance.now()-y,cancelAnimationFrame(G),xe(y);},getProgress(){return Ie},refresh(){clearTimeout(F),_.forEach((b,W)=>{P[W]=je(b),b.style.strokeDasharray=`${P[W]}`;});}}}if(Ee)return mt(cn());Pt();function Ot(){if(ce||!Ge)return;let o=performance.now(),c=Ue();if(!We&&v===false&&c===Lt){pt(c);return}We=false,Lt=c;let y=u;if(v!==false){let S=o-At,F=S>0?Math.abs(c-(et<0?c:et))/S:0;y=u*Math.max(.2,1+F*(typeof v=="number"?v:1)*.04);}et=c,At=o;let X=be?Ve===-1||c>=Ve?"forward":"reverse":C;Ve=c;let xe=p-l,De=true,Ce=xe===0?0:(c-l)/xe;if(isNaN(Be)||(Be<=0&&Ce>0?O?.():Be>0&&Ce<=0&&Se?.(),Be<1&&Ce>=1?te?.():Be>=1&&Ce<1&&pe?.()),Be=Ce,Z){let S=E(ee(c,l,p,y));Q&&!be&&(q=Math.max(q,S),S=q),Ie=S,e.style.setProperty("--scroll-draw-progress",String(S));let F=X==="reverse"?1-S:S;e.style.clipPath=Oe(F),m?.(S),!V&&ee(c,l,p,y)>0&&(V=true,A?.()),S>=1&&!$?($=true,h?.(),He<(N==="infinite"?1/0:N??0)&&(He++,ze=setTimeout(()=>{q=-1,V=false,$=false,e.style.clipPath=Oe(0);},B))):S<1&&!Q&&($=false),pt(c);return}if(_.forEach((S,F)=>{let ue=F*$e*xe,b=E(ee(c,l+ue,p+ue,y));Q&&!be&&(b=Re[F]=Math.max(Re[F]??q,b)),S.style.strokeDashoffset=X==="reverse"?`${P[F]*b}`:`${P[F]*(1-b)}`,f&&(S.style.opacity=X==="reverse"?`${1-b}`:`${b}`),le&&ne?S.style.stroke=Qe(le,ne,b):ne&&(S.style.stroke=ne),re!==null&&Y!==null?S.style.strokeWidth=`${re+(Y-re)*b}`:Y!==null&&(S.style.strokeWidth=`${Y}`),ge!==null&&J!==null?S.style.fillOpacity=`${ge+(J-ge)*b}`:J!==null&&(S.style.fillOpacity=`${J}`),L&&S.tagName.toLowerCase()==="path"&&we[F]&&S.setAttribute("d",yt(we[F],L,b)),F===0&&(Ie=b,m?.(b),e.style.setProperty("--scroll-draw-progress",String(b))),b<1&&(De=false);}),w){let S=E(ee(c,l,p,y));for(let F in w){let ue=parseFloat(F);S>=ue&&!_e.has(ue)&&(_e.add(ue),w[F]?.());}}!V&&ee(c,l,p,y)>0&&(V=true,A?.()),De&&!$?($=true,h?.(),He<(N==="infinite"?1/0:N??0)&&(He++,ze=setTimeout(()=>{q=-1,Re=[],V=false,$=false,_e.clear(),tt(),We=true;},B))):!De&&!Q&&($=false),pt(c);}function ft(o){return o>=p&&o<Te}function pt(o){Ne||ft(o)?G=requestAnimationFrame(Ot):Ge=false;}function dt(){return Ne||ft(Ue())}let Ge=false;function nt(){Ge||(Ge=true,G=requestAnimationFrame(function(){Ot();}));}function rt(){Ge=false,cancelAnimationFrame(G);}let gt=new IntersectionObserver(o=>{o.forEach(c=>{Ne=c.isIntersecting,Ne&&!ce?(We=true,nt()):Ge&&!ce&&ft(Ue())||rt();});},{root:ae??null,threshold:T,rootMargin:U});function It(){_.forEach((o,c)=>{P[c]=je(o),o.style.strokeDasharray=`${P[c]}`;}),Pt(),We=true;}let ot;function Ye(){clearTimeout(ot),ot=setTimeout(It,150);}window.addEventListener("resize",Ye),window.addEventListener("orientationchange",Ye);let un=Fe([e],Ye);return D>0?setTimeout(()=>gt.observe(e),D):gt.observe(e),mt({destroy(){cancelAnimationFrame(G),clearTimeout(ze),rt(),gt.disconnect(),un(),window.removeEventListener("resize",Ye),window.removeEventListener("orientationchange",Ye),clearTimeout(ot),Mt();},replay(){q=-1,Re=[],Ve=-1,et=-1,V=false,$=false,He=0,ce=false,Ie=0,_e.clear(),clearTimeout(ze),tt(),We=true,dt()&&nt();},pause(){ce=true,rt();},resume(){ce&&(ce=false,We=true,dt()&&nt());},seek(o){let c=Math.min(1,Math.max(0,o));Ie=c,q=c,Re=[],ce=true,rt(),sn(c,C),We=true;},getProgress(){return Ie},refresh(){clearTimeout(ot),It(),dt()&&!ce&&nt();}},()=>({tStart:l,tEnd:p}))}var Qt=new WeakMap,xn=0;function bt(e){return JSON.stringify(e,(t,n)=>{if(typeof n=="function")return "\u0192";if(typeof Element<"u"&&n instanceof Element){let r=Qt.get(n);return r===void 0&&Qt.set(n,r=++xn),`el#${r}`}return n})}function wt(e,t){let n={...e};for(let r of Object.keys(n))typeof n[r]=="function"&&(n[r]=(...s)=>t()[r]?.(...s));return n}function Mn(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Ut(e){let t=[],n=/([\w]+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let s=[],i=[],a=r[2].trim();if(a)for(let u of a.split(/[\s,]+/)){let f=u.match(/^([-+]?[\d.eE]+)(.*)$/);s.push(f?parseFloat(f[1]):0),i.push(f?f[2]:"");}t.push({fn:r[1],nums:s,units:i});}return t}function Ln(e,t,n){let r=Ut(e),s=Ut(t);return r.length===0||r.length!==s.length?n<1?e:t:r.map((i,a)=>{let u=s[a];return i.fn!==u.fn||i.nums.length!==u.nums.length?n<1?`${i.fn}(${i.nums.map((f,d)=>`${f}${i.units[d]}`).join(", ")})`:`${u.fn}(${u.nums.map((f,d)=>`${f}${u.units[d]}`).join(", ")})`:`${i.fn}(${i.nums.map((f,d)=>`${f+(u.nums[d]-f)*n}${i.units[d]}`).join(", ")})`}).join(" ")}function Yt(e,t,n){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*n);let r=String(e),s=String(t);if(Mn(r))return Qe(r,s,n);if(r.includes("("))return Ln(r,s,n);let i=r.match(/^([-+]?[\d.]+)(.*)$/),a=s.match(/^([-+]?[\d.]+)(.*)$/);if(i&&a){let u=parseFloat(i[1]),f=parseFloat(a[1]);return `${u+(f-u)*n}${i[2]||a[2]}`}return n<1?r:s}function An(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var $n=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Cn=0,Xt="--scroll-draw-progress";function Pn(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}var Zt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function vt(e,t){return typeof window>"u"?Zt:t.respectReducedMotion===false?Kt(e,t,false):qe(t,(n,r)=>Kt(e,n,r))}function Kt(e,t,n){let{props:r,trigger:s={},easing:i="ease-out",speed:a=1,once:u=false,axis:f="y",scrollContainer:d,native:x=true,velocityScale:R=false,triggerElement:C,onProgress:Q,onComplete:me,onEnter:I,onLeave:se,onEnterBack:be,onLeaveBack:D}=t,H=typeof i=="function"?i:oe[i]??oe["ease-out"],k=ye(s.start??"top bottom"),M=ye(s.end??"bottom top"),w=C??e,v=typeof d=="string"?document.querySelector(d):d??null,T=Object.entries(r).map(([l,p])=>({prop:An(l),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function U(){let l=window.getComputedStyle(e);for(let p of T)p.from===""&&(p.from=l.getPropertyValue(p.prop).trim()||"0");}function N(){for(let l of T)e.style.setProperty(l.prop,String(l.to));}let B=new Map;for(let l of [...T.map(p=>p.prop),Xt])B.set(l,e.style.getPropertyValue(l));function L(){for(let[l,p]of B)p?e.style.setProperty(l,p):e.style.removeProperty(l);}if(n)return N(),me?.(),{...Zt,destroy:L,getProgress:()=>1};U();let fe=typeof i=="string"?it(i):null;function Ee(){if(!x||!Pn()||!fe||f!=="y"||v||w!==e||u||a!==1||Q||me||I||se||be||D||R!==false||(s.start??"top bottom").trim()!=="top bottom"||(s.end??"bottom top").trim()!=="bottom top")return false;for(let l of T)if(!$n.has(l.prop))return false;return true}function ie(){let l=`ssd-a-${++Cn}`,p=T.map(q=>`${q.prop}:${q.from}`).join(";"),$e=T.map(q=>`${q.prop}:${q.to}`).join(";"),Te=document.createElement("style");Te.setAttribute("data-ssd-animate",""),Te.textContent=`@keyframes ${l}{from{${p}}to{${$e}}}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${fe};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(Te),e.classList.add(l);let $=()=>f==="x"?window.scrollX:window.scrollY,V=()=>f==="x"?window.innerWidth:window.innerHeight,G=()=>{let q=e.getBoundingClientRect();return Le({top:q.top,height:q.height},$(),V(),k,M)};Pe(e,{type:"animate",getProgress:()=>Ne.getProgress(),getTrigger:G});let Ne={refresh(){},destroy(){e.classList.remove(l),Te.remove(),e.style.animationPlayState="",L(),ke(e);},replay(){e.classList.remove(l),e.offsetWidth,e.classList.add(l);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(q){let Re=Math.min(1,Math.max(0,q));e.classList.remove(l);for(let Ve of T)e.style.setProperty(Ve.prop,Yt(Ve.from,Ve.to,Re));},getProgress(){let{tStart:q,tEnd:Re}=G();return H(ee($(),q,Re,a))}};return Ne}if(Ee())return ie();let z=0,m=0,A=0,h=false,O=false,te=-1,pe=0,Se=false,Z=NaN,E=-1,de=0,Ae=()=>v?f==="x"?v.scrollLeft:v.scrollTop:f==="x"?window.scrollX:window.scrollY,ae=()=>v?f==="x"?v.clientWidth:v.clientHeight:f==="x"?window.innerWidth:window.innerHeight,le=w===e?T:[],ne=false;function re(){let l=e.style,p=le.map(V=>l.getPropertyValue(V.prop)),$e=l.transition;le.length&&(l.transition="none"),le.forEach(V=>l.setProperty(V.prop,B.get(V.prop)??""));let Te=st(w,v,f);le.forEach((V,G)=>l.setProperty(V.prop,p[G])),le.length&&(e.offsetWidth,l.transition=$e);let $=Le(Te,Te.scroll,ae(),k,M);ne&&Math.abs($.tStart-z)<1&&Math.abs($.tEnd-m)<1||(ne=true,z=$.tStart,m=$.tEnd);}function Y(l){e.style.setProperty(Xt,String(l));for(let p of T)e.style.setProperty(p.prop,Yt(p.from,p.to,l));Q?.(l);}function ge(l){if(isNaN(Z)){Z=l;return}Z<=0&&l>0?I?.():Z>0&&l<=0&&D?.(),Z<1&&l>=1?se?.():Z>=1&&l<1&&be?.(),Z=l;}function J(){if(!h||O)return;let l=performance.now(),p=Ae(),$e=a;if(R!==false){let V=l-de,G=V>0?Math.abs(p-(E<0?p:E))/V:0;$e=a*Math.max(.2,1+G*(typeof R=="number"?R:1)*.04);}E=p,de=l;let Te=m===z?0:(p-z)/(m-z);ge(Te);let $=H(ee(p,z,m,$e));u&&(te=Math.max(te,$),$=te),pe=$,Y($),$>=1&&!Se?(Se=true,me?.()):$<1&&!u&&(Se=false),A=requestAnimationFrame(J);}re(),m===z&&he("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let l=H(ee(Ae(),z,m,a));u&&l>0&&(te=l),pe=l,Y(l);}let Oe=new IntersectionObserver(l=>{l.forEach(p=>{h=p.isIntersecting,h&&!O?A=requestAnimationFrame(J):cancelAnimationFrame(A);});},{root:v??null}),_;function P(){clearTimeout(_),_=setTimeout(re,150);}window.addEventListener("resize",P),window.addEventListener("orientationchange",P);let we=Fe([w],P);return Oe.observe(e),Pe(e,{type:"animate",getProgress:()=>pe,getTrigger:()=>({tStart:z,tEnd:m})}),{destroy(){cancelAnimationFrame(A),Oe.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),we(),clearTimeout(_),L(),ke(e);},replay(){te=-1,Se=false,pe=0,O=false,Y(0);},pause(){O=true,cancelAnimationFrame(A);},resume(){O&&(O=false,h&&(A=requestAnimationFrame(J)));},seek(l){let p=Math.min(1,Math.max(0,l));pe=p,te=p,O=true,cancelAnimationFrame(A),Y(p);},getProgress(){return pe},refresh(){re();}}}var Et={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function St(e,t){if(typeof window>"u")return Et;let n=typeof e=="string"?document.querySelector(e):e;return n?qe(t,(r,s)=>kn(n,r,s)):(he("scrollCounter: element not found:",e),Et)}function kn(e,t,n){let{from:r=0,to:s,format:i,easing:a="ease-out",trigger:u={},once:f=true,decimals:d,onComplete:x}=t,R=d!==void 0?m=>m.toFixed(d):i??(m=>String(Math.round(m))),C=typeof a=="function"?a:oe[a]??oe["ease-out"],Q=ye(u.start??"top 80%"),me=ye(u.end??"top 20%");if(n)return e.textContent=R(s),x?.(),{...Et,getProgress:()=>1};let I=0,se=0,be=false,D=0,H=false,k=false,M=-1,w=0,v=false,T=()=>window.scrollY,U=()=>window.innerHeight;function N(){let m=e.getBoundingClientRect(),A=Le({top:m.top,height:m.height},T(),U(),Q,me);be&&Math.abs(A.tStart-I)<1&&Math.abs(A.tEnd-se)<1||(be=true,I=A.tStart,se=A.tEnd);}function B(m){e.textContent=R(r+(s-r)*m),e.style.setProperty("--scroll-draw-progress",String(m));}function L(){if(!H||k)return;let m=C(ee(T(),I,se,1));f&&(M=Math.max(M,m),m=M),w=m,B(m),m>=1&&!v?(v=true,x?.()):m<1&&!f&&(v=false),D=requestAnimationFrame(L);}N();{let m=C(ee(T(),I,se,1));f&&m>0&&(M=m),w=m,B(m);}let fe=new IntersectionObserver(m=>{m.forEach(A=>{H=A.isIntersecting,H&&!k?D=requestAnimationFrame(L):cancelAnimationFrame(D);});}),Ee;function ie(){clearTimeout(Ee),Ee=setTimeout(N,150);}window.addEventListener("resize",ie),window.addEventListener("orientationchange",ie);let z=Fe([e],ie);return fe.observe(e),Pe(e,{type:"counter",getProgress:()=>w,getTrigger:()=>({tStart:I,tEnd:se})}),{destroy(){cancelAnimationFrame(D),fe.disconnect(),window.removeEventListener("resize",ie),window.removeEventListener("orientationchange",ie),z(),clearTimeout(Ee),ke(e);},replay(){M=-1,v=false,w=0,k=false,B(0);},pause(){k=true,cancelAnimationFrame(D);},resume(){k&&(k=false,H&&(D=requestAnimationFrame(L)));},seek(m){let A=Math.min(1,Math.max(0,m));w=A,M=A,k=true,cancelAnimationFrame(D),B(A);},getProgress(){return w}}}var Jt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Tt(e,t={}){if(typeof window>"u")return Jt;let n=typeof e=="string"?document.querySelector(e):e;if(!n||n.tagName.toLowerCase()!=="video")return he("scrollVideo: <video> element not found:",e),Jt;let r=n,{trigger:s={},easing:i="linear",once:a=false,axis:u="y",preload:f="auto",triggerElement:d,onReady:x,onComplete:R,onProgress:C}=t,Q=d??r,me=window.matchMedia("(prefers-reduced-motion: reduce)").matches,I=typeof i=="function"?i:oe[i]??oe.linear,se=ye(s.start??"top top"),be=ye(s.end??"bottom top");r.pause(),r.hasAttribute("preload")||(r.preload=f);let D=t.from??0,H=t.to,k=0,M=0,w=0,v=false,T=false,U=-1,N=0,B=false,L=false,fe=()=>u==="x"?window.scrollX:window.scrollY,Ee=()=>u==="x"?window.innerWidth:window.innerHeight;function ie(){let E=Q.getBoundingClientRect(),de=u==="x"?E.left:E.top,Ae=u==="x"?E.width:E.height,ae=Le({top:de,height:Ae},fe(),Ee(),se,be);k=ae.tStart,M=ae.tEnd,L&&M===k&&he("scrollVideo: zero-length trigger window, so it never scrubs. In a sticky stage, set triggerElement.",r);}let z=NaN;function m(E){if(!L)return;let de=H??r.duration??0,Ae=D+(de-D)*E;Ae!==z&&(z=Ae,r.currentTime=Ae),r.style.setProperty("--scroll-draw-progress",String(E)),C?.(E);}function A(){if(!v||T||!L||me)return;let E=I(ee(fe(),k,M,1));a&&(U=Math.max(U,E),E=U),N=E,m(E),E>=1&&!B?(B=true,R?.()):E<1&&!a&&(B=false),w=requestAnimationFrame(A);}function h(){if(L=true,H===void 0&&(H=r.duration),me){m(1),x?.();return}ie(),x?.(),v&&!T&&(w=requestAnimationFrame(A));}r.readyState>=1?h():r.addEventListener("loadedmetadata",h,{once:true}),L||ie();let O=me?()=>{}:ct(E=>{E&&(O(),me=true,cancelAnimationFrame(w),m(1));}),te=new IntersectionObserver(E=>{E.forEach(de=>{v=de.isIntersecting,v&&!T&&L?w=requestAnimationFrame(A):cancelAnimationFrame(w);});}),pe;function Se(){clearTimeout(pe),pe=setTimeout(ie,150);}window.addEventListener("resize",Se),window.addEventListener("orientationchange",Se);let Z=Fe([Q],Se);return te.observe(r),Pe(r,{type:"video",getProgress:()=>N,getTrigger:()=>({tStart:k,tEnd:M})}),{destroy(){cancelAnimationFrame(w),te.disconnect(),r.removeEventListener("loadedmetadata",h),window.removeEventListener("resize",Se),window.removeEventListener("orientationchange",Se),Z(),O(),clearTimeout(pe),ke(r);},replay(){U=-1,B=false,N=0,T=false,z=NaN,m(0);},pause(){T=true,cancelAnimationFrame(w);},resume(){T&&(T=false,v&&L&&(w=requestAnimationFrame(A)));},seek(E){let de=Math.min(1,Math.max(0,E));N=de,U=de,T=true,cancelAnimationFrame(w),z=NaN,m(de);},getProgress(){return N}}}function en(e,t){let n=document.createElement("span");n.textContent=t,n.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;user-select:none",e.appendChild(n);}function rn(e){let t=e.textContent??"";return e.textContent="",t.split(/(\s+)/).filter(Boolean).map(n=>{let r=document.createElement("span");return r.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(r.textContent=n,r.style.whiteSpace="pre"):(r.textContent=n,r.style.display="inline-block"),e.appendChild(r),/^\s+$/.test(n)?null:r}).filter(n=>n!==null)}function On(e){let t=e.textContent??"";return e.textContent="",t.split("").map(n=>{let r=document.createElement("span");return r.setAttribute("aria-hidden","true"),r.textContent=n,n===" "?r.style.whiteSpace="pre":r.style.display="inline-block",e.appendChild(r),n===" "?null:r}).filter(n=>n!==null)}function tn(e){let t=rn(e),n=new Map;for(let i of t){let a=i.offsetTop;n.has(a)||n.set(a,[]),n.get(a).push(i);}let r=[],s=Array.from(n.keys()).sort((i,a)=>i-a);for(let i of s){let a=n.get(i),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block",a.forEach((f,d)=>{let x=f.nextElementSibling;u.appendChild(f),d<a.length-1&&x&&x.style.whiteSpace==="pre"&&u.appendChild(x);}),r.push(u);}return e.textContent="",r.forEach((i,a)=>{e.appendChild(i),a<r.length-1&&e.appendChild(document.createTextNode(" "));}),r}function In(e,t,n,r){if(n<=1||r===0)return e;let s=(n-1)*r,i=t*r,a=i+(1-s);return a<=i?e>=i?1:0:Math.min(1,Math.max(0,(e-i)/(a-i)))}function Dn(e,t){let n=[];if(t?.y!==void 0&&n.push(`translateY(${t.y*(1-e)}px)`),t?.x!==void 0&&n.push(`translateX(${t.x*(1-e)}px)`),t?.rotate!==void 0&&n.push(`rotate(${t.rotate*(1-e)}deg)`),t?.scale!==void 0){let r=t.scale+(1-t.scale)*e;n.push(`scale(${r})`);}return n.join(" ")||""}var nn={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function xt(e,t={}){if(typeof window>"u")return nn;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return he("scrollText: element not found:",e),nn;let r=n;return qe(t,(s,i)=>Fn(r,s,i))}function Fn(e,t,n){let{split:r="words",stagger:s=.04,easing:i="ease-out",from:a={opacity:0,y:24},trigger:u={},once:f=true,onComplete:d}=t,x=typeof i=="function"?i:oe[i]??oe["ease-out"],R=ye(u.start??"top 85%"),C=ye(u.end??"top 40%"),Q=e.innerHTML,me=e.textContent??"",I;r==="chars"?I=On(e):r==="lines"?I=tn(e):I=rn(e),en(e,me);let se=I.length;function be(h,O){a?.opacity!==void 0&&(h.style.opacity=String(a.opacity+(1-a.opacity)*O));let te=Dn(O,a);te&&(h.style.transform=te);}function D(h){e.style.setProperty("--scroll-draw-progress",String(h)),I.forEach((O,te)=>{let pe=x(In(h,te,se,s));be(O,pe);});}if(n)return D(1),d?.(),{destroy(){e.innerHTML=Q;},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};D(0);let H=0,k=0,M=0,w=false,v=false,T=-1,U=0,N=false,B=()=>window.scrollY,L=()=>window.innerHeight;function fe(){let h=e.getBoundingClientRect(),O=Le({top:h.top,height:h.height},B(),L(),R,C);H=O.tStart,k=O.tEnd;}function Ee(){if(!w||v)return;let h=ee(B(),H,k,1);f&&(T=Math.max(T,h),h=T),U=h,D(h),h>=1&&!N?(N=true,d?.()):h<1&&!f&&(N=false),M=requestAnimationFrame(Ee);}fe();let ie=new IntersectionObserver(h=>{h.forEach(O=>{w=O.isIntersecting,w&&!v?M=requestAnimationFrame(Ee):cancelAnimationFrame(M);});}),z;function m(){clearTimeout(z),z=setTimeout(()=>{if(r==="lines"){let h=U;e.innerHTML=Q,I=tn(e),en(e,me),D(h);}fe();},150);}window.addEventListener("resize",m),window.addEventListener("orientationchange",m);let A=Fe([e],m);return ie.observe(e),Pe(e,{type:"text",getProgress:()=>U,getTrigger:()=>({tStart:H,tEnd:k})}),{destroy(){cancelAnimationFrame(M),ie.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("orientationchange",m),A(),clearTimeout(z),e.innerHTML=Q,ke(e);},replay(){T=-1,N=false,U=0,v=false,D(0);},pause(){v=true,cancelAnimationFrame(M);},resume(){v&&(v=false,w&&(M=requestAnimationFrame(Ee)));},seek(h){let O=Math.min(1,Math.max(0,h));U=O,T=O,v=true,cancelAnimationFrame(M),D(O);},getProgress(){return U}}}function Je(e,t,n){let r=t,s=bt(t),i=n(e,wt(t,()=>r));return {update(a){r=a;let u=bt(a);u!==s&&(s=u,i.destroy(),i=n(e,wt(a,()=>r)));},destroy(){i.destroy();}}}function Ur(e,t={}){return Je(e,t,ht)}function Yr(e={}){let t=null;function n(r){return t=ht(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function Xr(e,t){return Je(e,t,vt)}function Kr(e){let t=null;function n(r){return t=vt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function Zr(e,t){return Je(e,t,St)}function Jr(e){let t=null;function n(r){return t=St(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function eo(e,t={}){return Je(e,t,Tt)}function to(e={}){let t=null;function n(r){return t=Tt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function no(e,t={}){return Je(e,t,xt)}function ro(e={}){let t=null;function n(r){return t=xt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}exports.createScrollAnimate=Kr;exports.createScrollCounter=Jr;exports.createScrollDraw=Yr;exports.createScrollText=ro;exports.createScrollVideo=to;exports.scrollAnimate=Xr;exports.scrollCounterAction=Zr;exports.scrollDraw=Ur;exports.scrollTextAction=no;exports.scrollVideoAction=eo;
|
package/dist/svelte/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as ScrollDrawInstance, a as ScrollDrawOptions } from '../types-MswK0erX.mjs';
|
|
2
|
-
import { S as ScrollAnimateOptions } from '../engine-
|
|
2
|
+
import { S as ScrollAnimateOptions } from '../engine-o1VSQ1lX.mjs';
|
|
3
3
|
import { S as ScrollCounterOptions } from '../index-CdaBYn3A.mjs';
|
|
4
4
|
import { ScrollVideoOptions } from '../video/index.mjs';
|
|
5
5
|
import { ScrollTextOptions } from '../text/index.mjs';
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as ScrollDrawInstance, a as ScrollDrawOptions } from '../types-MswK0erX.js';
|
|
2
|
-
import { S as ScrollAnimateOptions } from '../engine-
|
|
2
|
+
import { S as ScrollAnimateOptions } from '../engine-B7UpB4fT.js';
|
|
3
3
|
import { S as ScrollCounterOptions } from '../index-D3o4vT3e.js';
|
|
4
4
|
import { ScrollVideoOptions } from '../video/index.js';
|
|
5
5
|
import { ScrollTextOptions } from '../text/index.js';
|
package/dist/svelte/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$4,b as b$1}from'../chunk-XSVTHCLO.mjs';import {a as a$3}from'../chunk-
|
|
1
|
+
import {a as a$4,b as b$1}from'../chunk-XSVTHCLO.mjs';import {a as a$3}from'../chunk-KV3WCPQ5.mjs';import {a as a$2}from'../chunk-DY5JCXVR.mjs';import {a as a$1}from'../chunk-WXUOF4NM.mjs';import {a}from'../chunk-LTCJVVSC.mjs';import {b}from'../chunk-HX4SP5WN.mjs';import'../chunk-OJFWQ6CU.mjs';import'../chunk-YWKPTYSG.mjs';import'../chunk-YZV4Z3EQ.mjs';import'../chunk-2PYLM3E7.mjs';import'../chunk-A4JCC3QQ.mjs';import'../chunk-DM6EDKWH.mjs';import'../chunk-5PJEKEEP.mjs';import'../chunk-4DOJSIEQ.mjs';import'../chunk-BCV4RAIX.mjs';import'../chunk-LFSU6LR3.mjs';function r(n,t,o){let e=t,f=a$4(t),l=o(n,b$1(t,()=>e));return {update(c){e=c;let d=a$4(c);d!==f&&(f=d,l.destroy(),l=o(n,b$1(c,()=>e)));},destroy(){l.destroy();}}}function D(n,t={}){return r(n,t,b)}function I(n={}){let t=null;function o(e){return t=b(e,n),{destroy(){t?.destroy(),t=null;}}}return {action:o,getInstance:()=>t}}function A(n,t){return r(n,t,a)}function H(n){let t=null;function o(e){return t=a(e,n),{destroy(){t?.destroy(),t=null;}}}return {action:o,getInstance:()=>t}}function L(n,t){return r(n,t,a$1)}function M(n){let t=null;function o(e){return t=a$1(e,n),{destroy(){t?.destroy(),t=null;}}}return {action:o,getInstance:()=>t}}function V(n,t={}){return r(n,t,a$3)}function g(n={}){let t=null;function o(e){return t=a$3(e,n),{destroy(){t?.destroy(),t=null;}}}return {action:o,getInstance:()=>t}}function C(n,t={}){return r(n,t,a$2)}function v(n={}){let t=null;function o(e){return t=a$2(e,n),{destroy(){t?.destroy(),t=null;}}}return {action:o,getInstance:()=>t}}export{H as createScrollAnimate,M as createScrollCounter,I as createScrollDraw,v as createScrollText,g as createScrollVideo,A as scrollAnimate,L as scrollCounterAction,D as scrollDraw,C as scrollTextAction,V as scrollVideoAction};
|
package/dist/text/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function ce({bounces:e=3,decay:n=.5}={}){let t=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,n)),i=Math.sqrt(r),o=0,s=[];for(let u=0;u<t;u++){let c=Math.pow(i,u);s.push(c),o+=c;}let d=[0],m=0;for(let u=0;u<t;u++)m+=s[u]/o,d.push(m);return u=>{if(u<=0)return 0;if(u>=1)return 1;for(let c=0;c<t;c++)if(u<=d[c+1]){let g=(u-d[c])/(d[c+1]-d[c]);if(c===0)return g*(2-g);let v=1-Math.pow(r,c);return v+(1-v)*(2*g-1)*(2*g-1)}return 1}}function de({amplitude:e=1,period:n=.4}={}){let t=Math.max(1,e),r=Math.max(.1,n),i=t<=1?r/4:r/(2*Math.PI)*Math.asin(1/t);return o=>o<=0?0:o>=1?1:t*Math.pow(2,-10*o)*Math.sin((o-i)*(2*Math.PI)/r)+1}var k={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:ce(),elastic:de()};function V(e,n,t){return Math.min(t,Math.max(n,e))}function D(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[t="top",r="bottom"]=n.split(/\s+/).filter(Boolean);return {element:t,viewport:r}}function W(e,n,t,r){switch(r){case "top":return e+t;case "center":return e+t+n/2;case "bottom":return e+t+n;default:return e+t}}function $(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function N(e,n,t,r){return t===n?0:V((e-n)/(t-n)*r,0,1)}function q(e,n,t,r,i){let o=W(e.top,e.height,n,r.element)-$(r.viewport,t),s=W(e.top,e.height,n,i.element)-$(i.viewport,t);return {tStart:o,tEnd:s}}var B=Symbol.for("svg-scroll-draw.registry");function G(){let e=globalThis;return e[B]||(e[B]=new Map)}function j(e,n){G().set(e,n);}function K(e){G().delete(e);}var x,C=new Set,R=new WeakMap,M=new Map,U=e=>{let n=e.getBoundingClientRect();return n.width+" "+n.height};function le(e){let n=new Set;for(let t of e)for(;t&&t!==document.body;t=t.parentElement)for(let r=t;r;r=r.previousElementSibling)n.add(r);return n}function X(e,n){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let t=()=>n();x??(x=new ResizeObserver(i=>{let o=false;for(let{target:s}of i)R.get(s)!==U(s)&&(o=true),R.set(s,"");o&&C.forEach(s=>s());})),C.add(t);let r=le(e);return [document.body,document.documentElement].forEach(i=>i&&r.add(i)),r.forEach(i=>{R.has(i)||R.set(i,U(i)),M.set(i,(M.get(i)??0)+1),x.observe(i);}),()=>{C.delete(t)&&(r.forEach(i=>{let o=(M.get(i)??1)-1;if(o)return void M.set(i,o);M.delete(i),x?.unobserve(i);}),C.size||(x?.disconnect(),x=void 0));}}var me=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function Y(e,...n){me&&console.warn(`[svg-scroll-draw] ${e}`,...n);}function J(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let n=window.matchMedia("(prefers-reduced-motion: reduce)"),t=i=>e(!!i.matches);if(typeof n.addEventListener=="function")return n.addEventListener("change",t),()=>n.removeEventListener("change",t);let r=n;return r.addListener?.(t),()=>r.removeListener?.(t)}function Z(e,n){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n(e,true);let t=n(e,false),r=J(o=>{if(!o)return;r();let s=(t.getProgress?.()??0)>=1;t.destroy(),t=n(s?{...e,onComplete:void 0}:e,true);}),i={};for(let o of Object.keys(t))i[o]=(...s)=>t[o]?.(...s);return i.destroy=()=>{r(),t.destroy();},i}function ee(e,n){let t=document.createElement("span");t.textContent=n,t.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;user-select:none",e.appendChild(t);}function re(e){let n=e.textContent??"";return e.textContent="",n.split(/(\s+)/).filter(Boolean).map(t=>{let r=document.createElement("span");return r.setAttribute("aria-hidden","true"),/^\s+$/.test(t)?(r.textContent=t,r.style.whiteSpace="pre"):(r.textContent=t,r.style.display="inline-block"),e.appendChild(r),/^\s+$/.test(t)?null:r}).filter(t=>t!==null)}function pe(e){let n=e.textContent??"";return e.textContent="",n.split("").map(t=>{let r=document.createElement("span");return r.setAttribute("aria-hidden","true"),r.textContent=t,t===" "?r.style.whiteSpace="pre":r.style.display="inline-block",e.appendChild(r),t===" "?null:r}).filter(t=>t!==null)}function te(e){let n=re(e),t=new Map;for(let o of n){let s=o.offsetTop;t.has(s)||t.set(s,[]),t.get(s).push(o);}let r=[],i=Array.from(t.keys()).sort((o,s)=>o-s);for(let o of i){let s=t.get(o),d=document.createElement("span");d.setAttribute("aria-hidden","true"),d.style.display="inline-block",s.forEach((m,u)=>{let c=m.nextElementSibling;d.appendChild(m),u<s.length-1&&c&&c.style.whiteSpace==="pre"&&d.appendChild(c);}),r.push(d);}return e.textContent="",r.forEach((o,s)=>{e.appendChild(o),s<r.length-1&&e.appendChild(document.createTextNode(" "));}),r}function fe(e,n,t,r){if(t<=1||r===0)return e;let i=(t-1)*r,o=n*r,s=o+(1-i);return s<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(s-o)))}function ge(e,n){let t=[];if(n?.y!==void 0&&t.push(`translateY(${n.y*(1-e)}px)`),n?.x!==void 0&&t.push(`translateX(${n.x*(1-e)}px)`),n?.rotate!==void 0&&t.push(`rotate(${n.rotate*(1-e)}deg)`),n?.scale!==void 0){let r=n.scale+(1-n.scale)*e;t.push(`scale(${r})`);}return t.join(" ")||""}var ne={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Pe(e,n={}){if(typeof window>"u")return ne;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return Y("scrollText: element not found:",e),ne;let r=t;return Z(n,(i,o)=>be(r,i,o))}function be(e,n,t){let{split:r="words",stagger:i=.04,easing:o="ease-out",from:s={opacity:0,y:24},trigger:d={},once:m=true,onComplete:u}=n,c=typeof o=="function"?o:k[o]??k["ease-out"],g=D(d.start??"top 85%"),v=D(d.end??"top 40%"),_=e.innerHTML,H=e.textContent??"",b;r==="chars"?b=pe(e):r==="lines"?b=te(e):b=re(e),ee(e,H);let oe=b.length;function ie(a,l){s?.opacity!==void 0&&(a.style.opacity=String(s.opacity+(1-s.opacity)*l));let L=ge(l,s);L&&(a.style.transform=L);}function h(a){e.style.setProperty("--scroll-draw-progress",String(a)),b.forEach((l,L)=>{let ue=c(fe(a,L,oe,i));ie(l,ue);});}if(t)return h(1),u?.(),{destroy(){e.innerHTML=_;},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};h(0);let A=0,I=0,p=0,T=false,f=false,w=-1,y=0,S=false,z=()=>window.scrollY,se=()=>window.innerHeight;function F(){let a=e.getBoundingClientRect(),l=q({top:a.top,height:a.height},z(),se(),g,v);A=l.tStart,I=l.tEnd;}function O(){if(!T||f)return;let a=N(z(),A,I,1);m&&(w=Math.max(w,a),a=w),y=a,h(a),a>=1&&!S?(S=true,u?.()):a<1&&!m&&(S=false),p=requestAnimationFrame(O);}F();let Q=new IntersectionObserver(a=>{a.forEach(l=>{T=l.isIntersecting,T&&!f?p=requestAnimationFrame(O):cancelAnimationFrame(p);});}),P;function E(){clearTimeout(P),P=setTimeout(()=>{if(r==="lines"){let a=y;e.innerHTML=_,b=te(e),ee(e,H),h(a);}F();},150);}window.addEventListener("resize",E),window.addEventListener("orientationchange",E);let ae=X([e],E);return Q.observe(e),j(e,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:A,tEnd:I})}),{destroy(){cancelAnimationFrame(p),Q.disconnect(),window.removeEventListener("resize",E),window.removeEventListener("orientationchange",E),ae(),clearTimeout(P),e.innerHTML=_,K(e);},replay(){w=-1,S=false,y=0,f=false,h(0);},pause(){f=true,cancelAnimationFrame(p);},resume(){f&&(f=false,T&&(p=requestAnimationFrame(O)));},seek(a){let l=Math.min(1,Math.max(0,a));y=l,w=l,f=true,cancelAnimationFrame(p),h(l);},getProgress(){return y}}}exports.scrollText=Pe;
|
package/dist/text/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as scrollText}from'../chunk-
|
|
1
|
+
export{a as scrollText}from'../chunk-DY5JCXVR.mjs';import'../chunk-2PYLM3E7.mjs';import'../chunk-A4JCC3QQ.mjs';import'../chunk-DM6EDKWH.mjs';import'../chunk-5PJEKEEP.mjs';import'../chunk-4DOJSIEQ.mjs';import'../chunk-BCV4RAIX.mjs';import'../chunk-LFSU6LR3.mjs';
|
package/dist/timeline/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$
|
|
1
|
+
import {a as a$1}from'../chunk-AJ22VSHC.mjs';import {a as a$3}from'../chunk-YZV4Z3EQ.mjs';import {a,d as d$1,c,b as b$2}from'../chunk-A4JCC3QQ.mjs';import {d}from'../chunk-DM6EDKWH.mjs';import {a as a$2}from'../chunk-5PJEKEEP.mjs';import'../chunk-4DOJSIEQ.mjs';import {a as a$4,b as b$1}from'../chunk-BCV4RAIX.mjs';import {b}from'../chunk-LFSU6LR3.mjs';var le=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function Ae(u,ce){let V={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return V;let W=typeof u=="string"?document.querySelector(u):u;if(!W)return b("timeline: Container not found:",u),V;let s=W,{trigger:_={},speed:pe=1,once:$=false,axis:w="y",tracks:B,onComplete:de,repeat:x,repeatDelay:I=0,loop:L=false,loopDuration:fe=1500,debug:ue=false,label:me,respectReducedMotion:U=true}=ce,ge=a(_.start??"top bottom"),ye=a(_.end??"bottom top"),v=x==="infinite"?1/0:x??0,r,k=L===true?1/0:typeof L=="number"?L:0,a$5=false,A=0,m=k,R=U&&a$1(),be=a$2(e=>{R=U&&e,R&&(a$5=false,clearTimeout(r),r=void 0);}),F=()=>k>0&&!R,z=new Map,C=B.map(e=>{let n=typeof e.easing=="function"?e.easing:d[e.easing??"linear"]??d.linear,i=Array.from(s.querySelectorAll(e.selector)),o=i.map(t=>a$3(t));return i.forEach((t,l)=>{z.has(t)||z.set(t,t.getAttribute("style")??""),t.style.strokeDasharray=`${o[l]}`,t.style.strokeDashoffset=`${o[l]}`,e.fade&&(t.style.opacity="0");}),{...e,elements:i,lengths:o,easeFn:n}});function he(){for(let[e,n]of z)n?e.setAttribute("style",n):e.removeAttribute("style");}let P=0,H=0,T=false,p=false,d$2=0,y=false,b$3=-1,f=0,c$1=null;ue&&(c$1=document.createElement("div"),Object.assign(c$1.style,{position:"fixed",bottom:"16px",left:"16px",zIndex:"9999",background:"rgba(0,0,0,0.88)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"10px",padding:"10px 14px",fontFamily:"monospace",fontSize:"11px",color:"#fff",minWidth:"240px",pointerEvents:"none",lineHeight:"1.4"}),document.body.appendChild(c$1));function we(e){if(!c$1)return;let n=me??(typeof u=="string"?u:"timeline"),i=B.map(({selector:o,from:t,to:l},q)=>{let g=le[q%le.length],D=l>t?Math.min(1,Math.max(0,(e-t)/(l-t))):0,S=Math.round(D*100);return `<div style="margin:4px 0">
|
|
2
2
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:2px">
|
|
3
3
|
<span style="color:${g};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${o}</span>
|
|
4
4
|
<span style="color:#666;margin-left:8px">${S}%</span>
|
package/dist/video/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function me({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),o=Math.sqrt(n),
|
|
1
|
+
'use strict';function me({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),o=Math.sqrt(n),s=0,c=[];for(let a=0;a<r;a++){let u=Math.pow(o,a);c.push(u),s+=u;}let d=[0],L=0;for(let a=0;a<r;a++)L+=c[a]/s,d.push(L);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let u=0;u<r;u++)if(a<=d[u+1]){let g=(a-d[u])/(d[u+1]-d[u]);if(u===0)return g*(2-g);let S=1-Math.pow(n,u);return S+(1-S)*(2*g-1)*(2*g-1)}return 1}}function le({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),o=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return s=>s<=0?0:s>=1?1:r*Math.pow(2,-10*s)*Math.sin((s-o)*(2*Math.PI)/n)+1}var C={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:me(),elastic:le()};function X(e,t,r){return Math.min(r,Math.max(t,e))}function Q(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function j(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function J(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function U(e,t,r,n){return r===t?0:X((e-t)/(r-t)*n,0,1)}function Y(e,t,r,n,o){let s=j(e.top,e.height,t,n.element)-J(n.viewport,r),c=j(e.top,e.height,t,o.element)-J(o.viewport,r);return {tStart:s,tEnd:c}}var Z=Symbol.for("svg-scroll-draw.registry");function H(){let e=globalThis;return e[Z]||(e[Z]=new Map)}function ee(e,t){H().set(e,t);}function te(e){H().delete(e);}var M,P=new Set,N=new WeakMap,x=new Map,ne=e=>{let t=e.getBoundingClientRect();return t.width+" "+t.height};function fe(e){let t=new Set;for(let r of e)for(;r&&r!==document.body;r=r.parentElement)for(let n=r;n;n=n.previousElementSibling)t.add(n);return t}function re(e,t){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let r=()=>t();M??(M=new ResizeObserver(o=>{let s=false;for(let{target:c}of o)N.get(c)!==ne(c)&&(s=true),N.set(c,"");s&&P.forEach(c=>c());})),P.add(r);let n=fe(e);return [document.body,document.documentElement].forEach(o=>o&&n.add(o)),n.forEach(o=>{N.has(o)||N.set(o,ne(o)),x.set(o,(x.get(o)??0)+1),M.observe(o);}),()=>{P.delete(r)&&(n.forEach(o=>{let s=(x.get(o)??1)-1;if(s)return void x.set(o,s);x.delete(o),M?.unobserve(o);}),P.size||(M?.disconnect(),M=void 0));}}var pe=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function q(e,...t){pe&&console.warn(`[svg-scroll-draw] ${e}`,...t);}function oe(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),r=o=>e(!!o.matches);if(typeof t.addEventListener=="function")return t.addEventListener("change",r),()=>t.removeEventListener("change",r);let n=t;return n.addListener?.(r),()=>n.removeListener?.(r)}var ie={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ae(e,t={}){if(typeof window>"u")return ie;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return q("scrollVideo: <video> element not found:",e),ie;let n=r,{trigger:o={},easing:s="linear",once:c=false,axis:d="y",preload:L="auto",triggerElement:a,onReady:u,onComplete:g,onProgress:S}=t,W=a??n,_=window.matchMedia("(prefers-reduced-motion: reduce)").matches,se=typeof s=="function"?s:C[s]??C.linear,ae=Q(o.start??"top top"),ue=Q(o.end??"bottom top");n.pause(),n.hasAttribute("preload")||(n.preload=L);let k=t.from??0,O=t.to,R=0,T=0,m=0,b=false,f=false,w=-1,h=0,A=false,p=false,G=()=>d==="x"?window.scrollX:window.scrollY,ce=()=>d==="x"?window.innerWidth:window.innerHeight;function z(){let i=W.getBoundingClientRect(),l=d==="x"?i.left:i.top,E=d==="x"?i.width:i.height,K=Y({top:l,height:E},G(),ce(),ae,ue);R=K.tStart,T=K.tEnd,p&&T===R&&q("scrollVideo: zero-length trigger window, so it never scrubs. In a sticky stage, set triggerElement.",n);}let I=NaN;function v(i){if(!p)return;let l=O??n.duration??0,E=k+(l-k)*i;E!==I&&(I=E,n.currentTime=E),n.style.setProperty("--scroll-draw-progress",String(i)),S?.(i);}function V(){if(!b||f||!p||_)return;let i=se(U(G(),R,T,1));c&&(w=Math.max(w,i),i=w),h=i,v(i),i>=1&&!A?(A=true,g?.()):i<1&&!c&&(A=false),m=requestAnimationFrame(V);}function D(){if(p=true,O===void 0&&(O=n.duration),_){v(1),u?.();return}z(),u?.(),b&&!f&&(m=requestAnimationFrame(V));}n.readyState>=1?D():n.addEventListener("loadedmetadata",D,{once:true}),p||z();let B=_?()=>{}:oe(i=>{i&&(B(),_=true,cancelAnimationFrame(m),v(1));}),$=new IntersectionObserver(i=>{i.forEach(l=>{b=l.isIntersecting,b&&!f&&p?m=requestAnimationFrame(V):cancelAnimationFrame(m);});}),F;function y(){clearTimeout(F),F=setTimeout(z,150);}window.addEventListener("resize",y),window.addEventListener("orientationchange",y);let de=re([W],y);return $.observe(n),ee(n,{type:"video",getProgress:()=>h,getTrigger:()=>({tStart:R,tEnd:T})}),{destroy(){cancelAnimationFrame(m),$.disconnect(),n.removeEventListener("loadedmetadata",D),window.removeEventListener("resize",y),window.removeEventListener("orientationchange",y),de(),B(),clearTimeout(F),te(n);},replay(){w=-1,A=false,h=0,f=false,I=NaN,v(0);},pause(){f=true,cancelAnimationFrame(m);},resume(){f&&(f=false,b&&p&&(m=requestAnimationFrame(V)));},seek(i){let l=Math.min(1,Math.max(0,i));h=l,w=l,f=true,cancelAnimationFrame(m),I=NaN,v(l);},getProgress(){return h}}}exports.scrollVideo=Ae;
|
package/dist/video/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as scrollVideo}from'../chunk-
|
|
1
|
+
export{a as scrollVideo}from'../chunk-KV3WCPQ5.mjs';import'../chunk-A4JCC3QQ.mjs';import'../chunk-DM6EDKWH.mjs';import'../chunk-5PJEKEEP.mjs';import'../chunk-4DOJSIEQ.mjs';import'../chunk-BCV4RAIX.mjs';import'../chunk-LFSU6LR3.mjs';
|
package/dist/vivus/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function g(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}var w=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function p(r,...t){w&&console.warn(`[svg-scroll-draw] ${r}`,...t);}var E=["delayed","sync","async","nsync","oneByOne","scenario","scenario-sync"],V=["inViewport","manual","autostart"];function u(r,t){let e=parseInt(r,10);return e>=0?e:t}function $(r){if(typeof window>"u")return false;let t=window,e=n=>typeof t[n]=="function"&&r instanceof t[n];return e("SVGSVGElement")||e("SVGGElement")||r?.constructor===t.SVGElement}var y=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],A=["line","ellipse","circle","polygon","polyline","rect"],S="http://www.w3.org/2000/svg";function v(r){let t=r.points.trim().split(" ");if(r.points.indexOf(",")===-1){let n=[];for(let s=0;s<t.length;s+=2)n.push(`${t[s]},${t[s+1]}`);t=n;}let e=`M${t[0]}`;for(let n=1;n<t.length;n++)t[n].indexOf(",")!==-1&&(e+=`L${t[n]}`);return e}function b(r,t,e,n){let s=parseFloat(e)||0,a=parseFloat(n)||0,i=parseFloat(r)||0,o=parseFloat(t)||0,l=i-s,h=i+s;return `M${l},${o}A${s},${a} 0,1,1 ${h},${o}A${s},${a} 0,1,1 ${l},${o}`}var x={line:r=>`M${r.x1||0},${r.y1||0}L${r.x2||0},${r.y2||0}`,rect(r){let t=parseFloat(r.x)||0,e=parseFloat(r.y)||0,n=parseFloat(r.width)||0,s=parseFloat(r.height)||0;if(r.rx||r.ry){let a=parseInt(r.rx,10)||-1,i=parseInt(r.ry,10)||-1;a=Math.min(Math.max(a<0?i:a,0),n/2),i=Math.min(Math.max(i<0?a:i,0),s/2);let o=`A ${a},${i},0,0,1,`;return `M ${t+a},${e} L ${t+n-a},${e} ${o}${t+n},${e+i} L ${t+n},${e+s-i} ${o}${t+n-a},${e+s} L ${t+a},${e+s} ${o}${t},${e+s-i} L ${t},${e+i} ${o}${t+a},${e}`}return `M${t} ${e} L${t+n} ${e} L${t+n} ${e+s} L${t} ${e+s} Z`},polyline:v,polygon:r=>`${v(r)}Z`,ellipse:r=>b(r.cx,r.cy,r.rx,r.ry),circle:r=>b(r.cx,r.cy,r.r,r.r)};function L(r){for(let t of Array.from(r.querySelectorAll(A.join(",")))){let e={};for(let{name:a,value:i}of Array.from(t.attributes)){if(y.indexOf(a)!==-1&&i.indexOf("%")!==-1)throw new Error("Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into 'path' tags. Please use 'viewBox'.");e[a]=i;}let n=x[t.tagName.toLowerCase()](e),s=document.createElementNS(S,"path");for(let{name:a,value:i}of Array.from(t.attributes))y.indexOf(a)===-1&&s.setAttribute(a,i);s.setAttribute("d",n),t.parentNode?.replaceChild(s,t);}}var c=class c{constructor(t,e,n){this.isReady=false;this.type="delayed";this.start="inViewport";this.duration=120;this.delay=null;this.dashGap=1;this.forceRender=false;this.reverseStack=false;this.selfDestroy=false;this.ignoreInvisible=false;this.animTimingFunction=c.LINEAR;this.pathTimingFunction=c.LINEAR;this.callback=()=>{};this.map=[];this.frameLength=0;this.currentFrame=0;this.delayUnit=0;this.speed=1;this.handle=null;this.instanceCallback=null;this.mustRecalcScale=null;this.viewportListener=null;this.setElement(t,e),this.setOptions(e),this.setCallback(n),this.isReady&&this.init();}setElement(t,e){if(t===void 0)throw new Error('Vivus [constructor]: "element" parameter is required');let n=t;if(typeof n=="string"){let s=document.getElementById(n);if(!s)throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID');n=s;}if(this.parentEl=n,e&&e.file){let s=new XMLHttpRequest;s.addEventListener("load",()=>{let a=document.createElement("div");a.innerHTML=s.responseText;let i=a.querySelector("svg");if(!i)throw new Error(`Vivus [load]: Cannot find the SVG in the loaded file : ${e.file}`);this.el=i,i.setAttribute("width","100%"),i.setAttribute("height","100%"),this.parentEl.appendChild(i),this.isReady=true,this.init();}),s.open("GET",e.file),s.send();return}if($(n)){this.el=n,this.isReady=true;return}if(n instanceof HTMLObjectElement){let s=n,a=i=>{if(this.isReady)return;let o=s.contentDocument&&s.contentDocument.querySelector("svg");if(!o&&i)throw new Error("Vivus [constructor]: object loaded does not contain any SVG");o&&(s.getAttribute("built-by-vivus")&&(this.parentEl.insertBefore(o,s),this.parentEl.removeChild(s),o.setAttribute("width","100%"),o.setAttribute("height","100%")),this.el=o,this.isReady=true,this.init());};a(),this.isReady||s.addEventListener("load",a);return}throw new Error('Vivus [constructor]: "element" parameter is not valid (or miss the "file" attribute)')}setOptions(t){if(t!==void 0&&(t===null||t.constructor!==Object))throw new Error('Vivus [constructor]: "options" parameter must be an object');let e=t||{};if(e.type&&E.indexOf(e.type)===-1)throw new Error(`Vivus [constructor]: ${e.type} is not an existing animation \`type\``);if(e.start&&V.indexOf(e.start)===-1)throw new Error(`Vivus [constructor]: ${e.start} is not an existing \`start\` option`);this.type=e.type||"delayed",this.start=e.start||"inViewport";let n=navigator.userAgent,s=n.indexOf("MSIE")!==-1||n.indexOf("Trident/")!==-1||n.indexOf("Edge/")!==-1;if(this.duration=u(e.duration,120),this.delay=u(e.delay,null),this.dashGap=u(e.dashGap,1),this.forceRender=Object.prototype.hasOwnProperty.call(e,"forceRender")?!!e.forceRender:s,this.reverseStack=!!e.reverseStack,this.selfDestroy=!!e.selfDestroy,this.onReady=e.onReady,this.map=[],this.ignoreInvisible=Object.prototype.hasOwnProperty.call(e,"ignoreInvisible")?!!e.ignoreInvisible:false,this.animTimingFunction=e.animTimingFunction||c.LINEAR,this.pathTimingFunction=e.pathTimingFunction||c.LINEAR,this.delay!==null&&this.delay>=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")}setCallback(t){if(t&&typeof t!="function")throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||(()=>{});}mapping(){let t=0,e=0,n=0,s=false,a=Array.from(this.el.querySelectorAll("path"));a.forEach((i,o)=>{if(this.isInvisible(i))return;let l={el:i,length:0,startAt:0,duration:0,isResizeSensitive:false},h=1;if(i.getAttribute("vector-effect")==="non-scaling-stroke"){let d=i.getBoundingClientRect(),f=i.getBBox();h=Math.max(d.width/f.width,d.height/f.height),l.isResizeSensitive=true,s=true;}if(l.length=Math.ceil(i.getTotalLength()*h),isNaN(l.length)){p("vivus: cannot retrieve a path element length",i);return}this.map.push(l),i.style.strokeDasharray=`${l.length} ${l.length+this.dashGap*2}`,i.style.strokeDashoffset=String(l.length+this.dashGap),l.length+=this.dashGap,e+=l.length,this.renderPath(o);}),s&&p("vivus: this SVG contains non-scaling-strokes. Call instance.recalc() when the SVG is resized."),e=e===0?1:e,this.delay=this.delay===null?this.duration/3:this.delay,this.delayUnit=this.delay/(a.length>1?a.length-1:1),this.reverseStack&&this.map.reverse(),this.map.forEach((i,o)=>{let l=()=>{let h={};for(let{name:d,value:f}of Array.from(i.el.attributes))h[d]=f;return h};switch(this.type){case "delayed":i.startAt=this.delayUnit*o,i.duration=this.duration-this.delay;break;case "oneByOne":i.startAt=n/e*this.duration,i.duration=i.length/e*this.duration;break;case "sync":case "async":case "nsync":i.startAt=0,i.duration=this.duration;break;case "scenario-sync":{let h=l();i.startAt=t+(u(h["data-delay"],this.delayUnit)||0),i.duration=u(h["data-duration"],this.duration),t=h["data-async"]!==void 0?i.startAt:i.startAt+i.duration,this.frameLength=Math.max(this.frameLength,i.startAt+i.duration);break}case "scenario":{let h=l();i.startAt=u(h["data-start"],this.delayUnit)||0,i.duration=u(h["data-duration"],this.duration),this.frameLength=Math.max(this.frameLength,i.startAt+i.duration);break}}n+=i.length,this.frameLength=this.frameLength||this.duration;});}recalc(){this.mustRecalcScale||(this.mustRecalcScale=requestAnimationFrame(()=>this.performLineRecalc()));}performLineRecalc(){for(let t of this.map){if(!t.isResizeSensitive)continue;let e=t.el.getBoundingClientRect(),n=t.el.getBBox(),s=Math.max(e.width/n.width,e.height/n.height);t.length=Math.ceil(t.el.getTotalLength()*s),t.el.style.strokeDasharray=`${t.length} ${t.length+this.dashGap*2}`;}this.trace(),this.mustRecalcScale=null;}draw(){if(this.currentFrame+=this.speed,this.currentFrame<=0)this.stop(),this.reset();else if(this.currentFrame>=this.frameLength)this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy();else {this.trace(),this.handle=requestAnimationFrame(()=>this.draw());return}this.finished();}finished(){if(this.callback(this),this.instanceCallback){let t=this.instanceCallback;this.instanceCallback=null,t(this);}}trace(){let t=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength;this.map.forEach((e,n)=>{let s=this.pathTimingFunction(Math.max(0,Math.min(1,(t-e.startAt)/e.duration)));e.progress!==s&&(e.progress=s,e.el.style.strokeDashoffset=String(Math.floor(e.length*(1-s))),this.renderPath(n));});}renderPath(t){let e=this.forceRender&&this.map&&this.map[t];if(!e)return;let n=e.el.cloneNode(true);e.el.parentNode?.replaceChild(n,e.el),e.el=n;}init(){this.frameLength=0,this.currentFrame=0,this.map=[],L(this.el),this.mapping(),this.starter(),this.onReady&&this.onReady(this);}starter(){if(this.start==="manual")return;if(this.start==="autostart"){this.play();return}let t=()=>{this.isInViewport(this.parentEl,1)&&(this.play(),window.removeEventListener("scroll",t),this.viewportListener=null);};this.viewportListener=t,window.addEventListener("scroll",t),t();}getStatus(){return this.currentFrame===0?"start":this.currentFrame===this.frameLength?"end":"progress"}reset(){return this.setFrameProgress(0)}finish(){return this.setFrameProgress(1)}setFrameProgress(t){let e=Math.min(1,Math.max(0,t));return this.currentFrame=Math.round(this.frameLength*e),this.trace(),this}play(t,e){this.instanceCallback=null;let n=t;if(n&&typeof n=="function")this.instanceCallback=n,n=void 0;else if(n&&typeof n!="number")throw new Error("Vivus [play]: invalid speed");return e&&typeof e=="function"&&!this.instanceCallback&&(this.instanceCallback=e),this.speed=n||1,g()?(this.stop(),this.currentFrame=this.speed<0?0:this.frameLength,this.trace(),this.speed>0&&this.selfDestroy&&this.destroy(),this.finished(),this):(this.handle||this.draw(),this)}stop(){return this.handle&&(cancelAnimationFrame(this.handle),this.handle=null),this}destroy(){this.stop(),this.viewportListener&&(window.removeEventListener("scroll",this.viewportListener),this.viewportListener=null),this.map.forEach((t,e)=>{t.el.style.strokeDashoffset="",t.el.style.strokeDasharray="",this.renderPath(e);});}isInvisible(t){let e=t.getAttribute("data-ignore");if(e!==null)return e!=="false";if(this.ignoreInvisible){let n=t.getBoundingClientRect();return !n.width&&!n.height}return false}isInViewport(t,e=0){let n=window.pageYOffset||document.documentElement.scrollTop,s=n+Math.max(document.documentElement.clientHeight,window.innerHeight),a=t.getBoundingClientRect(),i=n+a.top;return i+a.height*(e||0)<=s&&i+a.height>=n}};c.LINEAR=t=>t,c.EASE=t=>-Math.cos(t*Math.PI)/2+.5,c.EASE_OUT=t=>1-Math.pow(1-t,3),c.EASE_IN=t=>Math.pow(t,3),c.EASE_OUT_BOUNCE=t=>{let e=-Math.cos(t*(.5*Math.PI))+1,n=Math.pow(e,1.5),s=Math.pow(1-t,2),a=-Math.abs(Math.cos(n*(2.5*Math.PI)))+1;return 1-s+a*s};var m=c,O=m;
|
|
2
|
-
exports.Vivus=
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function g(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function y(r){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),e=s=>r(!!s.matches);if(typeof t.addEventListener=="function")return t.addEventListener("change",e),()=>t.removeEventListener("change",e);let i=t;return i.addListener?.(e),()=>i.removeListener?.(e)}var E=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function m(r,...t){E&&console.warn(`[svg-scroll-draw] ${r}`,...t);}var L=["delayed","sync","async","nsync","oneByOne","scenario","scenario-sync"],V=["inViewport","manual","autostart"];function u(r,t){let e=parseInt(r,10);return e>=0?e:t}function M(r){if(typeof window>"u")return false;let t=window,e=i=>typeof t[i]=="function"&&r instanceof t[i];return e("SVGSVGElement")||e("SVGGElement")||r?.constructor===t.SVGElement}var v=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],$=["line","ellipse","circle","polygon","polyline","rect"],R="http://www.w3.org/2000/svg";function w(r){let t=r.points.trim().split(" ");if(r.points.indexOf(",")===-1){let i=[];for(let s=0;s<t.length;s+=2)i.push(`${t[s]},${t[s+1]}`);t=i;}let e=`M${t[0]}`;for(let i=1;i<t.length;i++)t[i].indexOf(",")!==-1&&(e+=`L${t[i]}`);return e}function b(r,t,e,i){let s=parseFloat(e)||0,a=parseFloat(i)||0,n=parseFloat(r)||0,o=parseFloat(t)||0,h=n-s,l=n+s;return `M${h},${o}A${s},${a} 0,1,1 ${l},${o}A${s},${a} 0,1,1 ${h},${o}`}var x={line:r=>`M${r.x1||0},${r.y1||0}L${r.x2||0},${r.y2||0}`,rect(r){let t=parseFloat(r.x)||0,e=parseFloat(r.y)||0,i=parseFloat(r.width)||0,s=parseFloat(r.height)||0;if(r.rx||r.ry){let a=parseInt(r.rx,10)||-1,n=parseInt(r.ry,10)||-1;a=Math.min(Math.max(a<0?n:a,0),i/2),n=Math.min(Math.max(n<0?a:n,0),s/2);let o=`A ${a},${n},0,0,1,`;return `M ${t+a},${e} L ${t+i-a},${e} ${o}${t+i},${e+n} L ${t+i},${e+s-n} ${o}${t+i-a},${e+s} L ${t+a},${e+s} ${o}${t},${e+s-n} L ${t},${e+n} ${o}${t+a},${e}`}return `M${t} ${e} L${t+i} ${e} L${t+i} ${e+s} L${t} ${e+s} Z`},polyline:w,polygon:r=>`${w(r)}Z`,ellipse:r=>b(r.cx,r.cy,r.rx,r.ry),circle:r=>b(r.cx,r.cy,r.r,r.r)};function A(r){for(let t of Array.from(r.querySelectorAll($.join(",")))){let e={};for(let{name:a,value:n}of Array.from(t.attributes)){if(v.indexOf(a)!==-1&&n.indexOf("%")!==-1)throw new Error("Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into 'path' tags. Please use 'viewBox'.");e[a]=n;}let i=x[t.tagName.toLowerCase()](e),s=document.createElementNS(R,"path");for(let{name:a,value:n}of Array.from(t.attributes))v.indexOf(a)===-1&&s.setAttribute(a,n);s.setAttribute("d",i),t.parentNode?.replaceChild(s,t);}}var c=class c{constructor(t,e,i){this.isReady=false;this.type="delayed";this.start="inViewport";this.duration=120;this.delay=null;this.dashGap=1;this.forceRender=false;this.reverseStack=false;this.selfDestroy=false;this.ignoreInvisible=false;this.animTimingFunction=c.LINEAR;this.pathTimingFunction=c.LINEAR;this.callback=()=>{};this.map=[];this.frameLength=0;this.currentFrame=0;this.delayUnit=0;this.speed=1;this.handle=null;this.instanceCallback=null;this.mustRecalcScale=null;this.viewportListener=null;this.unwatchMotion=()=>{};this.setElement(t,e),this.setOptions(e),this.setCallback(i),this.isReady&&this.init(),this.unwatchMotion=y(s=>{s&&this.handle&&this.endNow();});}endNow(){this.stop(),this.currentFrame=this.speed<0?0:this.frameLength,this.trace(),this.speed>0&&this.selfDestroy&&this.destroy(),this.finished();}setElement(t,e){if(t===void 0)throw new Error('Vivus [constructor]: "element" parameter is required');let i=t;if(typeof i=="string"){let s=document.getElementById(i);if(!s)throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID');i=s;}if(this.parentEl=i,e&&e.file){let s=new XMLHttpRequest;s.addEventListener("load",()=>{let a=document.createElement("div");a.innerHTML=s.responseText;let n=a.querySelector("svg");if(!n)throw new Error(`Vivus [load]: Cannot find the SVG in the loaded file : ${e.file}`);this.el=n,n.setAttribute("width","100%"),n.setAttribute("height","100%"),this.parentEl.appendChild(n),this.isReady=true,this.init();}),s.open("GET",e.file),s.send();return}if(M(i)){this.el=i,this.isReady=true;return}if(i instanceof HTMLObjectElement){let s=i,a=n=>{if(this.isReady)return;let o=s.contentDocument&&s.contentDocument.querySelector("svg");if(!o&&n)throw new Error("Vivus [constructor]: object loaded does not contain any SVG");o&&(s.getAttribute("built-by-vivus")&&(this.parentEl.insertBefore(o,s),this.parentEl.removeChild(s),o.setAttribute("width","100%"),o.setAttribute("height","100%")),this.el=o,this.isReady=true,this.init());};a(),this.isReady||s.addEventListener("load",a);return}throw new Error('Vivus [constructor]: "element" parameter is not valid (or miss the "file" attribute)')}setOptions(t){if(t!==void 0&&(t===null||t.constructor!==Object))throw new Error('Vivus [constructor]: "options" parameter must be an object');let e=t||{};if(e.type&&L.indexOf(e.type)===-1)throw new Error(`Vivus [constructor]: ${e.type} is not an existing animation \`type\``);if(e.start&&V.indexOf(e.start)===-1)throw new Error(`Vivus [constructor]: ${e.start} is not an existing \`start\` option`);this.type=e.type||"delayed",this.start=e.start||"inViewport";let i=navigator.userAgent,s=i.indexOf("MSIE")!==-1||i.indexOf("Trident/")!==-1||i.indexOf("Edge/")!==-1;if(this.duration=u(e.duration,120),this.delay=u(e.delay,null),this.dashGap=u(e.dashGap,1),this.forceRender=Object.prototype.hasOwnProperty.call(e,"forceRender")?!!e.forceRender:s,this.reverseStack=!!e.reverseStack,this.selfDestroy=!!e.selfDestroy,this.onReady=e.onReady,this.map=[],this.ignoreInvisible=Object.prototype.hasOwnProperty.call(e,"ignoreInvisible")?!!e.ignoreInvisible:false,this.animTimingFunction=e.animTimingFunction||c.LINEAR,this.pathTimingFunction=e.pathTimingFunction||c.LINEAR,this.delay!==null&&this.delay>=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")}setCallback(t){if(t&&typeof t!="function")throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||(()=>{});}mapping(){let t=0,e=0,i=0,s=false,a=Array.from(this.el.querySelectorAll("path"));a.forEach((n,o)=>{if(this.isInvisible(n))return;let h={el:n,length:0,startAt:0,duration:0,isResizeSensitive:false},l=1;if(n.getAttribute("vector-effect")==="non-scaling-stroke"){let d=n.getBoundingClientRect(),f=n.getBBox();l=Math.max(d.width/f.width,d.height/f.height),h.isResizeSensitive=true,s=true;}if(h.length=Math.ceil(n.getTotalLength()*l),isNaN(h.length)){m("vivus: cannot retrieve a path element length",n);return}this.map.push(h),n.style.strokeDasharray=`${h.length} ${h.length+this.dashGap*2}`,n.style.strokeDashoffset=String(h.length+this.dashGap),h.length+=this.dashGap,e+=h.length,this.renderPath(o);}),s&&m("vivus: this SVG contains non-scaling-strokes. Call instance.recalc() when the SVG is resized."),e=e===0?1:e,this.delay=this.delay===null?this.duration/3:this.delay,this.delayUnit=this.delay/(a.length>1?a.length-1:1),this.reverseStack&&this.map.reverse(),this.map.forEach((n,o)=>{let h=()=>{let l={};for(let{name:d,value:f}of Array.from(n.el.attributes))l[d]=f;return l};switch(this.type){case "delayed":n.startAt=this.delayUnit*o,n.duration=this.duration-this.delay;break;case "oneByOne":n.startAt=i/e*this.duration,n.duration=n.length/e*this.duration;break;case "sync":case "async":case "nsync":n.startAt=0,n.duration=this.duration;break;case "scenario-sync":{let l=h();n.startAt=t+(u(l["data-delay"],this.delayUnit)||0),n.duration=u(l["data-duration"],this.duration),t=l["data-async"]!==void 0?n.startAt:n.startAt+n.duration,this.frameLength=Math.max(this.frameLength,n.startAt+n.duration);break}case "scenario":{let l=h();n.startAt=u(l["data-start"],this.delayUnit)||0,n.duration=u(l["data-duration"],this.duration),this.frameLength=Math.max(this.frameLength,n.startAt+n.duration);break}}i+=n.length,this.frameLength=this.frameLength||this.duration;});}recalc(){this.mustRecalcScale||(this.mustRecalcScale=requestAnimationFrame(()=>this.performLineRecalc()));}performLineRecalc(){for(let t of this.map){if(!t.isResizeSensitive)continue;let e=t.el.getBoundingClientRect(),i=t.el.getBBox(),s=Math.max(e.width/i.width,e.height/i.height);t.length=Math.ceil(t.el.getTotalLength()*s),t.el.style.strokeDasharray=`${t.length} ${t.length+this.dashGap*2}`;}this.trace(),this.mustRecalcScale=null;}draw(){if(this.currentFrame+=this.speed,this.currentFrame<=0)this.stop(),this.reset();else if(this.currentFrame>=this.frameLength)this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy();else {this.trace(),this.handle=requestAnimationFrame(()=>this.draw());return}this.finished();}finished(){if(this.callback(this),this.instanceCallback){let t=this.instanceCallback;this.instanceCallback=null,t(this);}}trace(){let t=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength;this.map.forEach((e,i)=>{let s=this.pathTimingFunction(Math.max(0,Math.min(1,(t-e.startAt)/e.duration)));e.progress!==s&&(e.progress=s,e.el.style.strokeDashoffset=String(Math.floor(e.length*(1-s))),this.renderPath(i));});}renderPath(t){let e=this.forceRender&&this.map&&this.map[t];if(!e)return;let i=e.el.cloneNode(true);e.el.parentNode?.replaceChild(i,e.el),e.el=i;}init(){this.frameLength=0,this.currentFrame=0,this.map=[],A(this.el),this.mapping(),this.starter(),this.onReady&&this.onReady(this);}starter(){if(this.start==="manual")return;if(this.start==="autostart"){this.play();return}let t=()=>{this.isInViewport(this.parentEl,1)&&(this.play(),window.removeEventListener("scroll",t),this.viewportListener=null);};this.viewportListener=t,window.addEventListener("scroll",t),t();}getStatus(){return this.currentFrame===0?"start":this.currentFrame===this.frameLength?"end":"progress"}reset(){return this.setFrameProgress(0)}finish(){return this.setFrameProgress(1)}setFrameProgress(t){let e=Math.min(1,Math.max(0,t));return this.currentFrame=Math.round(this.frameLength*e),this.trace(),this}play(t,e){this.instanceCallback=null;let i=t;if(i&&typeof i=="function")this.instanceCallback=i,i=void 0;else if(i&&typeof i!="number")throw new Error("Vivus [play]: invalid speed");return e&&typeof e=="function"&&!this.instanceCallback&&(this.instanceCallback=e),this.speed=i||1,g()?(this.endNow(),this):(this.handle||this.draw(),this)}stop(){return this.handle&&(cancelAnimationFrame(this.handle),this.handle=null),this}destroy(){this.stop(),this.unwatchMotion(),this.viewportListener&&(window.removeEventListener("scroll",this.viewportListener),this.viewportListener=null),this.map.forEach((t,e)=>{t.el.style.strokeDashoffset="",t.el.style.strokeDasharray="",this.renderPath(e);});}isInvisible(t){let e=t.getAttribute("data-ignore");if(e!==null)return e!=="false";if(this.ignoreInvisible){let i=t.getBoundingClientRect();return !i.width&&!i.height}return false}isInViewport(t,e=0){let i=window.pageYOffset||document.documentElement.scrollTop,s=i+Math.max(document.documentElement.clientHeight,window.innerHeight),a=t.getBoundingClientRect(),n=i+a.top;return n+a.height*(e||0)<=s&&n+a.height>=i}};c.LINEAR=t=>t,c.EASE=t=>-Math.cos(t*Math.PI)/2+.5,c.EASE_OUT=t=>1-Math.pow(1-t,3),c.EASE_IN=t=>Math.pow(t,3),c.EASE_OUT_BOUNCE=t=>{let e=-Math.cos(t*(.5*Math.PI))+1,i=Math.pow(e,1.5),s=Math.pow(1-t,2),a=-Math.abs(Math.cos(i*(2.5*Math.PI)))+1;return 1-s+a*s};var p=c,I=p;
|
|
2
|
+
exports.Vivus=p;exports.default=I;
|
package/dist/vivus/index.d.mts
CHANGED
|
@@ -61,7 +61,10 @@ declare class Vivus {
|
|
|
61
61
|
private instanceCallback;
|
|
62
62
|
private mustRecalcScale;
|
|
63
63
|
private viewportListener;
|
|
64
|
+
private unwatchMotion;
|
|
64
65
|
constructor(element: string | Element, options?: VivusOptions, callback?: VivusCallback);
|
|
66
|
+
/** The exact end (or start, playing backwards), the callbacks, as under reduced motion. */
|
|
67
|
+
private endNow;
|
|
65
68
|
private setElement;
|
|
66
69
|
private setOptions;
|
|
67
70
|
private setCallback;
|
package/dist/vivus/index.d.ts
CHANGED
|
@@ -61,7 +61,10 @@ declare class Vivus {
|
|
|
61
61
|
private instanceCallback;
|
|
62
62
|
private mustRecalcScale;
|
|
63
63
|
private viewportListener;
|
|
64
|
+
private unwatchMotion;
|
|
64
65
|
constructor(element: string | Element, options?: VivusOptions, callback?: VivusCallback);
|
|
66
|
+
/** The exact end (or start, playing backwards), the callbacks, as under reduced motion. */
|
|
67
|
+
private endNow;
|
|
65
68
|
private setElement;
|
|
66
69
|
private setOptions;
|
|
67
70
|
private setCallback;
|
package/dist/vivus/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as Vivus,b as default}from'../chunk-
|
|
1
|
+
export{a as Vivus,b as default}from'../chunk-EAWFBJUR.mjs';import'../chunk-AJ22VSHC.mjs';import'../chunk-5PJEKEEP.mjs';import'../chunk-LFSU6LR3.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var react=require('react');function y(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}var V=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function p(r,...t){V&&console.warn(`[svg-scroll-draw] ${r}`,...t);}var S=["delayed","sync","async","nsync","oneByOne","scenario","scenario-sync"],R=["inViewport","manual","autostart"];function u(r,t){let e=parseInt(r,10);return e>=0?e:t}function $(r){if(typeof window>"u")return false;let t=window,e=n=>typeof t[n]=="function"&&r instanceof t[n];return e("SVGSVGElement")||e("SVGGElement")||r?.constructor===t.SVGElement}var v=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],x=["line","ellipse","circle","polygon","polyline","rect"],A="http://www.w3.org/2000/svg";function b(r){let t=r.points.trim().split(" ");if(r.points.indexOf(",")===-1){let n=[];for(let s=0;s<t.length;s+=2)n.push(`${t[s]},${t[s+1]}`);t=n;}let e=`M${t[0]}`;for(let n=1;n<t.length;n++)t[n].indexOf(",")!==-1&&(e+=`L${t[n]}`);return e}function w(r,t,e,n){let s=parseFloat(e)||0,a=parseFloat(n)||0,i=parseFloat(r)||0,o=parseFloat(t)||0,l=i-s,h=i+s;return `M${l},${o}A${s},${a} 0,1,1 ${h},${o}A${s},${a} 0,1,1 ${l},${o}`}var L={line:r=>`M${r.x1||0},${r.y1||0}L${r.x2||0},${r.y2||0}`,rect(r){let t=parseFloat(r.x)||0,e=parseFloat(r.y)||0,n=parseFloat(r.width)||0,s=parseFloat(r.height)||0;if(r.rx||r.ry){let a=parseInt(r.rx,10)||-1,i=parseInt(r.ry,10)||-1;a=Math.min(Math.max(a<0?i:a,0),n/2),i=Math.min(Math.max(i<0?a:i,0),s/2);let o=`A ${a},${i},0,0,1,`;return `M ${t+a},${e} L ${t+n-a},${e} ${o}${t+n},${e+i} L ${t+n},${e+s-i} ${o}${t+n-a},${e+s} L ${t+a},${e+s} ${o}${t},${e+s-i} L ${t},${e+i} ${o}${t+a},${e}`}return `M${t} ${e} L${t+n} ${e} L${t+n} ${e+s} L${t} ${e+s} Z`},polyline:b,polygon:r=>`${b(r)}Z`,ellipse:r=>w(r.cx,r.cy,r.rx,r.ry),circle:r=>w(r.cx,r.cy,r.r,r.r)};function T(r){for(let t of Array.from(r.querySelectorAll(x.join(",")))){let e={};for(let{name:a,value:i}of Array.from(t.attributes)){if(v.indexOf(a)!==-1&&i.indexOf("%")!==-1)throw new Error("Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into 'path' tags. Please use 'viewBox'.");e[a]=i;}let n=L[t.tagName.toLowerCase()](e),s=document.createElementNS(A,"path");for(let{name:a,value:i}of Array.from(t.attributes))v.indexOf(a)===-1&&s.setAttribute(a,i);s.setAttribute("d",n),t.parentNode?.replaceChild(s,t);}}var c=class c{constructor(t,e,n){this.isReady=false;this.type="delayed";this.start="inViewport";this.duration=120;this.delay=null;this.dashGap=1;this.forceRender=false;this.reverseStack=false;this.selfDestroy=false;this.ignoreInvisible=false;this.animTimingFunction=c.LINEAR;this.pathTimingFunction=c.LINEAR;this.callback=()=>{};this.map=[];this.frameLength=0;this.currentFrame=0;this.delayUnit=0;this.speed=1;this.handle=null;this.instanceCallback=null;this.mustRecalcScale=null;this.viewportListener=null;this.setElement(t,e),this.setOptions(e),this.setCallback(n),this.isReady&&this.init();}setElement(t,e){if(t===void 0)throw new Error('Vivus [constructor]: "element" parameter is required');let n=t;if(typeof n=="string"){let s=document.getElementById(n);if(!s)throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID');n=s;}if(this.parentEl=n,e&&e.file){let s=new XMLHttpRequest;s.addEventListener("load",()=>{let a=document.createElement("div");a.innerHTML=s.responseText;let i=a.querySelector("svg");if(!i)throw new Error(`Vivus [load]: Cannot find the SVG in the loaded file : ${e.file}`);this.el=i,i.setAttribute("width","100%"),i.setAttribute("height","100%"),this.parentEl.appendChild(i),this.isReady=true,this.init();}),s.open("GET",e.file),s.send();return}if($(n)){this.el=n,this.isReady=true;return}if(n instanceof HTMLObjectElement){let s=n,a=i=>{if(this.isReady)return;let o=s.contentDocument&&s.contentDocument.querySelector("svg");if(!o&&i)throw new Error("Vivus [constructor]: object loaded does not contain any SVG");o&&(s.getAttribute("built-by-vivus")&&(this.parentEl.insertBefore(o,s),this.parentEl.removeChild(s),o.setAttribute("width","100%"),o.setAttribute("height","100%")),this.el=o,this.isReady=true,this.init());};a(),this.isReady||s.addEventListener("load",a);return}throw new Error('Vivus [constructor]: "element" parameter is not valid (or miss the "file" attribute)')}setOptions(t){if(t!==void 0&&(t===null||t.constructor!==Object))throw new Error('Vivus [constructor]: "options" parameter must be an object');let e=t||{};if(e.type&&S.indexOf(e.type)===-1)throw new Error(`Vivus [constructor]: ${e.type} is not an existing animation \`type\``);if(e.start&&R.indexOf(e.start)===-1)throw new Error(`Vivus [constructor]: ${e.start} is not an existing \`start\` option`);this.type=e.type||"delayed",this.start=e.start||"inViewport";let n=navigator.userAgent,s=n.indexOf("MSIE")!==-1||n.indexOf("Trident/")!==-1||n.indexOf("Edge/")!==-1;if(this.duration=u(e.duration,120),this.delay=u(e.delay,null),this.dashGap=u(e.dashGap,1),this.forceRender=Object.prototype.hasOwnProperty.call(e,"forceRender")?!!e.forceRender:s,this.reverseStack=!!e.reverseStack,this.selfDestroy=!!e.selfDestroy,this.onReady=e.onReady,this.map=[],this.ignoreInvisible=Object.prototype.hasOwnProperty.call(e,"ignoreInvisible")?!!e.ignoreInvisible:false,this.animTimingFunction=e.animTimingFunction||c.LINEAR,this.pathTimingFunction=e.pathTimingFunction||c.LINEAR,this.delay!==null&&this.delay>=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")}setCallback(t){if(t&&typeof t!="function")throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||(()=>{});}mapping(){let t=0,e=0,n=0,s=false,a=Array.from(this.el.querySelectorAll("path"));a.forEach((i,o)=>{if(this.isInvisible(i))return;let l={el:i,length:0,startAt:0,duration:0,isResizeSensitive:false},h=1;if(i.getAttribute("vector-effect")==="non-scaling-stroke"){let d=i.getBoundingClientRect(),f=i.getBBox();h=Math.max(d.width/f.width,d.height/f.height),l.isResizeSensitive=true,s=true;}if(l.length=Math.ceil(i.getTotalLength()*h),isNaN(l.length)){p("vivus: cannot retrieve a path element length",i);return}this.map.push(l),i.style.strokeDasharray=`${l.length} ${l.length+this.dashGap*2}`,i.style.strokeDashoffset=String(l.length+this.dashGap),l.length+=this.dashGap,e+=l.length,this.renderPath(o);}),s&&p("vivus: this SVG contains non-scaling-strokes. Call instance.recalc() when the SVG is resized."),e=e===0?1:e,this.delay=this.delay===null?this.duration/3:this.delay,this.delayUnit=this.delay/(a.length>1?a.length-1:1),this.reverseStack&&this.map.reverse(),this.map.forEach((i,o)=>{let l=()=>{let h={};for(let{name:d,value:f}of Array.from(i.el.attributes))h[d]=f;return h};switch(this.type){case "delayed":i.startAt=this.delayUnit*o,i.duration=this.duration-this.delay;break;case "oneByOne":i.startAt=n/e*this.duration,i.duration=i.length/e*this.duration;break;case "sync":case "async":case "nsync":i.startAt=0,i.duration=this.duration;break;case "scenario-sync":{let h=l();i.startAt=t+(u(h["data-delay"],this.delayUnit)||0),i.duration=u(h["data-duration"],this.duration),t=h["data-async"]!==void 0?i.startAt:i.startAt+i.duration,this.frameLength=Math.max(this.frameLength,i.startAt+i.duration);break}case "scenario":{let h=l();i.startAt=u(h["data-start"],this.delayUnit)||0,i.duration=u(h["data-duration"],this.duration),this.frameLength=Math.max(this.frameLength,i.startAt+i.duration);break}}n+=i.length,this.frameLength=this.frameLength||this.duration;});}recalc(){this.mustRecalcScale||(this.mustRecalcScale=requestAnimationFrame(()=>this.performLineRecalc()));}performLineRecalc(){for(let t of this.map){if(!t.isResizeSensitive)continue;let e=t.el.getBoundingClientRect(),n=t.el.getBBox(),s=Math.max(e.width/n.width,e.height/n.height);t.length=Math.ceil(t.el.getTotalLength()*s),t.el.style.strokeDasharray=`${t.length} ${t.length+this.dashGap*2}`;}this.trace(),this.mustRecalcScale=null;}draw(){if(this.currentFrame+=this.speed,this.currentFrame<=0)this.stop(),this.reset();else if(this.currentFrame>=this.frameLength)this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy();else {this.trace(),this.handle=requestAnimationFrame(()=>this.draw());return}this.finished();}finished(){if(this.callback(this),this.instanceCallback){let t=this.instanceCallback;this.instanceCallback=null,t(this);}}trace(){let t=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength;this.map.forEach((e,n)=>{let s=this.pathTimingFunction(Math.max(0,Math.min(1,(t-e.startAt)/e.duration)));e.progress!==s&&(e.progress=s,e.el.style.strokeDashoffset=String(Math.floor(e.length*(1-s))),this.renderPath(n));});}renderPath(t){let e=this.forceRender&&this.map&&this.map[t];if(!e)return;let n=e.el.cloneNode(true);e.el.parentNode?.replaceChild(n,e.el),e.el=n;}init(){this.frameLength=0,this.currentFrame=0,this.map=[],T(this.el),this.mapping(),this.starter(),this.onReady&&this.onReady(this);}starter(){if(this.start==="manual")return;if(this.start==="autostart"){this.play();return}let t=()=>{this.isInViewport(this.parentEl,1)&&(this.play(),window.removeEventListener("scroll",t),this.viewportListener=null);};this.viewportListener=t,window.addEventListener("scroll",t),t();}getStatus(){return this.currentFrame===0?"start":this.currentFrame===this.frameLength?"end":"progress"}reset(){return this.setFrameProgress(0)}finish(){return this.setFrameProgress(1)}setFrameProgress(t){let e=Math.min(1,Math.max(0,t));return this.currentFrame=Math.round(this.frameLength*e),this.trace(),this}play(t,e){this.instanceCallback=null;let n=t;if(n&&typeof n=="function")this.instanceCallback=n,n=void 0;else if(n&&typeof n!="number")throw new Error("Vivus [play]: invalid speed");return e&&typeof e=="function"&&!this.instanceCallback&&(this.instanceCallback=e),this.speed=n||1,y()?(this.stop(),this.currentFrame=this.speed<0?0:this.frameLength,this.trace(),this.speed>0&&this.selfDestroy&&this.destroy(),this.finished(),this):(this.handle||this.draw(),this)}stop(){return this.handle&&(cancelAnimationFrame(this.handle),this.handle=null),this}destroy(){this.stop(),this.viewportListener&&(window.removeEventListener("scroll",this.viewportListener),this.viewportListener=null),this.map.forEach((t,e)=>{t.el.style.strokeDashoffset="",t.el.style.strokeDasharray="",this.renderPath(e);});}isInvisible(t){let e=t.getAttribute("data-ignore");if(e!==null)return e!=="false";if(this.ignoreInvisible){let n=t.getBoundingClientRect();return !n.width&&!n.height}return false}isInViewport(t,e=0){let n=window.pageYOffset||document.documentElement.scrollTop,s=n+Math.max(document.documentElement.clientHeight,window.innerHeight),a=t.getBoundingClientRect(),i=n+a.top;return i+a.height*(e||0)<=s&&i+a.height>=n}};c.LINEAR=t=>t,c.EASE=t=>-Math.cos(t*Math.PI)/2+.5,c.EASE_OUT=t=>1-Math.pow(1-t,3),c.EASE_IN=t=>Math.pow(t,3),c.EASE_OUT_BOUNCE=t=>{let e=-Math.cos(t*(.5*Math.PI))+1,n=Math.pow(e,1.5),s=Math.pow(1-t,2),a=-Math.abs(Math.cos(n*(2.5*Math.PI)))+1;return 1-s+a*s};var m=c,E=m;function _(r={},t){let e=react.useRef(null),[n,s]=react.useState(null),a=react.useRef(r),i=react.useRef(t);return a.current=r,i.current=t,react.useEffect(()=>{if(!e.current)return;let o=new E(e.current,a.current,l=>i.current?.(l));return s(o),()=>{o.destroy(),s(null);}},[]),[e,n]}
|
|
3
|
-
exports.useVivus=
|
|
2
|
+
'use strict';var react=require('react');function y(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function g(r){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),e=s=>r(!!s.matches);if(typeof t.addEventListener=="function")return t.addEventListener("change",e),()=>t.removeEventListener("change",e);let n=t;return n.addListener?.(e),()=>n.removeListener?.(e)}var L=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function p(r,...t){L&&console.warn(`[svg-scroll-draw] ${r}`,...t);}var R=["delayed","sync","async","nsync","oneByOne","scenario","scenario-sync"],S=["inViewport","manual","autostart"];function u(r,t){let e=parseInt(r,10);return e>=0?e:t}function x(r){if(typeof window>"u")return false;let t=window,e=n=>typeof t[n]=="function"&&r instanceof t[n];return e("SVGSVGElement")||e("SVGGElement")||r?.constructor===t.SVGElement}var w=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],M=["line","ellipse","circle","polygon","polyline","rect"],$="http://www.w3.org/2000/svg";function b(r){let t=r.points.trim().split(" ");if(r.points.indexOf(",")===-1){let n=[];for(let s=0;s<t.length;s+=2)n.push(`${t[s]},${t[s+1]}`);t=n;}let e=`M${t[0]}`;for(let n=1;n<t.length;n++)t[n].indexOf(",")!==-1&&(e+=`L${t[n]}`);return e}function E(r,t,e,n){let s=parseFloat(e)||0,a=parseFloat(n)||0,i=parseFloat(r)||0,o=parseFloat(t)||0,l=i-s,h=i+s;return `M${l},${o}A${s},${a} 0,1,1 ${h},${o}A${s},${a} 0,1,1 ${l},${o}`}var A={line:r=>`M${r.x1||0},${r.y1||0}L${r.x2||0},${r.y2||0}`,rect(r){let t=parseFloat(r.x)||0,e=parseFloat(r.y)||0,n=parseFloat(r.width)||0,s=parseFloat(r.height)||0;if(r.rx||r.ry){let a=parseInt(r.rx,10)||-1,i=parseInt(r.ry,10)||-1;a=Math.min(Math.max(a<0?i:a,0),n/2),i=Math.min(Math.max(i<0?a:i,0),s/2);let o=`A ${a},${i},0,0,1,`;return `M ${t+a},${e} L ${t+n-a},${e} ${o}${t+n},${e+i} L ${t+n},${e+s-i} ${o}${t+n-a},${e+s} L ${t+a},${e+s} ${o}${t},${e+s-i} L ${t},${e+i} ${o}${t+a},${e}`}return `M${t} ${e} L${t+n} ${e} L${t+n} ${e+s} L${t} ${e+s} Z`},polyline:b,polygon:r=>`${b(r)}Z`,ellipse:r=>E(r.cx,r.cy,r.rx,r.ry),circle:r=>E(r.cx,r.cy,r.r,r.r)};function T(r){for(let t of Array.from(r.querySelectorAll(M.join(",")))){let e={};for(let{name:a,value:i}of Array.from(t.attributes)){if(w.indexOf(a)!==-1&&i.indexOf("%")!==-1)throw new Error("Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into 'path' tags. Please use 'viewBox'.");e[a]=i;}let n=A[t.tagName.toLowerCase()](e),s=document.createElementNS($,"path");for(let{name:a,value:i}of Array.from(t.attributes))w.indexOf(a)===-1&&s.setAttribute(a,i);s.setAttribute("d",n),t.parentNode?.replaceChild(s,t);}}var c=class c{constructor(t,e,n){this.isReady=false;this.type="delayed";this.start="inViewport";this.duration=120;this.delay=null;this.dashGap=1;this.forceRender=false;this.reverseStack=false;this.selfDestroy=false;this.ignoreInvisible=false;this.animTimingFunction=c.LINEAR;this.pathTimingFunction=c.LINEAR;this.callback=()=>{};this.map=[];this.frameLength=0;this.currentFrame=0;this.delayUnit=0;this.speed=1;this.handle=null;this.instanceCallback=null;this.mustRecalcScale=null;this.viewportListener=null;this.unwatchMotion=()=>{};this.setElement(t,e),this.setOptions(e),this.setCallback(n),this.isReady&&this.init(),this.unwatchMotion=g(s=>{s&&this.handle&&this.endNow();});}endNow(){this.stop(),this.currentFrame=this.speed<0?0:this.frameLength,this.trace(),this.speed>0&&this.selfDestroy&&this.destroy(),this.finished();}setElement(t,e){if(t===void 0)throw new Error('Vivus [constructor]: "element" parameter is required');let n=t;if(typeof n=="string"){let s=document.getElementById(n);if(!s)throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID');n=s;}if(this.parentEl=n,e&&e.file){let s=new XMLHttpRequest;s.addEventListener("load",()=>{let a=document.createElement("div");a.innerHTML=s.responseText;let i=a.querySelector("svg");if(!i)throw new Error(`Vivus [load]: Cannot find the SVG in the loaded file : ${e.file}`);this.el=i,i.setAttribute("width","100%"),i.setAttribute("height","100%"),this.parentEl.appendChild(i),this.isReady=true,this.init();}),s.open("GET",e.file),s.send();return}if(x(n)){this.el=n,this.isReady=true;return}if(n instanceof HTMLObjectElement){let s=n,a=i=>{if(this.isReady)return;let o=s.contentDocument&&s.contentDocument.querySelector("svg");if(!o&&i)throw new Error("Vivus [constructor]: object loaded does not contain any SVG");o&&(s.getAttribute("built-by-vivus")&&(this.parentEl.insertBefore(o,s),this.parentEl.removeChild(s),o.setAttribute("width","100%"),o.setAttribute("height","100%")),this.el=o,this.isReady=true,this.init());};a(),this.isReady||s.addEventListener("load",a);return}throw new Error('Vivus [constructor]: "element" parameter is not valid (or miss the "file" attribute)')}setOptions(t){if(t!==void 0&&(t===null||t.constructor!==Object))throw new Error('Vivus [constructor]: "options" parameter must be an object');let e=t||{};if(e.type&&R.indexOf(e.type)===-1)throw new Error(`Vivus [constructor]: ${e.type} is not an existing animation \`type\``);if(e.start&&S.indexOf(e.start)===-1)throw new Error(`Vivus [constructor]: ${e.start} is not an existing \`start\` option`);this.type=e.type||"delayed",this.start=e.start||"inViewport";let n=navigator.userAgent,s=n.indexOf("MSIE")!==-1||n.indexOf("Trident/")!==-1||n.indexOf("Edge/")!==-1;if(this.duration=u(e.duration,120),this.delay=u(e.delay,null),this.dashGap=u(e.dashGap,1),this.forceRender=Object.prototype.hasOwnProperty.call(e,"forceRender")?!!e.forceRender:s,this.reverseStack=!!e.reverseStack,this.selfDestroy=!!e.selfDestroy,this.onReady=e.onReady,this.map=[],this.ignoreInvisible=Object.prototype.hasOwnProperty.call(e,"ignoreInvisible")?!!e.ignoreInvisible:false,this.animTimingFunction=e.animTimingFunction||c.LINEAR,this.pathTimingFunction=e.pathTimingFunction||c.LINEAR,this.delay!==null&&this.delay>=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")}setCallback(t){if(t&&typeof t!="function")throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||(()=>{});}mapping(){let t=0,e=0,n=0,s=false,a=Array.from(this.el.querySelectorAll("path"));a.forEach((i,o)=>{if(this.isInvisible(i))return;let l={el:i,length:0,startAt:0,duration:0,isResizeSensitive:false},h=1;if(i.getAttribute("vector-effect")==="non-scaling-stroke"){let d=i.getBoundingClientRect(),f=i.getBBox();h=Math.max(d.width/f.width,d.height/f.height),l.isResizeSensitive=true,s=true;}if(l.length=Math.ceil(i.getTotalLength()*h),isNaN(l.length)){p("vivus: cannot retrieve a path element length",i);return}this.map.push(l),i.style.strokeDasharray=`${l.length} ${l.length+this.dashGap*2}`,i.style.strokeDashoffset=String(l.length+this.dashGap),l.length+=this.dashGap,e+=l.length,this.renderPath(o);}),s&&p("vivus: this SVG contains non-scaling-strokes. Call instance.recalc() when the SVG is resized."),e=e===0?1:e,this.delay=this.delay===null?this.duration/3:this.delay,this.delayUnit=this.delay/(a.length>1?a.length-1:1),this.reverseStack&&this.map.reverse(),this.map.forEach((i,o)=>{let l=()=>{let h={};for(let{name:d,value:f}of Array.from(i.el.attributes))h[d]=f;return h};switch(this.type){case "delayed":i.startAt=this.delayUnit*o,i.duration=this.duration-this.delay;break;case "oneByOne":i.startAt=n/e*this.duration,i.duration=i.length/e*this.duration;break;case "sync":case "async":case "nsync":i.startAt=0,i.duration=this.duration;break;case "scenario-sync":{let h=l();i.startAt=t+(u(h["data-delay"],this.delayUnit)||0),i.duration=u(h["data-duration"],this.duration),t=h["data-async"]!==void 0?i.startAt:i.startAt+i.duration,this.frameLength=Math.max(this.frameLength,i.startAt+i.duration);break}case "scenario":{let h=l();i.startAt=u(h["data-start"],this.delayUnit)||0,i.duration=u(h["data-duration"],this.duration),this.frameLength=Math.max(this.frameLength,i.startAt+i.duration);break}}n+=i.length,this.frameLength=this.frameLength||this.duration;});}recalc(){this.mustRecalcScale||(this.mustRecalcScale=requestAnimationFrame(()=>this.performLineRecalc()));}performLineRecalc(){for(let t of this.map){if(!t.isResizeSensitive)continue;let e=t.el.getBoundingClientRect(),n=t.el.getBBox(),s=Math.max(e.width/n.width,e.height/n.height);t.length=Math.ceil(t.el.getTotalLength()*s),t.el.style.strokeDasharray=`${t.length} ${t.length+this.dashGap*2}`;}this.trace(),this.mustRecalcScale=null;}draw(){if(this.currentFrame+=this.speed,this.currentFrame<=0)this.stop(),this.reset();else if(this.currentFrame>=this.frameLength)this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy();else {this.trace(),this.handle=requestAnimationFrame(()=>this.draw());return}this.finished();}finished(){if(this.callback(this),this.instanceCallback){let t=this.instanceCallback;this.instanceCallback=null,t(this);}}trace(){let t=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength;this.map.forEach((e,n)=>{let s=this.pathTimingFunction(Math.max(0,Math.min(1,(t-e.startAt)/e.duration)));e.progress!==s&&(e.progress=s,e.el.style.strokeDashoffset=String(Math.floor(e.length*(1-s))),this.renderPath(n));});}renderPath(t){let e=this.forceRender&&this.map&&this.map[t];if(!e)return;let n=e.el.cloneNode(true);e.el.parentNode?.replaceChild(n,e.el),e.el=n;}init(){this.frameLength=0,this.currentFrame=0,this.map=[],T(this.el),this.mapping(),this.starter(),this.onReady&&this.onReady(this);}starter(){if(this.start==="manual")return;if(this.start==="autostart"){this.play();return}let t=()=>{this.isInViewport(this.parentEl,1)&&(this.play(),window.removeEventListener("scroll",t),this.viewportListener=null);};this.viewportListener=t,window.addEventListener("scroll",t),t();}getStatus(){return this.currentFrame===0?"start":this.currentFrame===this.frameLength?"end":"progress"}reset(){return this.setFrameProgress(0)}finish(){return this.setFrameProgress(1)}setFrameProgress(t){let e=Math.min(1,Math.max(0,t));return this.currentFrame=Math.round(this.frameLength*e),this.trace(),this}play(t,e){this.instanceCallback=null;let n=t;if(n&&typeof n=="function")this.instanceCallback=n,n=void 0;else if(n&&typeof n!="number")throw new Error("Vivus [play]: invalid speed");return e&&typeof e=="function"&&!this.instanceCallback&&(this.instanceCallback=e),this.speed=n||1,y()?(this.endNow(),this):(this.handle||this.draw(),this)}stop(){return this.handle&&(cancelAnimationFrame(this.handle),this.handle=null),this}destroy(){this.stop(),this.unwatchMotion(),this.viewportListener&&(window.removeEventListener("scroll",this.viewportListener),this.viewportListener=null),this.map.forEach((t,e)=>{t.el.style.strokeDashoffset="",t.el.style.strokeDasharray="",this.renderPath(e);});}isInvisible(t){let e=t.getAttribute("data-ignore");if(e!==null)return e!=="false";if(this.ignoreInvisible){let n=t.getBoundingClientRect();return !n.width&&!n.height}return false}isInViewport(t,e=0){let n=window.pageYOffset||document.documentElement.scrollTop,s=n+Math.max(document.documentElement.clientHeight,window.innerHeight),a=t.getBoundingClientRect(),i=n+a.top;return i+a.height*(e||0)<=s&&i+a.height>=n}};c.LINEAR=t=>t,c.EASE=t=>-Math.cos(t*Math.PI)/2+.5,c.EASE_OUT=t=>1-Math.pow(1-t,3),c.EASE_IN=t=>Math.pow(t,3),c.EASE_OUT_BOUNCE=t=>{let e=-Math.cos(t*(.5*Math.PI))+1,n=Math.pow(e,1.5),s=Math.pow(1-t,2),a=-Math.abs(Math.cos(n*(2.5*Math.PI)))+1;return 1-s+a*s};var m=c,V=m;function j(r={},t){let e=react.useRef(null),[n,s]=react.useState(null),a=react.useRef(r),i=react.useRef(t);return a.current=r,i.current=t,react.useEffect(()=>{if(!e.current)return;let o=new V(e.current,a.current,l=>i.current?.(l));return s(o),()=>{o.destroy(),s(null);}},[]),[e,n]}
|
|
3
|
+
exports.useVivus=j;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {b}from'../../chunk-
|
|
2
|
+
import {b}from'../../chunk-EAWFBJUR.mjs';import'../../chunk-AJ22VSHC.mjs';import'../../chunk-5PJEKEEP.mjs';import'../../chunk-LFSU6LR3.mjs';import {useRef,useState,useEffect}from'react';function a(n={},u){let e=useRef(null),[o,r]=useState(null),s=useRef(n),c=useRef(u);return s.current=n,c.current=u,useEffect(()=>{if(!e.current)return;let i=new b(e.current,s.current,f=>c.current?.(f));return r(i),()=>{i.destroy(),r(null);}},[]),[e,o]}export{a as useVivus};
|