svg-scroll-draw 2.23.4 → 2.23.6
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 +21 -6
- package/dist/angular/index.cjs +3 -3
- package/dist/angular/index.d.mts +3 -3
- package/dist/angular/index.d.ts +3 -3
- package/dist/angular/index.mjs +1 -1
- package/dist/astro/index.cjs +2 -2
- package/dist/astro/index.d.mts +3 -3
- package/dist/astro/index.d.ts +3 -3
- package/dist/astro/index.mjs +1 -1
- package/dist/cdn/svg-scroll-draw.dev.global.js +190 -265
- package/dist/cdn/svg-scroll-draw.global.js +3 -3
- package/dist/{chunk-DSFD227B.mjs → chunk-22B37AWY.mjs} +1 -1
- package/dist/{chunk-YNNA33A5.mjs → chunk-BSW7W2Y5.mjs} +1 -1
- package/dist/{chunk-XTPAW6XR.mjs → chunk-CZLUBJAI.mjs} +1 -1
- package/dist/chunk-K6VATIJH.mjs +3 -0
- package/dist/chunk-NV6YTPHI.mjs +1 -0
- package/dist/chunk-NYQJPPMP.mjs +1 -0
- package/dist/{chunk-ZNCZYV3Q.mjs → chunk-OSGWGHQJ.mjs} +1 -1
- package/dist/chunk-PAGN26EH.mjs +1 -0
- package/dist/chunk-THPTANES.mjs +1 -0
- package/dist/{chunk-OJFWQ6CU.mjs → chunk-V3Z6G5JE.mjs} +1 -1
- package/dist/chunk-VJ5ZU55P.mjs +1 -0
- package/dist/chunk-XNM3VKEK.mjs +1 -0
- package/dist/cinematic/index.cjs +2 -2
- package/dist/cinematic/index.mjs +1 -1
- package/dist/{engine-B7UpB4fT.d.ts → engine-6VsjEwzb.d.ts} +1 -1
- package/dist/{engine-o1VSQ1lX.d.mts → engine-BLWKCfxC.d.mts} +1 -1
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +3 -3
- package/dist/group/index.d.ts +3 -3
- package/dist/group/index.mjs +1 -1
- package/dist/horizontal/index.cjs +1 -1
- package/dist/horizontal/index.d.mts +1 -1
- package/dist/horizontal/index.d.ts +1 -1
- package/dist/horizontal/index.mjs +1 -1
- package/dist/{index-D3o4vT3e.d.ts → index-BN8yKeQ3.d.ts} +1 -1
- package/dist/{index-BY-CNE8c.d.mts → index-DAiRJgtF.d.mts} +2 -2
- package/dist/{index-CdaBYn3A.d.mts → index-DVjblK_4.d.mts} +1 -1
- package/dist/{index-DqXXiDIk.d.ts → index-hSQqLVbg.d.ts} +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +1 -1
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +3 -3
- package/dist/nuxt/index.d.ts +3 -3
- package/dist/nuxt/index.mjs +1 -1
- package/dist/progress/index.cjs +1 -1
- package/dist/progress/index.d.mts +1 -1
- package/dist/progress/index.d.ts +1 -1
- package/dist/progress/index.mjs +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.mjs +1 -1
- package/dist/reveal/index.cjs +1 -1
- package/dist/reveal/index.d.mts +1 -1
- package/dist/reveal/index.d.ts +1 -1
- package/dist/reveal/index.mjs +1 -1
- package/dist/{scroll-draw-DsBMkwrX.d.ts → scroll-draw-BsU_Ohmu.d.ts} +1 -1
- package/dist/{scroll-draw-Dej-GIRP.d.mts → scroll-draw-Fzir8hlU.d.mts} +1 -1
- package/dist/snap/index.cjs +1 -1
- package/dist/snap/index.d.mts +1 -1
- package/dist/snap/index.d.ts +1 -1
- package/dist/snap/index.mjs +1 -1
- package/dist/solid/index.cjs +3 -3
- package/dist/solid/index.d.mts +3 -3
- package/dist/solid/index.d.ts +3 -3
- package/dist/solid/index.mjs +1 -1
- package/dist/svelte/index.cjs +3 -3
- package/dist/svelte/index.d.mts +3 -3
- package/dist/svelte/index.d.ts +3 -3
- package/dist/svelte/index.mjs +1 -1
- package/dist/text/index.cjs +1 -1
- package/dist/text/index.d.mts +1 -1
- package/dist/text/index.d.ts +1 -1
- package/dist/text/index.mjs +1 -1
- package/dist/timeline/index.cjs +9 -9
- package/dist/timeline/index.d.mts +1 -1
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.mjs +8 -8
- package/dist/{types-MswK0erX.d.mts → types-9bcJdVcg.d.mts} +6 -2
- package/dist/{types-MswK0erX.d.ts → types-9bcJdVcg.d.ts} +6 -2
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.d.mts +1 -1
- package/dist/video/index.d.ts +1 -1
- package/dist/video/index.mjs +1 -1
- package/dist/vue/index.cjs +3 -3
- package/dist/vue/index.d.mts +3 -3
- package/dist/vue/index.d.ts +3 -3
- 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 +8 -2
- package/dist/chunk-6TWFLRUB.mjs +0 -3
- package/dist/chunk-A4JCC3QQ.mjs +0 -1
- package/dist/chunk-DM6EDKWH.mjs +0 -1
- package/dist/chunk-I73SOXBN.mjs +0 -1
- package/dist/chunk-NLPSVYFP.mjs +0 -1
- package/dist/chunk-OPXWNJBG.mjs +0 -1
- package/dist/chunk-QFSTKVA3.mjs +0 -1
package/dist/svelte/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function yn({bounces:e=3,decay:t=.5}={}){let n=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,t)),
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${p?`left:${m}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${m}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 Xt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Kt=/[MmLlHhVvCcSsQqTtAaZz]/g;function An(e,t,n){if(!Ge)return;let r=(e.match(Kt)??[]).join("").toUpperCase(),s=(t.match(Kt)??[]).join("").toUpperCase(),i=(e.match(Xt)??[]).length,a=(t.match(Xt)??[]).length;if(r!==s){ge(`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&&ge(`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 Cn(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),m=r[s++]??a;return String(+(a+(m-a)*n).toFixed(4))})}function wt(e,t={}){return typeof window>"u"?{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0}:_e(t,(n,r)=>Pn(e,n,r))}function Pn(e,t,n){let{preset:r,...s}=t,i=r?{...qt[r],...s}:s,{selector:a="path, polyline, line, polygon, rect, circle",speed:m=1,fade:p=false,easing:y="linear",trigger:E={},stagger:F=0,direction:S="forward",once:Y=false,debug:te=false,axis:L="y",scrollContainer:ne,autoReverse:we=false,delay:P=0,strokeColor:O,strokeWidth:$,fillOpacity:A,waypoints:b,velocityScale:h=false,threshold:v=0,rootMargin:G="0px",repeat:_=0,repeatDelay:q=0,morphTo:N,clip:R,autoplay:re=false,duration:Te=1e3,native:ce=true,onProgress:H,onStart:k,onComplete:I,onEnter:u,onLeave:d,onEnterBack:X,onLeaveBack:xe}=i,V=R===true?"left":typeof R=="string"?R:false,K=typeof y=="function"?y:ee[y]??ee.linear,$e=de(E.start||"top bottom"),x=de(E.end||"bottom top"),T=typeof ne=="string"?document.querySelector(ne):ne??null,ue=Array.isArray(O)?O[0]:null,me=Array.isArray(O)?O[1]:typeof O=="string"?O:null,ke=Array.isArray($)?$[0]:null,Oe=Array.isArray($)?$[1]:typeof $=="number"?$:null,Me=Array.isArray(A)?A[0]:null,He=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function Re(o){let l=o*100;switch(V){case "right":return `inset(0 0 0 ${100-l}%)`;case "top":return `inset(0 0 ${100-l}% 0)`;case "bottom":return `inset(${100-l}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-l}% 0 0)`}}let D=V?[]:Array.from(e.querySelectorAll(a)),ye=[],ve=[],oe=0,Z=0,We=F,Je=0,j=false,c=false,f=0,Ae=false,fe=-1,J=[],Q=-1,w=false,se=0,he=0,Ne,ft=null;function Ct(){ft?.destroy(),ft=null;}let Ve=new Set,Pt=NaN,ze=true,et=-1,$t=performance.now(),qe=NaN;function je(){return T?L==="x"?T.scrollLeft:T.scrollTop:L==="x"?window.scrollX:window.scrollY}function kt(){return T?L==="x"?T.clientWidth:T.clientHeight:L==="x"?window.innerWidth:window.innerHeight}function It(){let o=ot(e,T,L);return Le(o,o.scroll,kt(),$e,x)}function cn(){let o=Z-oe,l=D.length-1,g=T??document.documentElement,C=L==="x"?"Width":"Height";if(We=F,F>0&&l>0&&o>0){let pe=g[`scroll${C}`]-g[`client${C}`]-1-oe-o/m;pe>=0&&(We=Math.min(F,pe/(l*o)));}Je=Z+l*We*o;}function Ot(){(({tStart:oe,tEnd:Z}=It())),cn(),te&&Ge&&(Ct(),ft=Ln(oe,Z,L));}function pt(o,l=It){Ce(e,{type:"draw",getProgress:()=>o.getProgress(),getTrigger:l});let g=o.destroy;return o.destroy=()=>{g.call(o),Pe(e);},o}function Rt(o,l){return Y&&!we?Math.max(fe,K(J[o]=Math.max(J[o]??0,l))):K(l)}function un(o,l){if(e.style.setProperty("--scroll-draw-progress",String(o)),V){let g=l==="reverse"?1-o:o;e.style.clipPath=Re(g);return}D.forEach((g,C)=>dt(g,C,o,l));}function dt(o,l,g,C){o.style.strokeDashoffset=C==="reverse"?`${ye[l]*g}`:`${ye[l]*(1-g)}`,p&&(o.style.opacity=C==="reverse"?`${1-g}`:`${g}`),ue&&me?o.style.stroke=it(ue,me,g):me&&(o.style.stroke=me),ke!==null&&Oe!==null?o.style.strokeWidth=`${ke+(Oe-ke)*g}`:Oe!==null&&(o.style.strokeWidth=`${Oe}`),Me!==null&&He!==null?o.style.fillOpacity=`${Me+(He-Me)*g}`:He!==null&&(o.style.fillOpacity=`${He}`),N&&o.tagName.toLowerCase()==="path"&&ve[l]&&o.setAttribute("d",Cn(ve[l],N,g));}function Qe(){if(e.style.setProperty("--scroll-draw-progress","0"),V){e.style.clipPath=Re(S==="reverse"?1:0);return}D.forEach((o,l)=>{o.style.strokeDasharray=`${ye[l]}`,o.style.strokeDashoffset=S==="reverse"?"0":`${ye[l]}`,p?o.style.opacity=S==="reverse"?"1":"0":o.style.opacity="",ue&&(o.style.stroke=ue),ke!==null&&(o.style.strokeWidth=`${ke}`),Me!==null&&(o.style.fillOpacity=`${Me}`),N&&o.tagName.toLowerCase()==="path"&&ve[l]&&o.setAttribute("d",ve[l]);});}function Ue(o,l){let g=o.getAttribute("d"),C=st(o);if(N&&ve[l]){o.setAttribute("d",N);let pe=st(o);o.setAttribute("d",ve[l]),C=Math.max(st(o),pe),o.setAttribute("d",g);}ye[l]=C,o.style.strokeDasharray=`${C}`;}if(D.forEach((o,l)=>{Mn(o);let g=o.tagName.toLowerCase()==="path";g?ve.push(o.getAttribute("d")??""):ve.push(""),Ue(o,l);let C=ye[l];N&&(g?An(ve[ve.length-1],N,o):ge(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),n?(o.style.strokeDashoffset=S==="reverse"?`${C}`:"0",p&&(o.style.opacity="1"),me&&(o.style.stroke=me),Oe!==null&&(o.style.strokeWidth=`${Oe}`),He!==null&&(o.style.fillOpacity=`${He}`),N&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",N)):(o.style.strokeDashoffset=S==="reverse"?"0":`${C}`,p?o.style.opacity=S==="reverse"?"1":"0":o.style.opacity="",ue&&(o.style.stroke=ue),ke!==null&&(o.style.strokeWidth=`${ke}`),Me!==null&&(o.style.fillOpacity=`${Me}`));}),n)return V&&(e.style.clipPath=Re(1)),I?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};V&&(e.style.clipPath=Re(S==="reverse"?1:0));let Dt=typeof y=="string"?at(y):null;function mn(){return !(ce===false||re||te&&Ge||!xn()||!D.length||!Dt||V||L!=="y"||T||m!==1||F!==0||Y||we||h!==false||N||b||_||P>0||H||k||I||u||d||X||xe||O!=null||$!=null||A!=null||(E.start||"top bottom").trim()!=="top bottom"||(E.end||"bottom top").trim()!=="bottom top")}function fn(){let o=++Tn,l=`svg-scroll-draw-${o}`,g=`svg-scroll-draw-host-${o}`,C=`--svg-scroll-draw-${o}`,pe=S==="reverse"?"0":"var(--ssd-len)",De=S==="reverse"?"var(--ssd-len)":"0",Ee=`stroke-dashoffset:${pe};`,W=`stroke-dashoffset:${De};`;p&&(Ee+=`opacity:${S==="reverse"?1:0};`,W+=`opacity:${S==="reverse"?0:1};`);let B=document.createElement("style");B.setAttribute("data-svg-scroll-draw",""),B.textContent=`@keyframes ${l}{from{${Ee}}to{${W}}}.${g}{view-timeline-name:${C};view-timeline-axis:block;}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${Dt};animation-fill-mode:both;animation-timeline:${C};animation-range:cover 0% cover 100%;}`,document.head.appendChild(B),e.classList.add(g);function ie(M,z){M.style.setProperty("--ssd-len",String(ye[z])),M.style.strokeDasharray=`${ye[z]}`,M.style.strokeDashoffset="",M.style.opacity="",M.style.animationPlayState="",M.classList.add(l);}D.forEach(ie);let ae=false,be=-1;function Se(){if(be>=0)return be;let M=e.getBoundingClientRect(),{tStart:z,tEnd:le}=Le({top:M.top,height:M.height},je(),kt(),$e,x);return K(U(je(),z,le,m))}return {destroy(){e.classList.remove(g),D.forEach(M=>{M.classList.remove(l),M.style.removeProperty("--ssd-len"),M.style.animationPlayState="";}),B.remove();},replay(){ae=false,be=-1,D.forEach(ie);},pause(){ae=true,D.forEach(M=>{M.style.animationPlayState="paused";});},resume(){ae&&(ae=false,D.forEach(M=>{M.style.animationPlayState="running";}));},seek(M){let z=Math.min(1,Math.max(0,M));be=z,ae=true,D.forEach((le,Fe)=>{le.classList.remove(l),le.style.strokeDashoffset=S==="reverse"?`${ye[Fe]*z}`:`${ye[Fe]*(1-z)}`,p&&(le.style.opacity=S==="reverse"?`${1-z}`:`${z}`);});},getProgress(){return Se()},refresh(){D.forEach((M,z)=>{Ue(M,z),M.style.setProperty("--ssd-len",String(ye[z]));});}}}if(mn())return pt(fn());function pn(){let o=Math.max(1,Te),l=V?o:o*(1+Math.max(0,D.length-1)*F),g=0,C=0,pe=false;function De(be){let Se=true,M=Math.min(1,Math.max(0,be/l));if(V){let z=Math.min(1,Math.max(0,be/o)),le=K(z);se=le,e.style.setProperty("--scroll-draw-progress",String(le)),e.style.clipPath=Re(S==="reverse"?1-le:le),H?.(le),z<1&&(Se=false);}else {D.forEach((le,Fe)=>{let gn=Fe*F*o,Nt=Math.min(1,Math.max(0,(be-gn)/o));dt(le,Fe,K(Nt),S),Nt<1&&(Se=false);});let z=K(M);se=z,H?.(z),e.style.setProperty("--scroll-draw-progress",String(z));}if(b){let z=K(M);for(let le in b){let Fe=parseFloat(le);z>=Fe&&!Ve.has(Fe)&&(Ve.add(Fe),b[le]?.());}}return Se}function Ee(be){if(w)return;let Se=be-g;c||(c=true,k?.());let M=De(Se);if(M&&!j){j=true,De(l),I?.(),he<(_==="infinite"?1/0:_??0)&&(he++,Ne=setTimeout(()=>{g=performance.now(),c=false,j=false,Ve.clear(),Qe(),f=requestAnimationFrame(Ee);},q));return}M||(f=requestAnimationFrame(Ee));}function W(){cancelAnimationFrame(f),clearTimeout(Ne),g=performance.now(),C=0,w=false,c=false,j=false,he=0,pe=true,se=0,Ve.clear(),Qe(),f=requestAnimationFrame(Ee);}let B=new IntersectionObserver(be=>{be.forEach(Se=>{Se.isIntersecting&&!(Y&&j)?W():!Se.isIntersecting&&!Y&&!j&&(cancelAnimationFrame(f),clearTimeout(Ne),pe=false);});},{root:T??null,threshold:v,rootMargin:G}),ie;function ae(){clearTimeout(ie),ie=setTimeout(()=>D.forEach(Ue),150);}return window.addEventListener("resize",ae),window.addEventListener("orientationchange",ae),P>0?setTimeout(()=>B.observe(e),P):B.observe(e),{destroy(){cancelAnimationFrame(f),clearTimeout(Ne),B.disconnect(),window.removeEventListener("resize",ae),window.removeEventListener("orientationchange",ae),clearTimeout(ie);},replay(){he=0,W();},pause(){w||!pe||(w=true,C=performance.now()-g,cancelAnimationFrame(f));},resume(){w&&(w=false,pe=true,g=performance.now()-C,f=requestAnimationFrame(Ee));},seek(be){let Se=Math.min(1,Math.max(0,be));se=Se,w=true,C=Se*l,g=performance.now()-C,cancelAnimationFrame(f),De(C);},getProgress(){return se},refresh(){clearTimeout(ie),D.forEach(Ue);}}}if(re)return pt(pn());Ot();function Ft(){if(w||!Be)return;let o=performance.now(),l=je();if(!ze&&h===false&&l===Pt){yt(l);return}ze=false,Pt=l;let g=m;if(h!==false){let W=o-$t,B=W>0?Math.abs(l-(et<0?l:et))/W:0;g=m*Math.max(.2,1+B*(typeof h=="number"?h:1)*.04);}et=l,$t=o;let C=we?Q===-1||l>=Q?"forward":"reverse":S;Q=l;let pe=Z-oe,De=true,Ee=pe===0?0:(l-oe)/pe;if(isNaN(qe)||(qe<=0&&Ee>0?u?.():qe>0&&Ee<=0&&xe?.(),qe<1&&Ee>=1?d?.():qe>=1&&Ee<1&&X?.()),qe=Ee,V){let W=Rt(0,U(l,oe,Z,g));se=W,e.style.setProperty("--scroll-draw-progress",String(W));let B=C==="reverse"?1-W:W;e.style.clipPath=Re(B),H?.(W),!c&&U(l,oe,Z,g)>0&&(c=true,k?.()),W>=1&&!j?(j=true,I?.(),he<(_==="infinite"?1/0:_??0)&&(he++,Ne=setTimeout(()=>{fe=-1,J=[],c=false,j=false,Qe();},q))):W<1&&!Y&&(j=false),yt(l);return}if(D.forEach((W,B)=>{let ie=B*We*pe,ae=Rt(B,U(l,oe+ie,Z+ie,g));dt(W,B,ae,C),B===0&&(se=ae,H?.(ae),e.style.setProperty("--scroll-draw-progress",String(ae))),ae<1&&(De=false);}),b){let W=K(U(l,oe,Z,g));for(let B in b){let ie=parseFloat(B);W>=ie&&!Ve.has(ie)&&(Ve.add(ie),b[B]?.());}}!c&&U(l,oe,Z,g)>0&&(c=true,k?.()),De&&!j?(j=true,I?.(),he<(_==="infinite"?1/0:_??0)&&(he++,Ne=setTimeout(()=>{fe=-1,J=[],c=false,j=false,Ve.clear(),Qe(),ze=true;},q))):!De&&!Y&&(j=false),yt(l);}function gt(o){return o>=Z&&o<Je}function yt(o){Ae||gt(o)?f=requestAnimationFrame(Ft):Be=false;}function ht(){return Ae||gt(je())}let Be=false;function tt(){Be||(Be=true,f=requestAnimationFrame(function(){Ft();}));}function nt(){Be=false,cancelAnimationFrame(f);}let bt=new IntersectionObserver(o=>{o.forEach(l=>{Ae=l.isIntersecting,Ae&&!w?(ze=true,tt()):Be&&!w&>(je())||nt();});},{root:T??null,threshold:v,rootMargin:G});function Ht(){D.forEach(Ue),Ot(),ze=true;}let rt;function Ye(){clearTimeout(rt),rt=setTimeout(Ht,150);}window.addEventListener("resize",Ye),window.addEventListener("orientationchange",Ye);let dn=Ie([e],Ye);return P>0?setTimeout(()=>bt.observe(e),P):bt.observe(e),pt({destroy(){cancelAnimationFrame(f),clearTimeout(Ne),nt(),bt.disconnect(),dn(),window.removeEventListener("resize",Ye),window.removeEventListener("orientationchange",Ye),clearTimeout(rt),Ct();},replay(){fe=-1,J=[],Q=-1,et=-1,c=false,j=false,he=0,w=false,se=0,Ve.clear(),clearTimeout(Ne),Qe(),ze=true,ht()&&tt();},pause(){w=true,nt();},resume(){w&&(w=false,ze=true,ht()&&tt());},seek(o){let l=Math.min(1,Math.max(0,o));se=l,fe=l,J=[],w=true,nt(),un(l,S),ze=true;},getProgress(){return se},refresh(){clearTimeout(rt),Ht(),ht()&&!w&&tt();}},()=>({tStart:oe,tEnd:Z}))}var Zt=new WeakMap,$n=0;function vt(e){return JSON.stringify(e,(t,n)=>{if(typeof n=="function")return "\u0192";if(typeof Element<"u"&&n instanceof Element){let r=Zt.get(n);return r===void 0&&Zt.set(n,r=++$n),`el#${r}`}return n})}function Et(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 kn(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Jt(e){let t=[],n=/([\w]+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let s=[],i=[],a=r[2].trim();if(a)for(let m of a.split(/[\s,]+/)){let p=m.match(/^([-+]?[\d.eE]+)(.*)$/);s.push(p?parseFloat(p[1]):0),i.push(p?p[2]:"");}t.push({fn:r[1],nums:s,units:i});}return t}function In(e,t,n){let r=Jt(e),s=Jt(t);return r.length===0||r.length!==s.length?n<1?e:t:r.map((i,a)=>{let m=s[a];return i.fn!==m.fn||i.nums.length!==m.nums.length?n<1?`${i.fn}(${i.nums.map((p,y)=>`${p}${i.units[y]}`).join(", ")})`:`${m.fn}(${m.nums.map((p,y)=>`${p}${m.units[y]}`).join(", ")})`:`${i.fn}(${i.nums.map((p,y)=>`${p+(m.nums[y]-p)*n}${i.units[y]}`).join(", ")})`}).join(" ")}function en(e,t,n){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*n);let r=String(e),s=String(t);if(kn(r))return it(r,s,n);if(r.includes("("))return In(r,s,n);let i=r.match(/^([-+]?[\d.]+)(.*)$/),a=s.match(/^([-+]?[\d.]+)(.*)$/);if(i&&a){let m=parseFloat(i[1]),p=parseFloat(a[1]);return `${m+(p-m)*n}${i[2]||a[2]}`}return n<1?r:s}function On(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var Rn=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Dn=0,tn="--scroll-draw-progress";function Fn(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}var rn={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function St(e,t){return typeof window>"u"?rn:t.respectReducedMotion===false?nn(e,t,false):_e(t,(n,r)=>nn(e,n,r))}function nn(e,t,n){let{props:r,trigger:s={},easing:i="ease-out",speed:a=1,once:m=false,axis:p="y",scrollContainer:y,native:E=true,velocityScale:F=false,triggerElement:S,onProgress:Y,onComplete:te,onEnter:L,onLeave:ne,onEnterBack:we,onLeaveBack:P}=t,O=typeof i=="function"?i:ee[i]??ee["ease-out"],$=de(s.start||"top bottom"),A=de(s.end||"bottom top"),b=S??e,h=typeof y=="string"?document.querySelector(y):y??null,v=Object.entries(r).map(([c,f])=>({prop:On(c),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function G(){let c=window.getComputedStyle(e);for(let f of v)f.from===""&&(f.from=c.getPropertyValue(f.prop).trim()||"0");}function _(){for(let c of v)e.style.setProperty(c.prop,String(c.to));}let q=new Map;for(let c of [...v.map(f=>f.prop),tn])q.set(c,e.style.getPropertyValue(c));function N(){for(let[c,f]of q)f?e.style.setProperty(c,f):e.style.removeProperty(c);}if(n)return _(),te?.(),{...rn,destroy:N,getProgress:()=>1};G();let R=()=>h?p==="x"?h.scrollLeft:h.scrollTop:p==="x"?window.scrollX:window.scrollY,re=()=>h?p==="x"?h.clientWidth:h.clientHeight:p==="x"?window.innerWidth:window.innerHeight,Te=typeof i=="string"?at(i):null;function ce(){if(!E||!Fn()||!Te||p!=="y"||h||b!==e||m||a!==1||Y||te||L||ne||we||P||F!==false||(s.start||"top bottom").trim()!=="top bottom"||(s.end||"bottom top").trim()!=="bottom top")return false;for(let c of v)if(!Rn.has(c.prop))return false;return true}function H(){let c=`ssd-a-${++Dn}`,f=v.map(w=>`${w.prop}:${w.from}`).join(";"),Ae=v.map(w=>`${w.prop}:${w.to}`).join(";"),fe=document.createElement("style");fe.setAttribute("data-ssd-animate",""),fe.textContent=`@keyframes ${c}{from{${f}}to{${Ae}}}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${Te};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(fe),e.classList.add(c);let J=()=>{let w=e.getBoundingClientRect();return Le({top:w.top,height:w.height},R(),re(),$,A)};Ce(e,{type:"animate",getProgress:()=>Q.getProgress(),getTrigger:J});let Q={refresh(){},destroy(){e.classList.remove(c),fe.remove(),e.style.animationPlayState="",N(),Pe(e);},replay(){e.classList.remove(c),e.offsetWidth,e.classList.add(c);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(w){let se=Math.min(1,Math.max(0,w));e.classList.remove(c);for(let he of v)e.style.setProperty(he.prop,en(he.from,he.to,se));},getProgress(){let{tStart:w,tEnd:se}=J();return O(U(R(),w,se,a))}};return Q}if(ce())return H();let k=0,I=0,u=0,d=NaN,X=false,xe=-1,V=0,K=0,$e=false,x=NaN,T=-1,ue=0,me=b===e?v:[],ke=false;function Oe(){let c=e.style,f=me.map(Q=>c.getPropertyValue(Q.prop)),Ae=c.transition;me.length&&(c.transition="none"),me.forEach(Q=>c.setProperty(Q.prop,q.get(Q.prop)??""));let fe=ot(b,h,p);me.forEach((Q,w)=>c.setProperty(Q.prop,f[w])),me.length&&(e.offsetWidth,c.transition=Ae);let J=Le(fe,fe.scroll,re(),$,A);ke&&Math.abs(J.tStart-k)<1&&Math.abs(J.tEnd-I)<1||(ke=true,k=J.tStart,I=J.tEnd);}function Me(c){e.style.setProperty(tn,String(c));for(let f of v)e.style.setProperty(f.prop,en(f.from,f.to,c));Y?.(c);}function He(c){if(isNaN(x)){x=c;return}x<=0&&c>0?L?.():x>0&&c<=0&&P?.(),x<1&&c>=1?ne?.():x>=1&&c<1&&we?.(),x=c;}let Re=c=>U(c,k,I,Math.min(a,1));function D(){!u&&!X&&Re(R())!==d&&(u=requestAnimationFrame(ye));}function ye(){if(X)return;let c=performance.now(),f=R(),Ae=a;if(F!==false){let w=c-ue,se=w>0?Math.abs(f-(T<0?f:T))/w:0;Ae=a*Math.max(.2,1+se*(typeof F=="number"?F:1)*.04);}T=f,ue=c;let fe=I===k?0:(f-k)/(I-k);He(fe);let J=U(f,k,I,Ae),Q=m?Math.max(xe,O(V=Math.max(V,J))):O(J);K=Q,Me(Q),Q>=1&&!$e?($e=true,te?.()):Q<1&&!m&&($e=false),!X&&(d=Re(f),u=d>0&&d<1?requestAnimationFrame(ye):0);}Oe(),I===k&&ge("scrollAnimate: zero-length trigger window, so it never animates. In a sticky stage, set triggerElement.",e),V=U(R(),k,I,a),K=O(V),Me(K);function ve(){Oe(),D();}let oe;function Z(){clearTimeout(oe),oe=setTimeout(ve,150);}let We=h??window;We.addEventListener("scroll",D,{passive:true}),window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z);let Je=Ie([b],Z);D(),Ce(e,{type:"animate",getProgress:()=>K,getTrigger:()=>({tStart:k,tEnd:I})});function j(){X=true,cancelAnimationFrame(u),u=0,d=NaN;}return {destroy(){j(),We.removeEventListener("scroll",D),window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z),Je(),clearTimeout(oe),N(),Pe(e);},replay(){xe=-1,V=0,$e=false,K=0,X=false,Me(0),d=0,D();},pause:j,resume(){X&&(X=false,D());},seek(c){let f=Math.min(1,Math.max(0,c));K=f,xe=f,V=0,j(),Me(f);},getProgress(){return K},refresh:ve}}var Tt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function xt(e,t){if(typeof window>"u")return Tt;let n=typeof e=="string"?document.querySelector(e):e;return n?_e(t,(r,s)=>Hn(n,r,s)):(ge("scrollCounter: element not found:",e),Tt)}function Hn(e,t,n){let{from:r=0,to:s,format:i,easing:a="ease-out",trigger:m={},once:p=true,decimals:y,onComplete:E}=t,F=y!==void 0?u=>u.toFixed(y):i??(u=>String(Math.round(u))),S=typeof a=="function"?a:ee[a]??ee["ease-out"],Y=de(m.start||"top 80%"),te=de(m.end||"top 20%");if(n)return e.textContent=F(s),E?.(),{...Tt,getProgress:()=>1};let L=0,ne=0,we=false,P=0,O=false,$=false,A=-1,b=0,h=0,v=false,G=()=>window.scrollY,_=()=>window.innerHeight;function q(){let u=e.getBoundingClientRect(),d=Le({top:u.top,height:u.height},G(),_(),Y,te);we&&Math.abs(d.tStart-L)<1&&Math.abs(d.tEnd-ne)<1||(we=true,L=d.tStart,ne=d.tEnd);}let N=e.style.getPropertyValue("--scroll-draw-progress");function R(u){e.textContent=F(r+(s-r)*u),e.style.setProperty("--scroll-draw-progress",String(u));}function re(){if(!O||$)return;let u=U(G(),L,ne,1),d=p?Math.max(A,S(b=Math.max(b,u))):S(u);h=d,R(d),d>=1&&!v?(v=true,E?.()):d<1&&!p&&(v=false),P=requestAnimationFrame(re);}q();{b=U(G(),L,ne,1);let u=S(b);h=u,R(u);}let Te=new IntersectionObserver(u=>{u.forEach(d=>{O=d.isIntersecting,O&&!$?P=requestAnimationFrame(re):cancelAnimationFrame(P);});}),ce;function H(){clearTimeout(ce),ce=setTimeout(q,150);}window.addEventListener("resize",H),window.addEventListener("orientationchange",H);let k=Ie([e],H);Te.observe(e),Ce(e,{type:"counter",getProgress:()=>h,getTrigger:()=>({tStart:L,tEnd:ne})});function I(){$&&($=false,O&&(P=requestAnimationFrame(re)));}return {destroy(){cancelAnimationFrame(P),Te.disconnect(),window.removeEventListener("resize",H),window.removeEventListener("orientationchange",H),k(),clearTimeout(ce),e.style.setProperty("--scroll-draw-progress",N),Pe(e);},replay(){A=-1,b=0,v=false,h=0,R(0),I();},pause(){$=true,cancelAnimationFrame(P);},resume:I,seek(u){let d=Math.min(1,Math.max(0,u));h=d,A=d,b=0,$=true,cancelAnimationFrame(P),R(d);},getProgress(){return h}}}var on={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Mt(e,t={}){if(typeof window>"u")return on;let n=typeof e=="string"?document.querySelector(e):e;if(!n||n.tagName.toLowerCase()!=="video")return ge("scrollVideo: <video> element not found:",e),on;let r=n,{trigger:s={},easing:i="linear",once:a=false,axis:m="y",preload:p="auto",triggerElement:y,onReady:E,onComplete:F,onProgress:S}=t,Y=y??r,te=window.matchMedia("(prefers-reduced-motion: reduce)").matches,L=typeof i=="function"?i:ee[i]??ee.linear,ne=de(s.start||"top top"),we=de(s.end||"bottom top");r.pause(),r.hasAttribute("preload")||(r.preload=p);let P=t.from??0,O=t.to,$=0,A=0,b=0,h=false,v=false,G=-1,_=0,q=0,N=false,R=false,re=()=>m==="x"?window.scrollX:window.scrollY,Te=()=>m==="x"?window.innerWidth:window.innerHeight;function ce(){let x=Y.getBoundingClientRect(),T=m==="x"?x.left:x.top,ue=m==="x"?x.width:x.height,me=Le({top:T,height:ue},re(),Te(),ne,we);$=me.tStart,A=me.tEnd,R&&A===$&&ge("scrollVideo: zero-length trigger window, so it never scrubs. In a sticky stage, set triggerElement.",r);}let H=NaN;function k(x){if(!R)return;let T=O??r.duration??0,ue=P+(T-P)*x;ue!==H&&(H=ue,r.currentTime=ue),r.style.setProperty("--scroll-draw-progress",String(x)),S?.(x);}function I(){if(!h||v||!R||te)return;let x=U(re(),$,A,1),T=a?Math.max(G,L(_=Math.max(_,x))):L(x);q=T,k(T),T>=1&&!N?(N=true,F?.()):T<1&&!a&&(N=false),b=requestAnimationFrame(I);}function u(){if(R=true,O===void 0&&(O=r.duration),te){k(1),E?.();return}ce(),E?.(),v?k(q):h&&(b=requestAnimationFrame(I));}r.readyState>=1?u():r.addEventListener("loadedmetadata",u,{once:true}),R||ce();let d=te?()=>{}:ut(x=>{x&&(d(),te=true,cancelAnimationFrame(b),k(1));}),X=new IntersectionObserver(x=>{x.forEach(T=>{h=T.isIntersecting,h&&!v&&R?b=requestAnimationFrame(I):cancelAnimationFrame(b);});}),xe;function V(){clearTimeout(xe),xe=setTimeout(ce,150);}window.addEventListener("resize",V),window.addEventListener("orientationchange",V);let K=Ie([Y],V);X.observe(r),Ce(r,{type:"video",getProgress:()=>q,getTrigger:()=>({tStart:$,tEnd:A})});function $e(){v&&(v=false,h&&R&&(b=requestAnimationFrame(I)));}return {destroy(){cancelAnimationFrame(b),X.disconnect(),r.removeEventListener("loadedmetadata",u),window.removeEventListener("resize",V),window.removeEventListener("orientationchange",V),K(),d(),clearTimeout(xe),Pe(r);},replay(){G=-1,_=0,N=false,q=0,H=NaN,k(0),$e();},pause(){v=true,cancelAnimationFrame(b);},resume:$e,seek(x){let T=Math.min(1,Math.max(0,x));q=T,G=T,_=0,v=true,cancelAnimationFrame(b),H=NaN,k(T);},getProgress(){return q}}}function sn(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 mt(e=""){let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=e,t}function ln(e){let t=e.textContent??"";return e.textContent="",t.split(/(\s+)/).filter(Boolean).map(n=>{let r=e.appendChild(mt(n)),s=/^\s+$/.test(n);return s?r.style.whiteSpace="pre":r.style.display="inline-block",s?null:r}).filter(n=>n!==null)}function Nn(e){let t=e.textContent??"";e.textContent="";let n=[],r=null;for(let s of t){let i=mt(s),a=s===" ";a?i.style.whiteSpace="pre":(i.style.display="inline-block",n.push(i)),a||s>"\u0DFF"?r=null:r||(r=e.appendChild(mt()),r.style.cssText="display:inline-block;white-space:nowrap"),(r??e).appendChild(i);}return n}function an(e){let t=ln(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),m=mt();m.style.display="inline-block",a.forEach((p,y)=>{let E=p.nextElementSibling;m.appendChild(p),y<a.length-1&&E&&E.style.whiteSpace==="pre"&&m.appendChild(E);}),r.push(m);}return e.textContent="",r.forEach((i,a)=>{e.appendChild(i),a<r.length-1&&e.appendChild(document.createTextNode(" "));}),r}function Vn(e,t,n,r){if(n<=1||r===0)return e;r=Math.min(r,1/n);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 zn(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 Lt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function At(e,t={}){if(typeof window>"u")return Lt;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return ge("scrollText: element not found:",e),Lt;let r=n;return _e(t,(s,i)=>_n(r,s,i))}function _n(e,t,n){let{split:r="words",stagger:s=.04,easing:i="ease-out",from:a={opacity:0,y:24},trigger:m={},once:p=true,onComplete:y}=t,E=typeof i=="function"?i:ee[i]??ee["ease-out"],F=de(m.start||"top 85%"),S=de(m.end||"top 40%"),Y=e.innerHTML,te=e.textContent??"",L;r==="chars"?L=Nn(e):r==="lines"?L=an(e):L=ln(e),sn(e,te);let ne=L.length;function we(u,d){a?.opacity!==void 0&&(u.style.opacity=String(a.opacity+(1-a.opacity)*d));let X=zn(d,a);X&&(u.style.transform=X);}function P(u){e.style.setProperty("--scroll-draw-progress",String(u)),L.forEach((d,X)=>{let xe=E(Vn(u,X,ne,s));we(d,xe);});}if(n)return P(1),y?.(),{...Lt,destroy:()=>{e.innerHTML=Y;},getProgress:()=>1};P(0);let O=0,$=0,A=0,b=false,h=false,v=-1,G=0,_=false,q=()=>window.scrollY,N=()=>window.innerHeight;function R(){let u=e.getBoundingClientRect(),d=Le({top:u.top,height:u.height},q(),N(),F,S);O=d.tStart,$=d.tEnd;}function re(){if(!b||h)return;let u=U(q(),O,$,1);p&&(v=Math.max(v,u),u=v),G=u,P(u),u>=1&&!_?(_=true,y?.()):u<1&&!p&&(_=false),A=requestAnimationFrame(re);}R();let Te=new IntersectionObserver(u=>{u.forEach(d=>{b=d.isIntersecting,b&&!h?A=requestAnimationFrame(re):cancelAnimationFrame(A);});}),ce;function H(){clearTimeout(ce),ce=setTimeout(()=>{if(r==="lines"){let u=G;e.innerHTML=Y,L=an(e),sn(e,te),P(u);}R();},150);}window.addEventListener("resize",H),window.addEventListener("orientationchange",H);let k=Ie([e],H);Te.observe(e),Ce(e,{type:"text",getProgress:()=>G,getTrigger:()=>({tStart:O,tEnd:$})});function I(){h&&(h=false,b&&(A=requestAnimationFrame(re)));}return {destroy(){cancelAnimationFrame(A),Te.disconnect(),window.removeEventListener("resize",H),window.removeEventListener("orientationchange",H),k(),clearTimeout(ce),e.innerHTML=Y,Pe(e);},replay(){v=-1,_=false,G=0,P(0),I();},pause(){h=true,cancelAnimationFrame(A);},resume:I,seek(u){let d=Math.min(1,Math.max(0,u));G=d,v=d,h=true,cancelAnimationFrame(A),P(d);},getProgress(){return G}}}function Ze(e,t,n){let r=t,s=vt(t),i=n(e,Et(t,()=>r));return {update(a){r=a;let m=vt(a);m!==s&&(s=m,i.destroy(),i=n(e,Et(a,()=>r)));},destroy(){i.destroy();}}}function eo(e,t={}){return Ze(e,t,wt)}function to(e={}){let t=null;function n(r){return t=wt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function no(e,t){return Ze(e,t,St)}function ro(e){let t=null;function n(r){return t=St(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function oo(e,t){return Ze(e,t,xt)}function so(e){let t=null;function n(r){return t=xt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function io(e,t={}){return Ze(e,t,Mt)}function ao(e={}){let t=null;function n(r){return t=Mt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function lo(e,t={}){return Ze(e,t,At)}function co(e={}){let t=null;function n(r){return t=At(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}exports.createScrollAnimate=ro;exports.createScrollCounter=so;exports.createScrollDraw=to;exports.createScrollText=co;exports.createScrollVideo=ao;exports.scrollAnimate=no;exports.scrollCounterAction=oo;exports.scrollDraw=eo;exports.scrollTextAction=lo;exports.scrollVideoAction=io;
|
|
1
|
+
'use strict';function gn({tension:e=2.5,friction:t=2.2}={}){return n=>1-Math.cos(n*Math.PI*e)*Math.pow(1-n,t)}function yn({bounces:e=3,decay:t=.5}={}){let n=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,t)),o=Math.sqrt(r),s=0,a=[];for(let p=0;p<n;p++){let g=Math.pow(o,p);a.push(g),s+=g;}let u=[0],f=0;for(let p=0;p<n;p++)f+=a[p]/s,u.push(f);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let g=0;g<n;g++)if(p<=u[g+1]){let x=(p-u[g])/(u[g+1]-u[g]);if(g===0)return x*(2-x);let y=1-Math.pow(r,g);return y+(1-y)*(2*x-1)*(2*x-1)}return 1}}function hn({amplitude:e=1,period:t=.4}={}){let n=Math.max(1,e),r=Math.max(.1,t),o=n<=1?r/4:r/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-o)*(2*Math.PI)/r)+1}var ee={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:gn(),bounce:yn(),elastic:hn()};function qe(e,t,n){return Math.min(n,Math.max(t,e))}function ie(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}}var Ft=(e,t)=>e==="top"?0:e==="center"?.5:e==="bottom"?1:t;function Rt(e,t,n,r){return e+n+t*Ft(r,0)}function Vt(e,t){return t*(/^\d+(\.\d+)?%$/.test(e)?parseFloat(e)/100:Ft(e,1))}function B(e,t,n,r){return n===t?0:qe((e-t)/(n-t)*r,0,1)}function we(e,t,n,r,o){let s=Rt(e.top,e.height,t,r.element)-Vt(r.viewport,n),a=Rt(e.top,e.height,t,o.element)-Vt(o.viewport,n);return {tStart:s,tEnd:a}}function et(e,t,n){let r=e.getBoundingClientRect(),o=n==="x"?r.width:r.height;return t?{top:n==="x"?r.left-t.getBoundingClientRect().left-t.clientLeft+t.scrollLeft:r.top-t.getBoundingClientRect().top-t.clientTop+t.scrollTop,height:o,scroll:0}:{top:n==="x"?r.left:r.top,height:o,scroll:n==="x"?window.scrollX:window.scrollY}}function tt(e){let t=parseFloat(e.getAttribute("pathLength")??"");if(t>0)return t;let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function _t(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 nt(e,t,n){let r=_t(e),o=_t(t);return !r||!o?e:`rgb(${Math.round(r[0]+(o[0]-r[0])*n)},${Math.round(r[1]+(o[1]-r[1])*n)},${Math.round(r[2]+(o[2]-r[2])*n)})`}var Wt={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 ze=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function ae(e,...t){ze&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var bn="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",wn="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",zt=33;function vn(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function En(e){let t=[];for(let n=0;n<zt;n++){let r=n/(zt-1);t.push(String(Math.round(e(r)*1e5)/1e5));}return `linear(${t.join(",")})`}function rt(e){switch(e){case "linear":return "linear";case "ease-in":return bn;case "ease-out":return wn;case "ease-in-out":return vn()?En(ee["ease-in-out"]):null;default:return null}}var Gt=Symbol.for("svg-scroll-draw.registry");function Bt(){let e=globalThis;return e[Gt]||(e[Gt]=new Map)}function ve(e,t){Bt().set(e,t);}function Ee(e){Bt().delete(e);}function ot(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),n=o=>e(!!o.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 Ne(e,t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t(e,true);let n=t(e,false),r=ot(s=>{if(!s)return;r();let a=(n.getProgress?.()??0)>=1;n.destroy(),n=t(a?{...e,onComplete:void 0}:e,true);}),o={};for(let s of Object.keys(n))o[s]=(...a)=>n[s]?.(...a);return o.destroy=()=>{r(),n.destroy();},o}var Qe,st=new Set,it=new WeakMap,Ye=new Map,jt=e=>{let t=e.getBoundingClientRect();return t.width+" "+t.height};function Sn(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 qt(e,t){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let n=()=>t();Qe??(Qe=new ResizeObserver(o=>{let s=false;for(let{target:a}of o)it.get(a)!==jt(a)&&(s=true),it.set(a,"");s&&st.forEach(a=>a());})),st.add(n);let r=Sn(e);return [document.body,document.documentElement].forEach(o=>o&&r.add(o)),r.forEach(o=>{it.has(o)||it.set(o,jt(o)),Ye.set(o,(Ye.get(o)??0)+1),Qe.observe(o);}),()=>{st.delete(n)&&(r.forEach(o=>{let s=(Ye.get(o)??1)-1;if(s)return void Ye.set(o,s);Ye.delete(o),Qe?.unobserve(o);}),st.size||(Qe?.disconnect(),Qe=void 0));}}function Me(e,t,n,r,o){let s,a=NaN,u,f,p=()=>{s=0,r(),!u&&!s&&(a=n())>0&&a<1&&(s=requestAnimationFrame(p));},g=()=>{!s&&!u&&n()!==a&&(s=requestAnimationFrame(p));},x=H=>{u=H,cancelAnimationFrame(s),s=a=NaN,g();},y=()=>{clearTimeout(f),o(),g();},I=()=>{clearTimeout(f),f=setTimeout(y,150);},j=qt(t,I),w=H=>{e[H]("scroll",g,{passive:true}),window[H]("resize",I),window[H]("orientationchange",I);};return w("addEventListener"),g(),{hold:x,remeasure:y,off(){x(true),w("removeEventListener"),j(),clearTimeout(f);}}}var Tn=0;function xn(){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 Yt=new Set(["","none","transparent","rgba(0, 0, 0, 0)"]);function Mn(e){if(!ze)return;let t=Qt(e,"stroke");if(!t||t==="none"){ae("Element has no stroke \u2014 path will not be visible.",e);return}let n=(e.getAttribute("fill")??"").trim();n&&!Yt.has(n)&&!Yt.has(Qt(e,"fill"))&&ae("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ln(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 o(){let s=n==="x"?window.scrollX:window.scrollY,a=e-s,u=t-s,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",o,{passive:true}),o(),{el:r,destroy(){window.removeEventListener("scroll",o),r.remove();}}}var Ut=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Xt=/[MmLlHhVvCcSsQqTtAaZz]/g;function An(e,t,n){if(!ze)return;let r=(e.match(Xt)??[]).join("").toUpperCase(),o=(t.match(Xt)??[]).join("").toUpperCase(),s=(e.match(Ut)??[]).length,a=(t.match(Ut)??[]).length;if(r!==o){ae(`morphTo: command sequence differs (${r||"\u2205"} \u2192 ${o||"\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!==a&&ae(`morphTo: coordinate count differs (${s} \u2192 ${a}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,n);}function Cn(e,t,n){let r=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),o=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let a=parseFloat(s),u=r[o++]??a;return String(+(a+(u-a)*n).toFixed(4))})}function gt(e,t={}){return typeof window>"u"?{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0}:Ne(t,(n,r)=>Pn(e,n,r))}function Pn(e,t,n){let{preset:r,...o}=t,s=r?{...Wt[r],...o}:o,{selector:a="path, polyline, line, polygon, rect, circle",speed:u=1,fade:f=false,easing:p="linear",trigger:g={},stagger:x=0,direction:y="forward",once:I=false,debug:j=false,axis:w="y",scrollContainer:H,autoReverse:ue=false,delay:D=0,strokeColor:M,strokeWidth:A,fillOpacity:$,waypoints:v,velocityScale:C=false,threshold:N=0,rootMargin:te="0px",repeat:q=0,repeatDelay:V=0,morphTo:R,clip:E,autoplay:Y=false,duration:h=1e3,native:P=true,onProgress:Se,onStart:U,onComplete:_,onEnter:fe,onLeave:Te,onEnterBack:ge,onLeaveBack:me}=s,b=E===true?"left":typeof E=="string"?E:false,S=typeof p=="function"?p:ee[p]??ee.linear,ye=ie(g.start||"top bottom"),Ie=ie(g.end||"bottom top"),X=typeof H=="string"?document.querySelector(H):H??null,Le=Array.isArray(M)?M[0]:null,Ae=Array.isArray(M)?M[1]:typeof M=="string"?M:null,he=Array.isArray(A)?A[0]:null,He=Array.isArray(A)?A[1]:typeof A=="number"?A:null,Ce=Array.isArray($)?$[0]:null,be=Array.isArray($)?$[1]:typeof $=="number"?$:null;function Pe(i){let c=i*100;switch(b){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(${i*150}% at 50% 50%)`;default:return `inset(0 ${100-c}% 0 0)`}}let l=b?[]:Array.from(e.querySelectorAll(a)),m=[],K=[],k=0,F=0,Q=x,W=0,De=0,Z=false,$e=false,ke=0,lt=-1,Xe=[],Ke=-1,pe=false,xe=0,Re=0,Ve,ct=false,ut=null;function xt(){ut?.destroy(),ut=null;}let Fe=new Set,Mt=NaN,_e=true,Ze=-1,Lt=performance.now(),We=NaN;function Je(){return X?w==="x"?X.scrollLeft:X.scrollTop:w==="x"?window.scrollX:window.scrollY}function At(){return X?w==="x"?X.clientWidth:X.clientHeight:w==="x"?window.innerWidth:window.innerHeight}function Ct(){let i=et(e,X,w);return we(i,i.scroll,At(),ye,Ie)}function ln(){let i=F-k,c=l.length-1,d=X??document.documentElement,L=w==="x"?"Width":"Height";if(Q=x,x>0&&c>0&&i>0){let ne=d[`scroll${L}`]-d[`client${L}`]-1-k-i/u;ne>=0&&(Q=Math.min(x,ne/(c*i)));}let J=Math.max(0,c)*Q*i,le=i/Math.min(u,1);W=k+Math.min(0,J,le,J+le),De=k+Math.max(0,J,le,J+le);}function Pt(){(({tStart:k,tEnd:F}=Ct())),ln(),j&&ze&&(xt(),ut=Ln(k,F,w));}function ft(i,c=Ct){ve(e,{type:"draw",getProgress:()=>i.getProgress(),getTrigger:c});let d=i.destroy;return i.destroy=()=>{d.call(i),Ee(e);},i}function $t(i,c){return I&&!ue?Math.max(lt,S(Xe[i]=Math.max(Xe[i]??0,c))):S(c)}function cn(i,c){if(e.style.setProperty("--scroll-draw-progress",String(i)),b){let d=c==="reverse"?1-i:i;e.style.clipPath=Pe(d);return}l.forEach((d,L)=>mt(d,L,i,c));}function mt(i,c,d,L){i.style.strokeDashoffset=L==="reverse"?`${m[c]*d}`:`${m[c]*(1-d)}`,f&&(i.style.opacity=L==="reverse"?`${1-d}`:`${d}`),Le&&Ae?i.style.stroke=nt(Le,Ae,d):Ae&&(i.style.stroke=Ae),he!==null&&He!==null?i.style.strokeWidth=`${he+(He-he)*d}`:He!==null&&(i.style.strokeWidth=`${He}`),Ce!==null&&be!==null?i.style.fillOpacity=`${Ce+(be-Ce)*d}`:be!==null&&(i.style.fillOpacity=`${be}`),R&&i.tagName.toLowerCase()==="path"&&K[c]&&i.setAttribute("d",Cn(K[c],R,d));}function pt(){if(e.style.setProperty("--scroll-draw-progress","0"),b){e.style.clipPath=Pe(y==="reverse"?1:0);return}l.forEach((i,c)=>{i.style.strokeDasharray=`${m[c]}`,i.style.strokeDashoffset=y==="reverse"?"0":`${m[c]}`,f?i.style.opacity=y==="reverse"?"1":"0":i.style.opacity="",Le&&(i.style.stroke=Le),he!==null&&(i.style.strokeWidth=`${he}`),Ce!==null&&(i.style.fillOpacity=`${Ce}`),R&&i.tagName.toLowerCase()==="path"&&K[c]&&i.setAttribute("d",K[c]);});}function Ge(i,c){let d=i.getAttribute("d"),L=tt(i);if(R&&K[c]){i.setAttribute("d",R);let J=tt(i);i.setAttribute("d",K[c]),L=Math.max(tt(i),J),i.setAttribute("d",d);}m[c]=L,i.style.strokeDasharray=`${L}`;}if(l.forEach((i,c)=>{Mn(i);let d=i.tagName.toLowerCase()==="path";d?K.push(i.getAttribute("d")??""):K.push(""),Ge(i,c);let L=m[c];R&&(d?An(K[K.length-1],R,i):ae(`morphTo only applies to <path> elements \u2014 ignored on <${i.tagName}>.`,i)),n?(i.style.strokeDashoffset=y==="reverse"?`${L}`:"0",f&&(i.style.opacity="1"),Ae&&(i.style.stroke=Ae),He!==null&&(i.style.strokeWidth=`${He}`),be!==null&&(i.style.fillOpacity=`${be}`),R&&i.tagName.toLowerCase()==="path"&&i.setAttribute("d",R)):(i.style.strokeDashoffset=y==="reverse"?"0":`${L}`,f?i.style.opacity=y==="reverse"?"1":"0":i.style.opacity="",Le&&(i.style.stroke=Le),he!==null&&(i.style.strokeWidth=`${he}`),Ce!==null&&(i.style.fillOpacity=`${Ce}`));}),n)return b&&(e.style.clipPath=Pe(1)),_?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};b&&(e.style.clipPath=Pe(y==="reverse"?1:0));let kt=typeof p=="string"?rt(p):null;function un(){return !(P===false||Y||j&&ze||!xn()||!l.length||!kt||b||w!=="y"||X||u!==1||x!==0||I||ue||C!==false||R||v||q||D>0||Se||U||_||fe||Te||ge||me||M!=null||A!=null||$!=null||(g.start||"top bottom").trim()!=="top bottom"||(g.end||"bottom top").trim()!=="bottom top")}function fn(){let i=++Tn,c=`svg-scroll-draw-${i}`,d=`svg-scroll-draw-host-${i}`,L=`--svg-scroll-draw-${i}`,J=y==="reverse"?"0":"var(--ssd-len)",le=y==="reverse"?"var(--ssd-len)":"0",ne=`stroke-dashoffset:${J};`,z=`stroke-dashoffset:${le};`;f&&(ne+=`opacity:${y==="reverse"?1:0};`,z+=`opacity:${y==="reverse"?0:1};`);let G=document.createElement("style");G.setAttribute("data-svg-scroll-draw",""),G.textContent=`@keyframes ${c}{from{${ne}}to{${z}}}.${d}{view-timeline-name:${L};view-timeline-axis:block;}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${kt};animation-fill-mode:both;animation-timeline:${L};animation-range:cover 0% cover 100%;}`,document.head.appendChild(G),e.classList.add(d);function se(T,O){T.style.setProperty("--ssd-len",String(m[O])),T.style.strokeDasharray=`${m[O]}`,T.style.strokeDashoffset="",T.style.opacity="",T.style.animationPlayState="",T.classList.add(c);}l.forEach(se);let re=false,ce=-1;function de(){if(ce>=0)return ce;let T=e.getBoundingClientRect(),{tStart:O,tEnd:oe}=we({top:T.top,height:T.height},Je(),At(),ye,Ie);return S(B(Je(),O,oe,u))}return {destroy(){e.classList.remove(d),l.forEach(T=>{T.classList.remove(c),T.style.removeProperty("--ssd-len"),T.style.animationPlayState="";}),G.remove();},replay(){re=false,ce=-1,l.forEach(se);},pause(){re=true,l.forEach(T=>{T.style.animationPlayState="paused";});},resume(){re&&(re=false,l.forEach(T=>{T.style.animationPlayState="running";}));},seek(T){let O=Math.min(1,Math.max(0,T));ce=O,re=true,l.forEach((oe,Oe)=>{oe.classList.remove(c),oe.style.strokeDashoffset=y==="reverse"?`${m[Oe]*O}`:`${m[Oe]*(1-O)}`,f&&(oe.style.opacity=y==="reverse"?`${1-O}`:`${O}`);});},getProgress(){return de()},refresh(){l.forEach((T,O)=>{Ge(T,O),T.style.setProperty("--ssd-len",String(m[O]));});}}}if(un())return ft(fn());function mn(){let i=Math.max(1,h),c=b?i:i*(1+Math.max(0,l.length-1)*x),d=0,L=0,J=false;function le(ce){let de=true,T=Math.min(1,Math.max(0,ce/c));if(b){let O=Math.min(1,Math.max(0,ce/i)),oe=S(O);xe=oe,e.style.setProperty("--scroll-draw-progress",String(oe)),e.style.clipPath=Pe(y==="reverse"?1-oe:oe),Se?.(oe),O<1&&(de=false);}else {l.forEach((oe,Oe)=>{let dn=Oe*x*i,Nt=Math.min(1,Math.max(0,(ce-dn)/i));mt(oe,Oe,S(Nt),y),Nt<1&&(de=false);});let O=S(T);xe=O,Se?.(O),e.style.setProperty("--scroll-draw-progress",String(O));}if(v){let O=S(T);for(let oe in v){let Oe=parseFloat(oe);O>=Oe&&!Fe.has(Oe)&&(Fe.add(Oe),v[oe]?.());}}return de}function ne(ce){if(pe)return;let de=ce-d;$e||($e=true,U?.());let T=le(de);if(T&&!Z){Z=true,le(c),_?.(),Re<(q==="infinite"?1/0:q??0)&&(Re++,Ve=setTimeout(()=>{d=performance.now(),$e=false,Z=false,Fe.clear(),pt(),ke=requestAnimationFrame(ne);},V));return}T||(ke=requestAnimationFrame(ne));}function z(){cancelAnimationFrame(ke),clearTimeout(Ve),d=performance.now(),L=0,pe=false,$e=false,Z=false,Re=0,J=true,xe=0,Fe.clear(),pt(),ke=requestAnimationFrame(ne);}let G=new IntersectionObserver(ce=>{ce.forEach(de=>{de.isIntersecting&&!(I&&Z)?z():!de.isIntersecting&&!I&&!Z&&(cancelAnimationFrame(ke),clearTimeout(Ve),J=false);});},{root:X??null,threshold:N,rootMargin:te}),se;function re(){clearTimeout(se),se=setTimeout(()=>l.forEach(Ge),150);}return window.addEventListener("resize",re),window.addEventListener("orientationchange",re),D>0?setTimeout(()=>G.observe(e),D):G.observe(e),{destroy(){cancelAnimationFrame(ke),clearTimeout(Ve),G.disconnect(),window.removeEventListener("resize",re),window.removeEventListener("orientationchange",re),clearTimeout(se);},replay(){Re=0,z();},pause(){pe||!J||(pe=true,L=performance.now()-d,cancelAnimationFrame(ke));},resume(){pe&&(pe=false,J=true,d=performance.now()-L,ke=requestAnimationFrame(ne));},seek(ce){let de=Math.min(1,Math.max(0,ce));xe=de,pe=true,L=de*c,d=performance.now()-L,cancelAnimationFrame(ke),le(L);},getProgress(){return xe},refresh(){clearTimeout(se),l.forEach(Ge);}}}if(Y)return ft(mn());Pt();let Ot=()=>B(Je(),W,De,1);function It(){Z=true,_?.(),Re<(q==="infinite"?1/0:q)&&(Re++,Ve=setTimeout(()=>{ct=true;},V));}function Ht(){lt=-1,Xe=[],$e=false,Z=false,ct=false,Fe.clear(),pt(),_e=true;}function pn(){let i=performance.now(),c=Je();if(ct&&Ot()%1&&Ht(),!_e&&C===false&&c===Mt)return;_e=false,Mt=c;let d=u;if(C!==false){let z=i-Lt,G=z>0?Math.abs(c-(Ze<0?c:Ze))/z:0;d=u*Math.max(.2,1+G*(typeof C=="number"?C:1)*.04);}Ze=c,Lt=i;let L=ue?Ke===-1||c>=Ke?"forward":"reverse":y;Ke=c;let J=F-k,le=true,ne=J===0?0:(c-k)/J;if(isNaN(We)||(We<=0&&ne>0&&fe?.(),We<1&&ne>=1&&Te?.(),We>=1&&ne<1&&ge?.(),We>0&&ne<=0&&me?.()),We=ne,b){let z=$t(0,B(c,k,F,d));xe=z,e.style.setProperty("--scroll-draw-progress",String(z));let G=L==="reverse"?1-z:z;e.style.clipPath=Pe(G),Se?.(z),!$e&&B(c,k,F,d)>0&&($e=true,U?.()),z>=1&&!Z?It():z<1&&!I&&(Z=false);return}if(l.forEach((z,G)=>{let se=G*Q*J,re=$t(G,B(c,k+se,F+se,d));mt(z,G,re,L),G===0&&(xe=re,Se?.(re),e.style.setProperty("--scroll-draw-progress",String(re))),re<1&&(le=false);}),v){let z=S(B(c,k,F,d));for(let G in v){let se=parseFloat(G);z>=se&&!Fe.has(se)&&(Fe.add(se),v[G]?.());}}!$e&&B(c,k,F,d)>0&&($e=true,U?.()),le&&!Z?It():!le&&!I&&(Z=false);}let Be=Me(X??window,[e],Ot,pn,()=>{let i=m.join();l.forEach(Ge),Pt(),_e=true,m.join()!==i&&je();}),dt=D>0;function je(){Be.hold(pe||dt);}let Dt;return dt&&(Dt=setTimeout(()=>{dt=false,je();},D)),je(),ft({destroy(){clearTimeout(Ve),clearTimeout(Dt),Be.off(),xt();},replay(){Ht(),Ke=-1,Ze=-1,Re=0,pe=false,xe=0,clearTimeout(Ve),je();},pause(){pe=true,Be.hold(true);},resume(){pe&&(pe=false,_e=true,je());},seek(i){let c=Math.min(1,Math.max(0,i));xe=c,lt=c,Xe=[],pe=true,Be.hold(true),cn(c,y),_e=true;},getProgress(){return xe},refresh:Be.remeasure},()=>({tStart:k,tEnd:F}))}var Kt=new WeakMap,$n=0;function yt(e){return JSON.stringify(e,(t,n)=>{if(typeof n=="function")return "\u0192";if(typeof Element<"u"&&n instanceof Element){let r=Kt.get(n);return r===void 0&&Kt.set(n,r=++$n),`el#${r}`}return n})}function ht(e,t){let n={...e};for(let r of Object.keys(n))typeof n[r]=="function"&&(n[r]=(...o)=>t()[r]?.(...o));return n}function kn(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Zt(e){let t=[],n=/([\w]+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let o=[],s=[],a=r[2].trim();if(a)for(let u of a.split(/[\s,]+/)){let f=u.match(/^([-+]?[\d.eE]+)(.*)$/);o.push(f?parseFloat(f[1]):0),s.push(f?f[2]:"");}t.push({fn:r[1],nums:o,units:s});}return t}function On(e,t,n){let r=Zt(e),o=Zt(t);return r.length===0||r.length!==o.length?n<1?e:t:r.map((s,a)=>{let u=o[a];return s.fn!==u.fn||s.nums.length!==u.nums.length?n<1?`${s.fn}(${s.nums.map((f,p)=>`${f}${s.units[p]}`).join(", ")})`:`${u.fn}(${u.nums.map((f,p)=>`${f}${u.units[p]}`).join(", ")})`:`${s.fn}(${s.nums.map((f,p)=>`${f+(u.nums[p]-f)*n}${s.units[p]}`).join(", ")})`}).join(" ")}function Jt(e,t,n){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*n);let r=String(e),o=String(t);if(kn(r))return nt(r,o,n);if(r.includes("("))return On(r,o,n);let s=r.match(/^([-+]?[\d.]+)(.*)$/),a=o.match(/^([-+]?[\d.]+)(.*)$/);if(s&&a){let u=parseFloat(s[1]),f=parseFloat(a[1]);return `${u+(f-u)*n}${s[2]||a[2]}`}return n<1?r:o}function In(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var Hn=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Dn=0,en="--scroll-draw-progress";function Nn(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}var nn={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function bt(e,t){return typeof window>"u"?nn:t.respectReducedMotion===false?tn(e,t,false):Ne(t,(n,r)=>tn(e,n,r))}function tn(e,t,n){let{props:r,trigger:o={},easing:s="ease-out",speed:a=1,once:u=false,axis:f="y",scrollContainer:p,native:g=true,velocityScale:x=false,triggerElement:y,onProgress:I,onComplete:j,onEnter:w,onLeave:H,onEnterBack:ue,onLeaveBack:D}=t,M=typeof s=="function"?s:ee[s]??ee["ease-out"],A=ie(o.start||"top bottom"),$=ie(o.end||"bottom top"),v=y??e,C=typeof p=="string"?document.querySelector(p):p??null,N=Object.entries(r).map(([l,m])=>({prop:In(l),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function te(){let l=window.getComputedStyle(e);for(let m of N)m.from===""&&(m.from=l.getPropertyValue(m.prop).trim()||"0");}function q(){for(let l of N)e.style.setProperty(l.prop,String(l.to));}let V=new Map;for(let l of [...N.map(m=>m.prop),en])V.set(l,e.style.getPropertyValue(l));function R(){for(let[l,m]of V)m?e.style.setProperty(l,m):e.style.removeProperty(l);}if(n)return q(),j?.(),{...nn,destroy:R,getProgress:()=>1};te();let E=()=>C?f==="x"?C.scrollLeft:C.scrollTop:f==="x"?window.scrollX:window.scrollY,Y=()=>C?f==="x"?C.clientWidth:C.clientHeight:f==="x"?window.innerWidth:window.innerHeight,h=typeof s=="string"?rt(s):null;function P(){if(!g||!Nn()||!h||f!=="y"||C||v!==e||u||a!==1||I||j||w||H||ue||D||x!==false||(o.start||"top bottom").trim()!=="top bottom"||(o.end||"bottom top").trim()!=="bottom top")return false;for(let l of N)if(!Hn.has(l.prop))return false;return true}function Se(){let l=`ssd-a-${++Dn}`,m=N.map(W=>`${W.prop}:${W.from}`).join(";"),K=N.map(W=>`${W.prop}:${W.to}`).join(";"),k=document.createElement("style");k.setAttribute("data-ssd-animate",""),k.textContent=`@keyframes ${l}{from{${m}}to{${K}}}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${h};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(k),e.classList.add(l);let F=()=>{let W=e.getBoundingClientRect();return we({top:W.top,height:W.height},E(),Y(),A,$)};ve(e,{type:"animate",getProgress:()=>Q.getProgress(),getTrigger:F});let Q={refresh(){},destroy(){e.classList.remove(l),k.remove(),e.style.animationPlayState="",R(),Ee(e);},replay(){e.classList.remove(l),e.offsetWidth,e.classList.add(l);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(W){let De=Math.min(1,Math.max(0,W));e.classList.remove(l);for(let Z of N)e.style.setProperty(Z.prop,Jt(Z.from,Z.to,De));},getProgress(){let{tStart:W,tEnd:De}=F();return M(B(E(),W,De,a))}};return Q}if(P())return Se();let U=0,_=0,fe=false,Te=-1,ge=0,me=0,b=false,S=NaN,ye=-1,Ie=0,X=v===e?N:[],Le=false;function Ae(){let l=e.style,m=X.map(Q=>l.getPropertyValue(Q.prop)),K=l.transition;X.length&&(l.transition="none"),X.forEach(Q=>l.setProperty(Q.prop,V.get(Q.prop)??""));let k=et(v,C,f);X.forEach((Q,W)=>l.setProperty(Q.prop,m[W])),X.length&&(e.offsetWidth,l.transition=K);let F=we(k,k.scroll,Y(),A,$);Le&&Math.abs(F.tStart-U)<1&&Math.abs(F.tEnd-_)<1||(Le=true,U=F.tStart,_=F.tEnd);}function he(l){e.style.setProperty(en,String(l));for(let m of N)e.style.setProperty(m.prop,Jt(m.from,m.to,l));I?.(l);}function He(l){if(isNaN(S)){S=l;return}S<=0&&l>0&&w?.(),S<1&&l>=1&&H?.(),S>=1&&l<1&&ue?.(),S>0&&l<=0&&D?.(),S=l;}function Ce(){if(fe)return;let l=performance.now(),m=E(),K=a;if(x!==false){let W=l-Ie,De=W>0?Math.abs(m-(ye<0?m:ye))/W:0;K=a*Math.max(.2,1+De*(typeof x=="number"?x:1)*.04);}ye=m,Ie=l;let k=_===U?0:(m-U)/(_-U);He(k);let F=B(m,U,_,K),Q=u?Math.max(Te,M(ge=Math.max(ge,F))):M(F);me=Q,he(Q),Q>=1&&!b?(b=true,j?.()):Q<1&&!u&&(b=false);}let be=Me(C??window,[v],()=>B(E(),U,_,Math.min(a,1)),Ce,Ae);Ae(),_===U&&ae("scrollAnimate: zero-length trigger window, so it never animates. In a sticky stage, set triggerElement.",e),ge=B(E(),U,_,a),me=M(ge),he(me),ve(e,{type:"animate",getProgress:()=>me,getTrigger:()=>({tStart:U,tEnd:_})});function Pe(){fe=true,be.hold(true);}return {destroy(){fe=true,be.off(),R(),Ee(e);},replay(){Te=-1,ge=0,b=false,me=0,fe=false,he(0),be.hold(false);},pause:Pe,resume(){fe&&(fe=false,be.hold(false));},seek(l){let m=Math.min(1,Math.max(0,l));me=m,Te=m,ge=0,Pe(),he(m);},getProgress(){return me},refresh:be.remeasure}}var wt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function vt(e,t){if(typeof window>"u")return wt;let n=typeof e=="string"?document.querySelector(e):e;return n?Ne(t,(r,o)=>Rn(n,r,o)):(ae("scrollCounter: element not found:",e),wt)}function Rn(e,t,n){let{from:r=0,to:o,format:s,easing:a="ease-out",trigger:u={},once:f=true,decimals:p,onComplete:g}=t,x=p!==void 0?h=>h.toFixed(p):s??(h=>String(Math.round(h))),y=typeof a=="function"?a:ee[a]??ee["ease-out"],I=ie(u.start||"top 80%"),j=ie(u.end||"top 20%");if(n)return e.textContent=x(o),g?.(),{...wt,getProgress:()=>1};let w=0,H=0,ue=false,D=-1,M=0,A=0,$=false,v=()=>window.scrollY,C=()=>window.innerHeight;function N(){let h=e.getBoundingClientRect(),P=we({top:h.top,height:h.height},v(),C(),I,j);ue&&Math.abs(P.tStart-w)<1&&Math.abs(P.tEnd-H)<1||(ue=true,w=P.tStart,H=P.tEnd);}let te=e.style.getPropertyValue("--scroll-draw-progress");function q(h){e.textContent=x(r+(o-r)*h),e.style.setProperty("--scroll-draw-progress",String(h));}let V=()=>B(v(),w,H,1);function R(){let h=V(),P=f?Math.max(D,y(M=Math.max(M,h))):y(h);A=P,q(P),P>=1&&!$?($=true,g?.()):P<1&&!f&&($=false);}N();{M=B(v(),w,H,1);let h=y(M);A=h,q(h);}let E=Me(window,[e],V,R,N);ve(e,{type:"counter",getProgress:()=>A,getTrigger:()=>({tStart:w,tEnd:H})});let Y=()=>E.hold(false);return {destroy(){E.off(),e.style.setProperty("--scroll-draw-progress",te),Ee(e);},replay(){D=-1,M=0,$=false,A=0,q(0),Y();},pause:()=>E.hold(true),resume:Y,seek(h){let P=Math.min(1,Math.max(0,h));A=P,D=P,M=0,E.hold(true),q(P);},getProgress(){return A}}}var rn={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Et(e,t={}){if(typeof window>"u")return rn;let n=typeof e=="string"?document.querySelector(e):e;if(!n||n.tagName.toLowerCase()!=="video")return ae("scrollVideo: <video> element not found:",e),rn;let r=n,{trigger:o={},easing:s="linear",once:a=false,axis:u="y",preload:f="auto",triggerElement:p,onReady:g,onComplete:x,onProgress:y}=t,I=p??r,j=window.matchMedia("(prefers-reduced-motion: reduce)").matches,w=typeof s=="function"?s:ee[s]??ee.linear,H=ie(o.start||"top top"),ue=ie(o.end||"bottom top");r.pause(),r.hasAttribute("preload")||(r.preload=f);let D=t.from??0,M=t.to,A=0,$=0,v=false,C=-1,N=0,te=0,q=false,V=false,R=()=>u==="x"?window.scrollX:window.scrollY,E=()=>u==="x"?window.innerWidth:window.innerHeight;function Y(){let b=I.getBoundingClientRect(),S=u==="x"?b.left:b.top,ye=u==="x"?b.width:b.height,Ie=we({top:S,height:ye},R(),E(),H,ue);A=Ie.tStart,$=Ie.tEnd,V&&$===A&&ae("scrollVideo: zero-length trigger window, so it never scrubs. In a sticky stage, set triggerElement.",r);}let h=NaN;function P(b){if(!V)return;let S=M??r.duration??0,ye=D+(S-D)*b;ye!==h&&(h=ye,r.currentTime=ye),r.style.setProperty("--scroll-draw-progress",String(b)),y?.(b);}let Se=()=>B(R(),A,$,1);function U(){if(!V||j)return;let b=Se(),S=a?Math.max(C,w(N=Math.max(N,b))):w(b);te=S,P(S),S>=1&&!q?(q=true,x?.()):S<1&&!a&&(q=false);}let _=Me(window,[I],Se,U,Y),fe=()=>_.hold(v||!V||j);fe();function Te(){if(V=true,M===void 0&&(M=r.duration),j){P(1),g?.();return}Y(),g?.(),v?P(te):fe();}r.readyState>=1?Te():r.addEventListener("loadedmetadata",Te,{once:true}),V||Y();let ge=j?()=>{}:ot(b=>{b&&(ge(),j=true,_.hold(true),P(1));});ve(r,{type:"video",getProgress:()=>te,getTrigger:()=>({tStart:A,tEnd:$})});function me(){v&&(v=false,fe());}return {destroy(){_.off(),r.removeEventListener("loadedmetadata",Te),ge(),Ee(r);},replay(){C=-1,N=0,q=false,te=0,h=NaN,P(0),me();},pause(){v=true,_.hold(true);},resume:me,seek(b){let S=Math.min(1,Math.max(0,b));te=S,C=S,N=0,v=true,_.hold(true),h=NaN,P(S);},getProgress(){return te}}}function on(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 at(e=""){let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=e,t}function an(e){let t=e.textContent??"";return e.textContent="",t.split(/(\s+)/).filter(Boolean).map(n=>{let r=e.appendChild(at(n)),o=/^\s+$/.test(n);return o?r.style.whiteSpace="pre":r.style.display="inline-block",o?null:r}).filter(n=>n!==null)}function Vn(e){let t=e.textContent??"";e.textContent="";let n=[],r=null;for(let o of t){let s=at(o),a=o===" ";a?s.style.whiteSpace="pre":(s.style.display="inline-block",n.push(s)),a||o>"\u0DFF"?r=null:r||(r=e.appendChild(at()),r.style.cssText="display:inline-block;white-space:nowrap"),(r??e).appendChild(s);}return n}function sn(e){let t=an(e),n=new Map;for(let s of t){let a=s.offsetTop;n.has(a)||n.set(a,[]),n.get(a).push(s);}let r=[],o=Array.from(n.keys()).sort((s,a)=>s-a);for(let s of o){let a=n.get(s),u=at();u.style.display="inline-block",a.forEach((f,p)=>{let g=f.nextElementSibling;u.appendChild(f),p<a.length-1&&g&&g.style.whiteSpace==="pre"&&u.appendChild(g);}),r.push(u);}return e.textContent="",r.forEach((s,a)=>{e.appendChild(s),a<r.length-1&&e.appendChild(document.createTextNode(" "));}),r}function Fn(e,t,n,r){if(n<=1||r===0)return e;r=Math.min(r,1/n);let o=(n-1)*r,s=t*r,a=s+(1-o);return a<=s?e>=s?1:0:qe((e-s)/(a-s),0,1)}function _n(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 St={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Tt(e,t={}){if(typeof window>"u")return St;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return ae("scrollText: element not found:",e),St;let r=n;return Ne(t,(o,s)=>Wn(r,o,s))}function Wn(e,t,n){let{split:r="words",stagger:o=.04,easing:s="ease-out",from:a={opacity:0,y:24},trigger:u={},once:f=true,onComplete:p}=t,g=typeof s=="function"?s:ee[s]??ee["ease-out"],x=ie(u.start||"top 85%"),y=ie(u.end||"top 40%"),I=e.innerHTML,j=e.textContent??"",w;r==="chars"?w=Vn(e):r==="lines"?w=sn(e):w=an(e),on(e,j);let H=w.length;function ue(E,Y){a?.opacity!==void 0&&(E.style.opacity=String(a.opacity+(1-a.opacity)*Y));let h=_n(Y,a);h&&(E.style.transform=h);}function D(E){e.style.setProperty("--scroll-draw-progress",String(E)),w.forEach((Y,h)=>{let P=g(Fn(E,h,H,o));ue(Y,P);});}if(n)return D(1),p?.(),{...St,destroy:()=>{e.innerHTML=I;},getProgress:()=>1};D(0);let M=0,A=0,$=-1,v=0,C=false;function N(){({tStart:M,tEnd:A}=we(e.getBoundingClientRect(),window.scrollY,window.innerHeight,x,y));}let te=()=>B(window.scrollY,M,A,1);function q(){let E=f?$=Math.max($,te()):te();v=E,D(E),E>=1&&!C?(C=true,p?.()):E<1&&!f&&(C=false);}N();let V=Me(window,[e],te,q,()=>{r==="lines"&&(e.innerHTML=I,w=sn(e),on(e,j),D(v)),N();});ve(e,{type:"text",getProgress:()=>v,getTrigger:()=>({tStart:M,tEnd:A})});let R=()=>V.hold(false);return {destroy(){V.off(),e.innerHTML=I,Ee(e);},replay(){$=-1,C=false,v=0,D(0),R();},pause:()=>V.hold(true),resume:R,seek(E){V.hold(true),D(v=$=qe(E,0,1));},getProgress(){return v}}}function Ue(e,t,n){let r=t,o=yt(t),s=n(e,ht(t,()=>r));return {update(a){r=a;let u=yt(a);u!==o&&(o=u,s.destroy(),s=n(e,ht(a,()=>r)));},destroy(){s.destroy();}}}function ro(e,t={}){return Ue(e,t,gt)}function oo(e={}){let t=null;function n(r){return t=gt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function so(e,t){return Ue(e,t,bt)}function io(e){let t=null;function n(r){return t=bt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function ao(e,t){return Ue(e,t,vt)}function lo(e){let t=null;function n(r){return t=vt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function co(e,t={}){return Ue(e,t,Et)}function uo(e={}){let t=null;function n(r){return t=Et(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}function fo(e,t={}){return Ue(e,t,Tt)}function mo(e={}){let t=null;function n(r){return t=Tt(r,e),{destroy(){t?.destroy(),t=null;}}}return {action:n,getInstance:()=>t}}exports.createScrollAnimate=io;exports.createScrollCounter=lo;exports.createScrollDraw=oo;exports.createScrollText=mo;exports.createScrollVideo=uo;exports.scrollAnimate=so;exports.scrollCounterAction=ao;exports.scrollDraw=ro;exports.scrollTextAction=fo;exports.scrollVideoAction=co;
|
package/dist/svelte/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScrollDrawInstance, a as ScrollDrawOptions } from '../types-
|
|
2
|
-
import { S as ScrollAnimateOptions } from '../engine-
|
|
3
|
-
import { S as ScrollCounterOptions } from '../index-
|
|
1
|
+
import { S as ScrollDrawInstance, a as ScrollDrawOptions } from '../types-9bcJdVcg.mjs';
|
|
2
|
+
import { S as ScrollAnimateOptions } from '../engine-BLWKCfxC.mjs';
|
|
3
|
+
import { S as ScrollCounterOptions } from '../index-DVjblK_4.mjs';
|
|
4
4
|
import { ScrollVideoOptions } from '../video/index.mjs';
|
|
5
5
|
import { ScrollTextOptions } from '../text/index.mjs';
|
|
6
6
|
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScrollDrawInstance, a as ScrollDrawOptions } from '../types-
|
|
2
|
-
import { S as ScrollAnimateOptions } from '../engine-
|
|
3
|
-
import { S as ScrollCounterOptions } from '../index-
|
|
1
|
+
import { S as ScrollDrawInstance, a as ScrollDrawOptions } from '../types-9bcJdVcg.js';
|
|
2
|
+
import { S as ScrollAnimateOptions } from '../engine-6VsjEwzb.js';
|
|
3
|
+
import { S as ScrollCounterOptions } from '../index-BN8yKeQ3.js';
|
|
4
4
|
import { ScrollVideoOptions } from '../video/index.js';
|
|
5
5
|
import { ScrollTextOptions } from '../text/index.js';
|
|
6
6
|
|
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-NYQJPPMP.mjs';import {a as a$2}from'../chunk-XNM3VKEK.mjs';import {a as a$1}from'../chunk-PAGN26EH.mjs';import {a}from'../chunk-VJ5ZU55P.mjs';import {b}from'../chunk-K6VATIJH.mjs';import'../chunk-V3Z6G5JE.mjs';import'../chunk-UPWWULKI.mjs';import'../chunk-XC5NR2MU.mjs';import'../chunk-2PYLM3E7.mjs';import'../chunk-NV6YTPHI.mjs';import'../chunk-THPTANES.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 se({tension:e=2.5,friction:t=2.2}={}){return n=>1-Math.cos(n*Math.PI*e)*Math.pow(1-n,t)}function ue({bounces:e=3,decay:t=.5}={}){let n=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,t)),i=Math.sqrt(r),o=0,s=[];for(let a=0;a<n;a++){let u=Math.pow(i,a);s.push(u),o+=u;}let c=[0],d=0;for(let a=0;a<n;a++)d+=s[a]/o,c.push(d);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let u=0;u<n;u++)if(a<=c[u+1]){let p=(a-c[u])/(c[u+1]-c[u]);if(u===0)return p*(2-p);let f=1-Math.pow(r,u);return f+(1-f)*(2*p-1)*(2*p-1)}return 1}}function ae({amplitude:e=1,period:t=.4}={}){let n=Math.max(1,e),r=Math.max(.1,t),i=n<=1?r/4:r/(2*Math.PI)*Math.asin(1/n);return o=>o<=0?0:o>=1?1:n*Math.pow(2,-10*o)*Math.sin((o-i)*(2*Math.PI)/r)+1}var I={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:se(),bounce:ue(),elastic:ae()};function w(e,t,n){return Math.min(n,Math.max(t,e))}function D(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}}var V=(e,t)=>e==="top"?0:e==="center"?.5:e==="bottom"?1:t;function G(e,t,n,r){return e+n+t*V(r,0)}function Q(e,t){return t*(/^\d+(\.\d+)?%$/.test(e)?parseFloat(e)/100:V(e,1))}function $(e,t,n,r){return n===t?0:w((e-t)/(n-t)*r,0,1)}function F(e,t,n,r,i){let o=G(e.top,e.height,t,r.element)-Q(r.viewport,n),s=G(e.top,e.height,t,i.element)-Q(i.viewport,n);return {tStart:o,tEnd:s}}var q=Symbol.for("svg-scroll-draw.registry");function z(){let e=globalThis;return e[q]||(e[q]=new Map)}function B(e,t){z().set(e,t);}function Y(e){z().delete(e);}var ce=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function j(e,...t){ce&&console.warn(`[svg-scroll-draw] ${e}`,...t);}function K(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),n=i=>e(!!i.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 U(e,t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t(e,true);let n=t(e,false),r=K(o=>{if(!o)return;r();let s=(n.getProgress?.()??0)>=1;n.destroy(),n=t(s?{...e,onComplete:void 0}:e,true);}),i={};for(let o of Object.keys(n))i[o]=(...s)=>n[o]?.(...s);return i.destroy=()=>{r(),n.destroy();},i}var E,_=new Set,R=new WeakMap,v=new Map,X=e=>{let t=e.getBoundingClientRect();return t.width+" "+t.height};function de(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 J(e,t){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let n=()=>t();E??(E=new ResizeObserver(i=>{let o=false;for(let{target:s}of i)R.get(s)!==X(s)&&(o=true),R.set(s,"");o&&_.forEach(s=>s());})),_.add(n);let r=de(e);return [document.body,document.documentElement].forEach(i=>i&&r.add(i)),r.forEach(i=>{R.has(i)||R.set(i,X(i)),v.set(i,(v.get(i)??0)+1),E.observe(i);}),()=>{_.delete(n)&&(r.forEach(i=>{let o=(v.get(i)??1)-1;if(o)return void v.set(i,o);v.delete(i),E?.unobserve(i);}),_.size||(E?.disconnect(),E=void 0));}}function Z(e,t,n,r,i){let o,s=NaN,c,d,a=()=>{o=0,r(),!c&&!o&&(s=n())>0&&s<1&&(o=requestAnimationFrame(a));},u=()=>{!o&&!c&&n()!==s&&(o=requestAnimationFrame(a));},p=b=>{c=b,cancelAnimationFrame(o),o=s=NaN,u();},f=()=>{clearTimeout(d),i(),u();},g=()=>{clearTimeout(d),d=setTimeout(f,150);},x=J(t,g),m=b=>{e[b]("scroll",u,{passive:true}),window[b]("resize",g),window[b]("orientationchange",g);};return m("addEventListener"),u(),{hold:p,remeasure:f,off(){p(true),m("removeEventListener"),x(),clearTimeout(d);}}}function ee(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 k(e=""){let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=e,t}function te(e){let t=e.textContent??"";return e.textContent="",t.split(/(\s+)/).filter(Boolean).map(n=>{let r=e.appendChild(k(n)),i=/^\s+$/.test(n);return i?r.style.whiteSpace="pre":r.style.display="inline-block",i?null:r}).filter(n=>n!==null)}function le(e){let t=e.textContent??"";e.textContent="";let n=[],r=null;for(let i of t){let o=k(i),s=i===" ";s?o.style.whiteSpace="pre":(o.style.display="inline-block",n.push(o)),s||i>"\u0DFF"?r=null:r||(r=e.appendChild(k()),r.style.cssText="display:inline-block;white-space:nowrap"),(r??e).appendChild(o);}return n}function ne(e){let t=te(e),n=new Map;for(let o of t){let s=o.offsetTop;n.has(s)||n.set(s,[]),n.get(s).push(o);}let r=[],i=Array.from(n.keys()).sort((o,s)=>o-s);for(let o of i){let s=n.get(o),c=k();c.style.display="inline-block",s.forEach((d,a)=>{let u=d.nextElementSibling;c.appendChild(d),a<s.length-1&&u&&u.style.whiteSpace==="pre"&&c.appendChild(u);}),r.push(c);}return e.textContent="",r.forEach((o,s)=>{e.appendChild(o),s<r.length-1&&e.appendChild(document.createTextNode(" "));}),r}function pe(e,t,n,r){if(n<=1||r===0)return e;r=Math.min(r,1/n);let i=(n-1)*r,o=t*r,s=o+(1-i);return s<=o?e>=o?1:0:w((e-o)/(s-o),0,1)}function me(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 P={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ie(e,t={}){if(typeof window>"u")return P;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return j("scrollText: element not found:",e),P;let r=n;return U(t,(i,o)=>fe(r,i,o))}function fe(e,t,n){let{split:r="words",stagger:i=.04,easing:o="ease-out",from:s={opacity:0,y:24},trigger:c={},once:d=true,onComplete:a}=t,u=typeof o=="function"?o:I[o]??I["ease-out"],p=D(c.start||"top 85%"),f=D(c.end||"top 40%"),g=e.innerHTML,x=e.textContent??"",m;r==="chars"?m=le(e):r==="lines"?m=ne(e):m=te(e),ee(e,x);let b=m.length;function re(l,S){s?.opacity!==void 0&&(l.style.opacity=String(s.opacity+(1-s.opacity)*S));let C=me(S,s);C&&(l.style.transform=C);}function h(l){e.style.setProperty("--scroll-draw-progress",String(l)),m.forEach((S,C)=>{let ie=u(pe(l,C,b,i));re(S,ie);});}if(n)return h(1),a?.(),{...P,destroy:()=>{e.innerHTML=g;},getProgress:()=>1};h(0);let H=0,O=0,M=-1,y=0,T=false;function N(){({tStart:H,tEnd:O}=F(e.getBoundingClientRect(),window.scrollY,window.innerHeight,p,f));}let A=()=>$(window.scrollY,H,O,1);function oe(){let l=d?M=Math.max(M,A()):A();y=l,h(l),l>=1&&!T?(T=true,a?.()):l<1&&!d&&(T=false);}N();let L=Z(window,[e],A,oe,()=>{r==="lines"&&(e.innerHTML=g,m=ne(e),ee(e,x),h(y)),N();});B(e,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:H,tEnd:O})});let W=()=>L.hold(false);return {destroy(){L.off(),e.innerHTML=g,Y(e);},replay(){M=-1,T=false,y=0,h(0),W();},pause:()=>L.hold(true),resume:W,seek(l){L.hold(true),h(y=M=w(l,0,1));},getProgress(){return y}}}exports.scrollText=Ie;
|
package/dist/text/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasingName, T as TriggerConfig, S as ScrollDrawInstance } from '../types-
|
|
1
|
+
import { E as EasingName, T as TriggerConfig, S as ScrollDrawInstance } from '../types-9bcJdVcg.mjs';
|
|
2
2
|
|
|
3
3
|
interface ScrollTextOptions {
|
|
4
4
|
split?: 'chars' | 'words' | 'lines';
|
package/dist/text/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasingName, T as TriggerConfig, S as ScrollDrawInstance } from '../types-
|
|
1
|
+
import { E as EasingName, T as TriggerConfig, S as ScrollDrawInstance } from '../types-9bcJdVcg.js';
|
|
2
2
|
|
|
3
3
|
interface ScrollTextOptions {
|
|
4
4
|
split?: 'chars' | 'words' | 'lines';
|
package/dist/text/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as scrollText}from'../chunk-
|
|
1
|
+
export{a as scrollText}from'../chunk-XNM3VKEK.mjs';import'../chunk-2PYLM3E7.mjs';import'../chunk-NV6YTPHI.mjs';import'../chunk-THPTANES.mjs';import'../chunk-5PJEKEEP.mjs';import'../chunk-4DOJSIEQ.mjs';import'../chunk-BCV4RAIX.mjs';import'../chunk-LFSU6LR3.mjs';
|
package/dist/timeline/index.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function Ge({tension:e=2.5,friction:t=2.2}={}){return n=>1-Math.cos(n*Math.PI*e)*Math.pow(1-n,t)}function Fe({bounces:e=3,decay:t=.5}={}){let n=Math.max(1,Math.round(e)),i=Math.max(.01,Math.min(.99,t)),o=Math.sqrt(i),s=0,u=[];for(let l=0;l<n;l++){let d=Math.pow(o,l);u.push(d),s+=d;}let b=[0],g=0;for(let l=0;l<n;l++)g+=u[l]/s,b.push(g);return l=>{if(l<=0)return 0;if(l>=1)return 1;for(let d=0;d<n;d++)if(l<=b[d+1]){let h=(l-b[d])/(b[d+1]-b[d]);if(d===0)return h*(2-h);let v=1-Math.pow(i,d);return v+(1-v)*(2*h-1)*(2*h-1)}return 1}}function Oe({amplitude:e=1,period:t=.4}={}){let n=Math.max(1,e),i=Math.max(.1,t),o=n<=1?i/4:i/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-o)*(2*Math.PI)/i)+1}var ee={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:Ge(),bounce:Fe(),elastic:Oe()};function ce(e,t,n){return Math.min(n,Math.max(t,e))}function te(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[n="top",i="bottom"]=t.split(/\s+/).filter(Boolean);return {element:n,viewport:i}}var fe=(e,t)=>e==="top"?0:e==="center"?.5:e==="bottom"?1:t;function me(e,t,n,i){return e+n+t*fe(i,0)}function pe(e,t){return t*(/^\d+(\.\d+)?%$/.test(e)?parseFloat(e)/100:fe(e,1))}function z(e,t,n,i){return n===t?0:ce((e-t)/(n-t)*i,0,1)}function be(e,t,n,i,o){let s=me(e.top,e.height,t,i.element)-pe(i.viewport,n),u=me(e.top,e.height,t,o.element)-pe(o.viewport,n);return {tStart:s,tEnd:u}}function ne(e){let t=parseFloat(e.getAttribute("pathLength")??"");if(t>0)return t;let n=e.tagName.toLowerCase();if(n==="rect"){let i=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(i+o)}if(n==="circle"){let i=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*i}return e.getTotalLength()}function ge(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function he(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let t=window.matchMedia("(prefers-reduced-motion: reduce)"),n=o=>e(!!o.matches);if(typeof t.addEventListener=="function")return t.addEventListener("change",n),()=>t.removeEventListener("change",n);let i=t;return i.addListener?.(n),()=>i.removeListener?.(n)}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 ye(e,...t){Pe&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var ve=Symbol.for("svg-scroll-draw.registry");function we(){let e=globalThis;return e[ve]||(e[ve]=new Map)}function xe(e,t){we().set(e,t);}function Ee(e){we().delete(e);}var I,W=new Set,Q=new WeakMap,$=new Map,Me=e=>{let t=e.getBoundingClientRect();return t.width+" "+t.height};function Ce(e){let t=new Set;for(let n of e)for(;n&&n!==document.body;n=n.parentElement)for(let i=n;i;i=i.previousElementSibling)t.add(i);return t}function Le(e,t){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let n=()=>t();I??(I=new ResizeObserver(o=>{let s=false;for(let{target:u}of o)Q.get(u)!==Me(u)&&(s=true),Q.set(u,"");s&&W.forEach(u=>u());})),W.add(n);let i=Ce(e);return [document.body,document.documentElement].forEach(o=>o&&i.add(o)),i.forEach(o=>{Q.has(o)||Q.set(o,Me(o)),$.set(o,($.get(o)??0)+1),I.observe(o);}),()=>{W.delete(n)&&(i.forEach(o=>{let s=($.get(o)??1)-1;if(s)return void $.set(o,s);$.delete(o),I?.unobserve(o);}),W.size||(I?.disconnect(),I=void 0));}}function Te(e,t,n,i,o){let s,u=NaN,b,g,l=()=>{s=0,i(),!b&&!s&&(u=n())>0&&u<1&&(s=requestAnimationFrame(l));},d=()=>{!s&&!b&&n()!==u&&(s=requestAnimationFrame(l));},h=M=>{b=M,cancelAnimationFrame(s),s=u=NaN,d();},v=()=>{clearTimeout(g),o(),d();},E=()=>{clearTimeout(g),g=setTimeout(v,150);},q=Le(t,E),k=M=>{e[M]("scroll",d,{passive:true}),window[M]("resize",E),window[M]("orientationchange",E);};return k("addEventListener"),d(),{hold:h,remeasure:v,off(){h(true),k("removeEventListener"),q(),clearTimeout(g);}}}var Se=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function it(e,t){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let i=typeof e=="string"?document.querySelector(e):e;if(!i)return ye("timeline: Container not found:",e),n;let o=i,{trigger:s={},speed:u=1,once:b=false,axis:g="y",tracks:l,onComplete:d,repeat:h,repeatDelay:v=0,loop:E=false,loopDuration:q=1500,debug:k=false,label:M,respectReducedMotion:re=true}=t,Re=te(s.start||"top bottom"),De=te(s.end||"bottom top"),G=h==="infinite"?1/0:h??0,f,H=false,B=E===true?1/0:typeof E=="number"?E:0,y=false,j=0,S=B,Y=re&&ge(),_e=he(r=>{Y=re&&r,Y&&(y=false,clearTimeout(f),f=void 0);}),K=()=>B>0&&!Y,U=new Map,X=l.map(r=>{let c=typeof r.easing=="function"?r.easing:ee[r.easing??"linear"]??ee.linear,p=Array.from(o.querySelectorAll(r.selector)),m=p.map(a=>ne(a));return p.forEach((a,w)=>{U.has(a)||U.set(a,a.getAttribute("style")??""),a.style.strokeDasharray=`${m[w]}`,a.style.strokeDashoffset=`${m[w]}`,r.fade&&(a.style.opacity="0");}),{...r,elements:p,lengths:m,easeFn:c}});function Ae(){for(let[r,c]of U)c?r.setAttribute("style",c):r.removeAttribute("style");}let F=0,O=0,oe=0,ie=0,R=false,_=false,A=-1,L=0,x=null;k&&(x=document.createElement("div"),Object.assign(x.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(x));function Ie(r){if(!x)return;let c=M??(typeof e=="string"?e:"timeline"),p=l.map(({selector:m,from:a,to:w},Z)=>{let D=Se[Z%Se.length],N=w>a?Math.min(1,Math.max(0,(r-a)/(w-a))):0,V=Math.round(N*100);return `<div style="margin:4px 0">
|
|
2
2
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:2px">
|
|
3
|
-
<span style="color:${
|
|
4
|
-
<span style="color:#666;margin-left:8px">${
|
|
3
|
+
<span style="color:${D};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${m}</span>
|
|
4
|
+
<span style="color:#666;margin-left:8px">${V}%</span>
|
|
5
5
|
</div>
|
|
6
6
|
<div style="height:3px;background:#2a2a2a;border-radius:2px;position:relative;overflow:hidden">
|
|
7
|
-
<div style="position:absolute;left:${
|
|
8
|
-
<div style="position:absolute;left:${
|
|
7
|
+
<div style="position:absolute;left:${a*100}%;width:${(w-a)*100}%;height:100%;background:${D}33;border-radius:2px"></div>
|
|
8
|
+
<div style="position:absolute;left:${a*100}%;width:${(w-a)*N*100}%;height:100%;background:${D};border-radius:2px;transition:width 0.05s linear"></div>
|
|
9
9
|
</div>
|
|
10
|
-
</div>`}).join("");
|
|
10
|
+
</div>`}).join("");x.innerHTML=`
|
|
11
11
|
<div style="color:#555;margin-bottom:8px;font-size:10px;text-transform:uppercase;letter-spacing:0.12em;border-bottom:1px solid rgba(255,255,255,0.06);padding-bottom:6px">
|
|
12
|
-
scrollDrawTimeline \xB7 ${
|
|
12
|
+
scrollDrawTimeline \xB7 ${c}
|
|
13
13
|
</div>
|
|
14
|
-
${
|
|
14
|
+
${p}
|
|
15
15
|
<div style="margin-top:6px;padding-top:6px;border-top:1px solid rgba(255,255,255,0.06)">
|
|
16
16
|
<div style="display:flex;justify-content:space-between;margin-bottom:2px">
|
|
17
17
|
<span style="color:#555">scroll</span>
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
<div style="height:2px;background:#2a2a2a;border-radius:1px;overflow:hidden">
|
|
21
21
|
<div style="height:100%;background:#fff;border-radius:1px;width:${r*100}%;transition:width 0.05s linear"></div>
|
|
22
22
|
</div>
|
|
23
|
-
</div>`;}function
|
|
23
|
+
</div>`;}function P(){return g==="x"?window.scrollX:window.scrollY}function se(){return g==="x"?window.innerWidth:window.innerHeight}function ae(){let r=o.getBoundingClientRect(),c=P(),p=g==="x"?r.left:r.top,m=g==="x"?r.width:r.height,a=be({top:p,height:m},c,se(),Re,De);F=a.tStart,O=a.tEnd,oe=p+c-se(),ie=p+c+m;}function ue(r){o.style.setProperty("--scroll-draw-progress",String(r)),X.forEach(({elements:c,lengths:p,from:m,to:a,easeFn:w,fade:Z})=>{let D=a-m,N=D>0?Math.min(1,Math.max(0,(r-m)/D)):0,V=w(N);c.forEach((de,ke)=>{de.style.strokeDashoffset=`${p[ke]*(1-V)}`,Z&&(de.style.opacity=String(V));});}),Ie(r);}function C(){H=false,A=-1,L=0,_=false,X.forEach(({elements:r,lengths:c,fade:p})=>{r.forEach((m,a)=>{m.style.strokeDashoffset=`${c[a]}`,p&&(m.style.opacity="0");});}),o.style.setProperty("--scroll-draw-progress","0");}function le(){return y?z(P(),oe,ie,1):z(P(),F,O,Math.min(u,1))}function $e(){H&&le()%1&&C();let r;y?r=Math.min(1,(performance.now()-j)/q):(r=z(P(),F,O,u),(b||K())&&(A=Math.max(A,r),r=A)),L=r,ue(r),r>=1&&!_?(_=true,d?.(),K()&&!y&&!f?f=setTimeout(()=>{f=void 0,S!==1/0&&S--,C(),y=true,j=performance.now(),T();},v):G>0&&b&&!y&&!f&&(f=setTimeout(()=>{f=void 0,G!==1/0&&G--,H=true;},v))):!y&&r<1&&!b&&(_=false),y&&r>=1&&!f&&(_=false,S>0&&K()?f=setTimeout(()=>{f=void 0,S!==1/0&&S--,C(),j=performance.now(),T();},v):y=false);}ae();let J=Te(window,[o],le,$e,()=>{X.forEach(({elements:r,lengths:c})=>{r.forEach((p,m)=>{c[m]=ne(p),p.style.strokeDasharray=`${c[m]}`;});}),ae();}),T=()=>J.hold(R);return T(),xe(o,{type:"draw",getProgress:()=>L,getTrigger:()=>({tStart:F,tEnd:O})}),{destroy(){J.off(),clearTimeout(f),Ee(o),_e(),x&&(x.remove(),x=null),Ae(),o.style.removeProperty("--scroll-draw-progress");},refresh:J.remeasure,replay(){G=h==="infinite"?1/0:h??0,S=B,y=false,clearTimeout(f),f=void 0,C(),R=false,T();},pause(){R=true,T();},resume(){R&&(R=false,T());},seek(r){L=Math.min(1,Math.max(0,r)),A=L,R=true,T(),ue(L);},getProgress(){return L}}}exports.scrollDrawTimeline=it;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasingName, S as ScrollDrawInstance } from '../types-
|
|
1
|
+
import { E as EasingName, S as ScrollDrawInstance } from '../types-9bcJdVcg.mjs';
|
|
2
2
|
|
|
3
3
|
interface TimelineTrack {
|
|
4
4
|
/** CSS selector for paths within the container to animate on this track. */
|
package/dist/timeline/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasingName, S as ScrollDrawInstance } from '../types-
|
|
1
|
+
import { E as EasingName, S as ScrollDrawInstance } from '../types-9bcJdVcg.js';
|
|
2
2
|
|
|
3
3
|
interface TimelineTrack {
|
|
4
4
|
/** CSS selector for paths within the container to animate on this track. */
|
package/dist/timeline/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {a as a$1}from'../chunk-AJ22VSHC.mjs';import {a as a$3}from'../chunk-XC5NR2MU.mjs';import {a,
|
|
1
|
+
import {a as a$1}from'../chunk-AJ22VSHC.mjs';import {a as a$3}from'../chunk-XC5NR2MU.mjs';import {a,e,c,b as b$2}from'../chunk-NV6YTPHI.mjs';import {d}from'../chunk-THPTANES.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 pe=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function Re(c$1,de){let _={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return _;let q=typeof c$1=="string"?document.querySelector(c$1):c$1;if(!q)return b("timeline: Container not found:",c$1),_;let l=q,{trigger:B={},speed:V=1,once:k=false,axis:h="y",tracks:U,onComplete:fe,repeat:x,repeatDelay:I=0,loop:R=false,loopDuration:ce=1500,debug:ue=false,label:me,respectReducedMotion:X=true}=de,ge=a(B.start||"top bottom"),ye=a(B.end||"bottom top"),w=x==="infinite"?1/0:x??0,i,L=false,C=R===true?1/0:typeof R=="number"?R:0,s=false,P=0,u=C,A=X&&a$1(),be=a$2(e=>{A=X&&e,A&&(s=false,clearTimeout(i),i=void 0);}),H=()=>C>0&&!A,z=new Map,G=U.map(e=>{let o=typeof e.easing=="function"?e.easing:d[e.easing??"linear"]??d.linear,r=Array.from(l.querySelectorAll(e.selector)),n=r.map(t=>a$3(t));return r.forEach((t,a)=>{z.has(t)||z.set(t,t.getAttribute("style")??""),t.style.strokeDasharray=`${n[a]}`,t.style.strokeDashoffset=`${n[a]}`,e.fade&&(t.style.opacity="0");}),{...e,elements:r,lengths:n,easeFn:o}});function he(){for(let[e,o]of z)o?e.setAttribute("style",o):e.removeAttribute("style");}let v=0,T=0,Y=0,J=0,m=false,y=false,b$3=-1,d$1=0,p=null;ue&&(p=document.createElement("div"),Object.assign(p.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(p));function xe(e){if(!p)return;let o=me??(typeof c$1=="string"?c$1:"timeline"),r=U.map(({selector:n,from:t,to:a},j)=>{let g=pe[j%pe.length],D=a>t?Math.min(1,Math.max(0,(e-t)/(a-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
|
-
<span style="color:${g};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${
|
|
3
|
+
<span style="color:${g};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${n}</span>
|
|
4
4
|
<span style="color:#666;margin-left:8px">${S}%</span>
|
|
5
5
|
</div>
|
|
6
6
|
<div style="height:3px;background:#2a2a2a;border-radius:2px;position:relative;overflow:hidden">
|
|
7
|
-
<div style="position:absolute;left:${t*100}%;width:${(
|
|
8
|
-
<div style="position:absolute;left:${t*100}%;width:${(
|
|
7
|
+
<div style="position:absolute;left:${t*100}%;width:${(a-t)*100}%;height:100%;background:${g}33;border-radius:2px"></div>
|
|
8
|
+
<div style="position:absolute;left:${t*100}%;width:${(a-t)*D*100}%;height:100%;background:${g};border-radius:2px;transition:width 0.05s linear"></div>
|
|
9
9
|
</div>
|
|
10
|
-
</div>`}).join("");
|
|
10
|
+
</div>`}).join("");p.innerHTML=`
|
|
11
11
|
<div style="color:#555;margin-bottom:8px;font-size:10px;text-transform:uppercase;letter-spacing:0.12em;border-bottom:1px solid rgba(255,255,255,0.06);padding-bottom:6px">
|
|
12
|
-
scrollDrawTimeline \xB7 ${
|
|
12
|
+
scrollDrawTimeline \xB7 ${o}
|
|
13
13
|
</div>
|
|
14
|
-
${
|
|
14
|
+
${r}
|
|
15
15
|
<div style="margin-top:6px;padding-top:6px;border-top:1px solid rgba(255,255,255,0.06)">
|
|
16
16
|
<div style="display:flex;justify-content:space-between;margin-bottom:2px">
|
|
17
17
|
<span style="color:#555">scroll</span>
|
|
@@ -20,4 +20,4 @@ import {a as a$1}from'../chunk-AJ22VSHC.mjs';import {a as a$3}from'../chunk-XC5N
|
|
|
20
20
|
<div style="height:2px;background:#2a2a2a;border-radius:1px;overflow:hidden">
|
|
21
21
|
<div style="height:100%;background:#fff;border-radius:1px;width:${e*100}%;transition:width 0.05s linear"></div>
|
|
22
22
|
</div>
|
|
23
|
-
</div>`;}function
|
|
23
|
+
</div>`;}function E(){return h==="x"?window.scrollX:window.scrollY}function K(){return h==="x"?window.innerWidth:window.innerHeight}function Q(){let e=l.getBoundingClientRect(),o=E(),r=h==="x"?e.left:e.top,n=h==="x"?e.width:e.height,t=c({top:r,height:n},o,K(),ge,ye);v=t.tStart,T=t.tEnd,Y=r+o-K(),J=r+o+n;}function Z(e){l.style.setProperty("--scroll-draw-progress",String(e)),G.forEach(({elements:o,lengths:r,from:n,to:t,easeFn:a,fade:j})=>{let g=t-n,D=g>0?Math.min(1,Math.max(0,(e-n)/g)):0,S=a(D);o.forEach((te,ve)=>{te.style.strokeDashoffset=`${r[ve]*(1-S)}`,j&&(te.style.opacity=String(S));});}),xe(e);}function M(){L=false,b$3=-1,d$1=0,y=false,G.forEach(({elements:e,lengths:o,fade:r})=>{e.forEach((n,t)=>{n.style.strokeDashoffset=`${o[t]}`,r&&(n.style.opacity="0");});}),l.style.setProperty("--scroll-draw-progress","0");}function ee(){return s?b$2(E(),Y,J,1):b$2(E(),v,T,Math.min(V,1))}function we(){L&&ee()%1&&M();let e;s?e=Math.min(1,(performance.now()-P)/ce):(e=b$2(E(),v,T,V),(k||H())&&(b$3=Math.max(b$3,e),e=b$3)),d$1=e,Z(e),e>=1&&!y?(y=true,fe?.(),H()&&!s&&!i?i=setTimeout(()=>{i=void 0,u!==1/0&&u--,M(),s=true,P=performance.now(),f();},I):w>0&&k&&!s&&!i&&(i=setTimeout(()=>{i=void 0,w!==1/0&&w--,L=true;},I))):!s&&e<1&&!k&&(y=false),s&&e>=1&&!i&&(y=false,u>0&&H()?i=setTimeout(()=>{i=void 0,u!==1/0&&u--,M(),P=performance.now(),f();},I):s=false);}Q();let O=e(window,[l],ee,we,()=>{G.forEach(({elements:e,lengths:o})=>{e.forEach((r,n)=>{o[n]=a$3(r),r.style.strokeDasharray=`${o[n]}`;});}),Q();}),f=()=>O.hold(m);return f(),a$4(l,{type:"draw",getProgress:()=>d$1,getTrigger:()=>({tStart:v,tEnd:T})}),{destroy(){O.off(),clearTimeout(i),b$1(l),be(),p&&(p.remove(),p=null),he(),l.style.removeProperty("--scroll-draw-progress");},refresh:O.remeasure,replay(){w=x==="infinite"?1/0:x??0,u=C,s=false,clearTimeout(i),i=void 0,M(),m=false,f();},pause(){m=true,f();},resume(){m&&(m=false,f());},seek(e){d$1=Math.min(1,Math.max(0,e)),b$3=d$1,m=true,f(),Z(d$1);},getProgress(){return d$1}}}export{Re as scrollDrawTimeline};
|
|
@@ -58,9 +58,13 @@ interface ScrollDrawOptions {
|
|
|
58
58
|
waypoints?: Record<number, () => void>;
|
|
59
59
|
/** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
|
|
60
60
|
velocityScale?: boolean | number;
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* With `autoplay`, the IntersectionObserver threshold (0–1) at which the run
|
|
63
|
+
* starts. Default 0. A scroll-linked draw follows its trigger window instead,
|
|
64
|
+
* and has no observer since 2.23.5.
|
|
65
|
+
*/
|
|
62
66
|
threshold?: number;
|
|
63
|
-
/** IntersectionObserver rootMargin. Default "0px". */
|
|
67
|
+
/** With `autoplay`, the IntersectionObserver rootMargin. Default "0px". */
|
|
64
68
|
rootMargin?: string;
|
|
65
69
|
/** Repeat the animation N times after completion. Use 'infinite' to loop forever. */
|
|
66
70
|
repeat?: number | 'infinite';
|
|
@@ -58,9 +58,13 @@ interface ScrollDrawOptions {
|
|
|
58
58
|
waypoints?: Record<number, () => void>;
|
|
59
59
|
/** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
|
|
60
60
|
velocityScale?: boolean | number;
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* With `autoplay`, the IntersectionObserver threshold (0–1) at which the run
|
|
63
|
+
* starts. Default 0. A scroll-linked draw follows its trigger window instead,
|
|
64
|
+
* and has no observer since 2.23.5.
|
|
65
|
+
*/
|
|
62
66
|
threshold?: number;
|
|
63
|
-
/** IntersectionObserver rootMargin. Default "0px". */
|
|
67
|
+
/** With `autoplay`, the IntersectionObserver rootMargin. Default "0px". */
|
|
64
68
|
rootMargin?: string;
|
|
65
69
|
/** Repeat the animation N times after completion. Use 'infinite' to loop forever. */
|
|
66
70
|
repeat?: number | 'infinite';
|
package/dist/video/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function fe({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),i=0,
|
|
1
|
+
'use strict';function le({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function fe({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),i=0,a=[];for(let u=0;u<r;u++){let s=Math.pow(o,u);a.push(s),i+=s;}let c=[0],l=0;for(let u=0;u<r;u++)l+=a[u]/i,c.push(l);return u=>{if(u<=0)return 0;if(u>=1)return 1;for(let s=0;s<r;s++)if(u<=c[s+1]){let f=(u-c[s])/(c[s+1]-c[s]);if(s===0)return f*(2-f);let p=1-Math.pow(n,s);return p+(1-p)*(2*f-1)*(2*f-1)}return 1}}function pe({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 i=>i<=0?0:i>=1?1:r*Math.pow(2,-10*i)*Math.sin((i-o)*(2*Math.PI)/n)+1}var Q={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:le(),bounce:fe(),elastic:pe()};function K(e,t,r){return Math.min(r,Math.max(t,e))}function k(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}}var J=(e,t)=>e==="top"?0:e==="center"?.5:e==="bottom"?1:t;function X(e,t,r,n){return e+r+t*J(n,0)}function j(e,t){return t*(/^\d+(\.\d+)?%$/.test(e)?parseFloat(e)/100:J(e,1))}function U(e,t,r,n){return r===t?0:K((e-t)/(r-t)*n,0,1)}function Z(e,t,r,n,o){let i=X(e.top,e.height,t,n.element)-j(n.viewport,r),a=X(e.top,e.height,t,o.element)-j(o.viewport,r);return {tStart:i,tEnd:a}}var ee=Symbol.for("svg-scroll-draw.registry");function te(){let e=globalThis;return e[ee]||(e[ee]=new Map)}function ne(e,t){te().set(e,t);}function re(e){te().delete(e);}var ge=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function W(e,...t){ge&&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 S,P=new Set,D=new WeakMap,_=new Map,ie=e=>{let t=e.getBoundingClientRect();return t.width+" "+t.height};function be(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 se(e,t){if(typeof ResizeObserver>"u"||typeof document>"u")return ()=>{};let r=()=>t();S??(S=new ResizeObserver(o=>{let i=false;for(let{target:a}of o)D.get(a)!==ie(a)&&(i=true),D.set(a,"");i&&P.forEach(a=>a());})),P.add(r);let n=be(e);return [document.body,document.documentElement].forEach(o=>o&&n.add(o)),n.forEach(o=>{D.has(o)||D.set(o,ie(o)),_.set(o,(_.get(o)??0)+1),S.observe(o);}),()=>{P.delete(r)&&(n.forEach(o=>{let i=(_.get(o)??1)-1;if(i)return void _.set(o,i);_.delete(o),S?.unobserve(o);}),P.size||(S?.disconnect(),S=void 0));}}function ae(e,t,r,n,o){let i,a=NaN,c,l,u=()=>{i=0,n(),!c&&!i&&(a=r())>0&&a<1&&(i=requestAnimationFrame(u));},s=()=>{!i&&!c&&r()!==a&&(i=requestAnimationFrame(u));},f=b=>{c=b,cancelAnimationFrame(i),i=a=NaN,s();},p=()=>{clearTimeout(l),o(),s();},v=()=>{clearTimeout(l),l=setTimeout(p,150);},g=se(t,v),M=b=>{e[b]("scroll",s,{passive:true}),window[b]("resize",v),window[b]("orientationchange",v);};return M("addEventListener"),s(),{hold:f,remeasure:p,off(){f(true),M("removeEventListener"),g(),clearTimeout(l);}}}var ue={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function De(e,t={}){if(typeof window>"u")return ue;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return W("scrollVideo: <video> element not found:",e),ue;let n=r,{trigger:o={},easing:i="linear",once:a=false,axis:c="y",preload:l="auto",triggerElement:u,onReady:s,onComplete:f,onProgress:p}=t,v=u??n,g=window.matchMedia("(prefers-reduced-motion: reduce)").matches,M=typeof i=="function"?i:Q[i]??Q.linear,b=k(o.start||"top top"),de=k(o.end||"bottom top");n.pause(),n.hasAttribute("preload")||(n.preload=l);let F=t.from??0,I=t.to,R=0,T=0,h=false,O=-1,N=0,w=0,A=false,y=false,q=()=>c==="x"?window.scrollX:window.scrollY,ce=()=>c==="x"?window.innerWidth:window.innerHeight;function z(){let d=v.getBoundingClientRect(),m=c==="x"?d.left:d.top,L=c==="x"?d.width:d.height,H=Z({top:m,height:L},q(),ce(),b,de);R=H.tStart,T=H.tEnd,y&&T===R&&W("scrollVideo: zero-length trigger window, so it never scrubs. In a sticky stage, set triggerElement.",n);}let V=NaN;function E(d){if(!y)return;let m=I??n.duration??0,L=F+(m-F)*d;L!==V&&(V=L,n.currentTime=L),n.style.setProperty("--scroll-draw-progress",String(d)),p?.(d);}let B=()=>U(q(),R,T,1);function me(){if(!y||g)return;let d=B(),m=a?Math.max(O,M(N=Math.max(N,d))):M(d);w=m,E(m),m>=1&&!A?(A=true,f?.()):m<1&&!a&&(A=false);}let x=ae(window,[v],B,me,z),C=()=>x.hold(h||!y||g);C();function G(){if(y=true,I===void 0&&(I=n.duration),g){E(1),s?.();return}z(),s?.(),h?E(w):C();}n.readyState>=1?G():n.addEventListener("loadedmetadata",G,{once:true}),y||z();let Y=g?()=>{}:oe(d=>{d&&(Y(),g=true,x.hold(true),E(1));});ne(n,{type:"video",getProgress:()=>w,getTrigger:()=>({tStart:R,tEnd:T})});function $(){h&&(h=false,C());}return {destroy(){x.off(),n.removeEventListener("loadedmetadata",G),Y(),re(n);},replay(){O=-1,N=0,A=false,w=0,V=NaN,E(0),$();},pause(){h=true,x.hold(true);},resume:$,seek(d){let m=Math.min(1,Math.max(0,d));w=m,O=m,N=0,h=true,x.hold(true),V=NaN,E(m);},getProgress(){return w}}}exports.scrollVideo=De;
|
package/dist/video/index.d.mts
CHANGED