svg-scroll-draw 2.9.0 → 2.10.1

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.
Files changed (75) hide show
  1. package/README.md +17 -10
  2. package/dist/angular/index.cjs +3 -3
  3. package/dist/angular/index.d.mts +42 -0
  4. package/dist/angular/index.d.ts +42 -0
  5. package/dist/angular/index.mjs +3 -3
  6. package/dist/astro/index.cjs +3 -3
  7. package/dist/astro/index.d.mts +20 -5
  8. package/dist/astro/index.d.ts +20 -5
  9. package/dist/astro/index.mjs +3 -3
  10. package/dist/cdn/svg-scroll-draw.dev.global.js +1903 -0
  11. package/dist/cdn/svg-scroll-draw.global.js +3 -3
  12. package/dist/cinematic/index.cjs +2 -2
  13. package/dist/cinematic/index.mjs +2 -2
  14. package/dist/cli/init.js +104 -101
  15. package/dist/devtools/index.cjs +1 -1
  16. package/dist/devtools/index.mjs +1 -1
  17. package/dist/group/index.cjs +3 -3
  18. package/dist/group/index.d.mts +42 -0
  19. package/dist/group/index.d.ts +42 -0
  20. package/dist/group/index.mjs +3 -3
  21. package/dist/horizontal/index.cjs +1 -1
  22. package/dist/horizontal/index.d.mts +48 -1
  23. package/dist/horizontal/index.d.ts +48 -1
  24. package/dist/horizontal/index.mjs +1 -1
  25. package/dist/index.cjs +4 -4
  26. package/dist/index.d.mts +42 -0
  27. package/dist/index.d.ts +42 -0
  28. package/dist/index.mjs +4 -4
  29. package/dist/nuxt/index.cjs +3 -3
  30. package/dist/nuxt/index.d.mts +27 -0
  31. package/dist/nuxt/index.d.ts +27 -0
  32. package/dist/nuxt/index.mjs +3 -3
  33. package/dist/pin/index.cjs +1 -1
  34. package/dist/pin/index.mjs +1 -1
  35. package/dist/progress/index.cjs +1 -1
  36. package/dist/progress/index.d.mts +15 -0
  37. package/dist/progress/index.d.ts +15 -0
  38. package/dist/progress/index.mjs +1 -1
  39. package/dist/react/index.cjs +3 -3
  40. package/dist/react/index.d.mts +27 -0
  41. package/dist/react/index.d.ts +27 -0
  42. package/dist/react/index.mjs +3 -3
  43. package/dist/reveal/index.cjs +1 -1
  44. package/dist/reveal/index.mjs +1 -1
  45. package/dist/snap/index.cjs +1 -1
  46. package/dist/snap/index.d.mts +8 -0
  47. package/dist/snap/index.d.ts +8 -0
  48. package/dist/snap/index.mjs +1 -1
  49. package/dist/solid/index.cjs +3 -3
  50. package/dist/solid/index.d.mts +42 -0
  51. package/dist/solid/index.d.ts +42 -0
  52. package/dist/solid/index.mjs +3 -3
  53. package/dist/svelte/index.cjs +3 -3
  54. package/dist/svelte/index.d.mts +42 -0
  55. package/dist/svelte/index.d.ts +42 -0
  56. package/dist/svelte/index.mjs +3 -3
  57. package/dist/text/index.cjs +1 -1
  58. package/dist/text/index.d.mts +15 -0
  59. package/dist/text/index.d.ts +15 -0
  60. package/dist/text/index.mjs +1 -1
  61. package/dist/timeline/index.cjs +9 -9
  62. package/dist/timeline/index.d.mts +31 -0
  63. package/dist/timeline/index.d.ts +31 -0
  64. package/dist/timeline/index.mjs +9 -9
  65. package/dist/video/index.cjs +1 -1
  66. package/dist/video/index.d.mts +15 -0
  67. package/dist/video/index.d.ts +15 -0
  68. package/dist/video/index.mjs +1 -1
  69. package/dist/vue/index.cjs +3 -3
  70. package/dist/vue/index.d.mts +27 -0
  71. package/dist/vue/index.d.ts +27 -0
  72. package/dist/vue/index.mjs +3 -3
  73. package/dist/web-component/index.cjs +3 -3
  74. package/dist/web-component/index.mjs +3 -3
  75. package/package.json +40 -6
@@ -1,3 +1,3 @@
1
- function Et({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),u=Math.sqrt(t),s=0,f=[];for(let h=0;h<r;h++){let P=Math.pow(u,h);f.push(P),s+=P;}let l=[0],c=0;for(let h=0;h<r;h++)c+=f[h]/s,l.push(c);return h=>{if(h<=0)return 0;if(h>=1)return 1;for(let P=0;P<r;P++)if(h<=l[P+1]){let R=(h-l[P])/(l[P+1]-l[P]);if(P===0)return R*(2-R);let E=1-Math.pow(t,P);return E+(1-E)*(2*R-1)*(2*R-1)}return 1}}function St({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),u=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return s=>s<=0?0:s>=1?1:r*Math.pow(2,-10*s)*Math.sin((s-u)*(2*Math.PI)/t)+1}var ae={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Et(),elastic:St()};function le(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",t="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:t}}function nt(e,n,r,t){switch(t){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function ot(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function _e(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function xt(e,n,r){return Math.min(r,Math.max(n,e))}function Q(e,n,r,t){return r===n?0:xt((e-n)/(r-n)*t,0,1)}function ye(e,n,r,t,u){let s=nt(e.top,e.height,n,t.element)-ot(t.viewport,r),f=nt(e.top,e.height,n,u.element)-ot(u.viewport,r);return {tStart:s,tEnd:f}}function st(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let t=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return t?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]:null}function De(e,n,r){let t=st(e),u=st(n);return !t||!u?e:`rgb(${Math.round(t[0]+(u[0]-t[0])*r)},${Math.round(t[1]+(u[1]-t[1])*r)},${Math.round(t[2]+(u[2]-t[2])*r)})`}var it={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}};function at(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n);}var lt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Tt=0;function At(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Mt(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?at("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&at("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Lt(e,n,r){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.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 u(){let s=r==="x"?window.scrollX:window.scrollY,f=e-s,l=n-s,c=r==="x";t.innerHTML=`
2
- <div style="position:absolute;${c?`left:${f}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${f}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;${c?`left:${l}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${l}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",u,{passive:true}),u(),t}function Ke(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let f=parseFloat(s),l=t[u++]??f;return String(+(f+(l-f)*r).toFixed(4))})}function Be(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,u=r?{...it[r],...t}:t,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:f="path, polyline, line, polygon, rect, circle",speed:l=1,fade:c=false,easing:h="linear",trigger:P={},stagger:R=0,direction:E="forward",once:j=false,debug:he=false,axis:V="y",scrollContainer:ee,autoReverse:U=false,delay:Z=0,strokeColor:S,strokeWidth:M,fillOpacity:L,waypoints:g,velocityScale:x=false,threshold:O=0,rootMargin:G="0px",repeat:I=0,repeatDelay:se=0,morphTo:$,clip:_,autoplay:B=false,duration:X=1e3,native:z=true,onProgress:p,onStart:T,onComplete:b,onEnter:y,onLeave:q,onEnterBack:Se,onLeaveBack:xe}=u,be=_===true?"left":typeof _=="string"?_:false,we=typeof h=="function"?h:ae[h]??ae.linear,Ce=le(P.start??"top bottom"),Ne=le(P.end??"bottom top"),te=typeof ee=="string"?document.querySelector(ee):ee??null,pe=Array.isArray(S)?S[0]:null,J=Array.isArray(S)?S[1]:typeof S=="string"?S:null,K=Array.isArray(M)?M[0]:null,i=Array.isArray(M)?M[1]:typeof M=="number"?M:null,d=Array.isArray(L)?L[0]:null,k=Array.isArray(L)?L[1]:typeof L=="number"?L:null;function re(o){let a=o*100;switch(be){case "right":return `inset(0 0 0 ${100-a}%)`;case "top":return `inset(0 0 ${100-a}% 0)`;case "bottom":return `inset(${100-a}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-a}% 0 0)`}}let C=be?[]:Array.from(e.querySelectorAll(f)),H=[],D=[],ie=0,ce=0,ne=false,de=false,oe=0,He=false,ve=-1,Re=-1,ue=false,Pe=0,Te=0,Ae,Ue=null,Me=new Set,Ve=-1,et=performance.now(),Oe=NaN;function Fe(){return te?V==="x"?te.scrollLeft:te.scrollTop:V==="x"?window.scrollX:window.scrollY}function tt(){return te?V==="x"?te.clientWidth:te.clientHeight:V==="x"?window.innerWidth:window.innerHeight}function rt(){let o=e.getBoundingClientRect(),a,v,Y;if(te){let fe=te.getBoundingClientRect();a=V==="x"?o.left-fe.left+te.scrollLeft:o.top-fe.top+te.scrollTop,v=V==="x"?o.width:o.height,Y=Fe();}else a=V==="x"?o.left:o.top,v=V==="x"?o.width:o.height,Y=Fe();let me=ye({top:a,height:v},Y,tt(),Ce,Ne);ie=me.tStart,ce=me.tEnd,he&&process.env.NODE_ENV!=="production"&&(Ue?.remove(),Ue=Lt(ie,ce,V));}function ht(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),be){let v=a==="reverse"?1-o:o;e.style.clipPath=re(v);return}C.forEach((v,Y)=>{v.style.strokeDashoffset=a==="reverse"?`${H[Y]*o}`:`${H[Y]*(1-o)}`,c&&(v.style.opacity=a==="reverse"?`${1-o}`:`${o}`),pe&&J?v.style.stroke=De(pe,J,o):J&&(v.style.stroke=J),K!==null&&i!==null?v.style.strokeWidth=`${K+(i-K)*o}`:i!==null&&(v.style.strokeWidth=`${i}`),d!==null&&k!==null?v.style.fillOpacity=`${d+(k-d)*o}`:k!==null&&(v.style.fillOpacity=`${k}`),$&&v.tagName.toLowerCase()==="path"&&D[Y]&&v.setAttribute("d",Ke(D[Y],$,o));});}function ze(){if(e.style.setProperty("--scroll-draw-progress","0"),be){e.style.clipPath=re(0);return}C.forEach((o,a)=>{o.style.strokeDasharray=`${H[a]}`,o.style.strokeDashoffset=E==="reverse"?"0":`${H[a]}`,c?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",pe&&(o.style.stroke=pe),K!==null&&(o.style.strokeWidth=`${K}`),d!==null&&(o.style.fillOpacity=`${d}`),$&&o.tagName.toLowerCase()==="path"&&D[a]&&o.setAttribute("d",D[a]);});}if(C.forEach(o=>{Mt(o);let a=_e(o);H.push(a),o.tagName.toLowerCase()==="path"?D.push(o.getAttribute("d")??""):D.push(""),s?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=E==="reverse"?`${a}`:"0",c&&(o.style.opacity="1"),J&&(o.style.stroke=J),i!==null&&(o.style.strokeWidth=`${i}`),k!==null&&(o.style.fillOpacity=`${k}`),$&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",$)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=E==="reverse"?"0":`${a}`,c?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",pe&&(o.style.stroke=pe),K!==null&&(o.style.strokeWidth=`${K}`),d!==null&&(o.style.fillOpacity=`${d}`));}),be){if(s)return e.style.clipPath=re(1),b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=re(0);}else if(s)return b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function bt(){return !(z===false||!At()||!C.length||typeof h!="string"||!(h in lt)||be||V!=="y"||te||l!==1||R!==0||j||U||x!==false||$||g||I||Z>0||p||T||b||y||q||Se||xe||S!=null||M!=null||L!=null||(P.start??"top bottom").trim()!=="top bottom"||(P.end??"bottom top").trim()!=="bottom top")}function wt(){let o=`svg-scroll-draw-${++Tt}`,a=E==="reverse"?"0":"var(--ssd-len)",v=E==="reverse"?"var(--ssd-len)":"0",Y=`stroke-dashoffset:${a};`,me=`stroke-dashoffset:${v};`;c&&(Y+=`opacity:${E==="reverse"?1:0};`,me+=`opacity:${E==="reverse"?0:1};`);let fe=document.createElement("style");fe.setAttribute("data-svg-scroll-draw",""),fe.textContent=`@keyframes ${o}{from{${Y}}to{${me}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${lt[h]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(fe);function ge(m,A){m.style.setProperty("--ssd-len",String(H[A])),m.style.strokeDasharray=`${H[A]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(o);}C.forEach(ge);let w=false,F=-1;function N(){if(F>=0)return F;let m=e.getBoundingClientRect(),{tStart:A,tEnd:W}=ye({top:m.top,height:m.height},Fe(),tt(),Ce,Ne);return we(Q(Fe(),A,W,l))}return {destroy(){C.forEach(m=>{m.classList.remove(o),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),fe.remove();},replay(){w=false,F=-1,C.forEach(ge);},pause(){w=true,C.forEach(m=>{m.style.animationPlayState="paused";});},resume(){w&&(w=false,C.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let A=Math.min(1,Math.max(0,m));F=A,w=true,C.forEach((W,Ie)=>{W.classList.remove(o),W.style.strokeDashoffset=E==="reverse"?`${H[Ie]*A}`:`${H[Ie]*(1-A)}`,c&&(W.style.opacity=E==="reverse"?`${1-A}`:`${A}`);});},getProgress(){return N()}}}if(bt())return wt();function vt(){let o=Math.max(1,X),a=0,v=0;function Y(N){let m=true;if(be){let A=Math.min(1,Math.max(0,N/o)),W=we(A);Pe=W,e.style.setProperty("--scroll-draw-progress",String(W)),e.style.clipPath=re(E==="reverse"?1-W:W),p?.(W),A<1&&(m=false);}else C.forEach((A,W)=>{let Ie=W*R*o,ke=Math.min(1,Math.max(0,(N-Ie)/o)),Ee=we(ke);A.style.strokeDashoffset=E==="reverse"?`${H[W]*Ee}`:`${H[W]*(1-Ee)}`,c&&(A.style.opacity=E==="reverse"?`${1-Ee}`:`${Ee}`),pe&&J?A.style.stroke=De(pe,J,Ee):J&&(A.style.stroke=J),K!==null&&i!==null?A.style.strokeWidth=`${K+(i-K)*Ee}`:i!==null&&(A.style.strokeWidth=`${i}`),d!==null&&k!==null?A.style.fillOpacity=`${d+(k-d)*Ee}`:k!==null&&(A.style.fillOpacity=`${k}`),$&&A.tagName.toLowerCase()==="path"&&D[W]&&A.setAttribute("d",Ke(D[W],$,Ee)),W===0&&(p?.(Ee),e.style.setProperty("--scroll-draw-progress",String(Ee))),ke<1&&(m=false);});if(g){let A=Math.min(1,Math.max(0,N/o)),W=we(A);for(let Ie in g){let ke=parseFloat(Ie);W>=ke&&!Me.has(ke)&&(Me.add(ke),g[Ie]?.());}}return m}function me(N){if(ue)return;let m=N-a;de||(de=true,T?.());let A=Y(m);if(A&&!ne){ne=true,Y(o*(1+Math.max(0,C.length-1)*R)),b?.(),Te<(I==="infinite"?1/0:I??0)&&(Te++,Ae=setTimeout(()=>{a=performance.now(),de=false,ne=false,Me.clear(),ze(),oe=requestAnimationFrame(me);},se));return}A||(oe=requestAnimationFrame(me));}function fe(){cancelAnimationFrame(oe),clearTimeout(Ae),a=performance.now(),v=0,ue=false,de=false,ne=false,Te=0,Me.clear(),ze(),oe=requestAnimationFrame(me);}let ge=new IntersectionObserver(N=>{N.forEach(m=>{m.isIntersecting&&!(j&&ne)?fe():!m.isIntersecting&&!j&&!ne&&(cancelAnimationFrame(oe),clearTimeout(Ae),a=null);});},{root:te??null,threshold:O,rootMargin:G}),w;function F(){clearTimeout(w),w=setTimeout(()=>{C.forEach((N,m)=>{H[m]=_e(N),N.style.strokeDasharray=`${H[m]}`;});},150);}return window.addEventListener("resize",F),window.addEventListener("orientationchange",F),Z>0?setTimeout(()=>ge.observe(e),Z):ge.observe(e),{destroy(){cancelAnimationFrame(oe),clearTimeout(Ae),ge.disconnect(),window.removeEventListener("resize",F),window.removeEventListener("orientationchange",F),clearTimeout(w);},replay(){Te=0,fe();},pause(){ue||(ue=true,v=performance.now()-a,cancelAnimationFrame(oe));},resume(){ue&&(ue=false,a=performance.now()-v,oe=requestAnimationFrame(me));},seek(N){let m=Math.min(1,Math.max(0,N));Pe=m,ue=true,v=m*o,a=performance.now()-v,cancelAnimationFrame(oe),Y(v);},getProgress(){return Pe}}}if(B)return vt();rt();function qe(){if(!He||ue)return;let o=performance.now(),a=Fe(),v=l;if(x!==false){let w=o-et,F=w>0?Math.abs(a-(Ve<0?a:Ve))/w:0;v=l*Math.max(.2,1+F*(typeof x=="number"?x:1)*.04);}Ve=a,et=o;let Y=U?Re===-1||a>=Re?"forward":"reverse":E;Re=a;let me=ce-ie,fe=true,ge=me===0?0:(a-ie)/me;if(isNaN(Oe)||(Oe<=0&&ge>0?y?.():Oe>0&&ge<=0&&xe?.(),Oe<1&&ge>=1?q?.():Oe>=1&&ge<1&&Se?.()),Oe=ge,be){let w=we(Q(a,ie,ce,v));j&&!U&&(ve=Math.max(ve,w),w=ve),Pe=w,e.style.setProperty("--scroll-draw-progress",String(w));let F=Y==="reverse"?1-w:w;e.style.clipPath=re(F),p?.(w),!de&&Q(a,ie,ce,v)>0&&(de=true,T?.()),w>=1&&!ne?(ne=true,b?.(),Te<(I==="infinite"?1/0:I??0)&&(Te++,Ae=setTimeout(()=>{ve=-1,de=false,ne=false,e.style.clipPath=re(0);},se))):w<1&&!j&&(ne=false),oe=requestAnimationFrame(qe);return}if(C.forEach((w,F)=>{let N=F*R*me,m=we(Q(a,ie+N,ce+N,v));j&&!U&&(ve=Math.max(ve,m),m=ve),Pe=m,w.style.strokeDashoffset=Y==="reverse"?`${H[F]*m}`:`${H[F]*(1-m)}`,c&&(w.style.opacity=Y==="reverse"?`${1-m}`:`${m}`),pe&&J?w.style.stroke=De(pe,J,m):J&&(w.style.stroke=J),K!==null&&i!==null?w.style.strokeWidth=`${K+(i-K)*m}`:i!==null&&(w.style.strokeWidth=`${i}`),d!==null&&k!==null?w.style.fillOpacity=`${d+(k-d)*m}`:k!==null&&(w.style.fillOpacity=`${k}`),$&&w.tagName.toLowerCase()==="path"&&D[F]&&w.setAttribute("d",Ke(D[F],$,m)),F===0&&(p?.(m),e.style.setProperty("--scroll-draw-progress",String(m))),m<1&&(fe=false);}),g){let w=we(Q(a,ie,ce,v));for(let F in g){let N=parseFloat(F);w>=N&&!Me.has(N)&&(Me.add(N),g[F]?.());}}!de&&Q(a,ie,ce,v)>0&&(de=true,T?.()),fe&&!ne?(ne=true,b?.(),Te<(I==="infinite"?1/0:I??0)&&(Te++,Ae=setTimeout(()=>{ve=-1,de=false,ne=false,Me.clear(),ze();},se))):!fe&&!j&&(ne=false),oe=requestAnimationFrame(qe);}let Ze=new IntersectionObserver(o=>{o.forEach(a=>{He=a.isIntersecting,He&&!ue?oe=requestAnimationFrame(qe):cancelAnimationFrame(oe);});},{root:te??null,threshold:O,rootMargin:G}),Je;function We(){clearTimeout(Je),Je=setTimeout(()=>{C.forEach((o,a)=>{H[a]=_e(o),o.style.strokeDasharray=`${H[a]}`;}),rt();},150);}return window.addEventListener("resize",We),window.addEventListener("orientationchange",We),Z>0?setTimeout(()=>Ze.observe(e),Z):Ze.observe(e),{destroy(){cancelAnimationFrame(oe),clearTimeout(Ae),Ze.disconnect(),window.removeEventListener("resize",We),window.removeEventListener("orientationchange",We),clearTimeout(Je),Ue?.remove();},replay(){ve=-1,Re=-1,Ve=-1,de=false,ne=false,Te=0,ue=false,Me.clear(),clearTimeout(Ae),ze();},pause(){ue=true,cancelAnimationFrame(oe);},resume(){ue&&(ue=false,He&&(oe=requestAnimationFrame(qe)));},seek(o){let a=Math.min(1,Math.max(0,o));Pe=a,ve=a,ue=true,cancelAnimationFrame(oe),ht(a,E);},getProgress(){return Pe}}}var ct=new Map;function Le(e,n){ct.set(e,n);}function $e(e){ct.delete(e);}function $t(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ut(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let u=[],s=[],f=t[2].trim();if(f)for(let l of f.split(/[\s,]+/)){let c=l.match(/^([-+]?[\d.eE]+)(.*)$/);u.push(c?parseFloat(c[1]):0),s.push(c?c[2]:"");}n.push({fn:t[1],nums:u,units:s});}return n}function Ct(e,n,r){let t=ut(e),u=ut(n);return t.length===0||t.length!==u.length?r<1?e:n:t.map((s,f)=>{let l=u[f];return s.fn!==l.fn||s.nums.length!==l.nums.length?r<1?`${s.fn}(${s.nums.map((c,h)=>`${c}${s.units[h]}`).join(", ")})`:`${l.fn}(${l.nums.map((c,h)=>`${c}${l.units[h]}`).join(", ")})`:`${s.fn}(${s.nums.map((c,h)=>`${c+(l.nums[h]-c)*r}${s.units[h]}`).join(", ")})`}).join(" ")}function mt(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),u=String(n);if($t(t))return De(t,u,r);if(t.includes("("))return Ct(t,u,r);let s=t.match(/^([-+]?[\d.]+)(.*)$/),f=u.match(/^([-+]?[\d.]+)(.*)$/);if(s&&f){let l=parseFloat(s[1]),c=parseFloat(f[1]);return `${l+(c-l)*r}${s[2]||f[2]}`}return r<1?t:u}function Pt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var ft={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},It=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Ot=0;function kt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ge(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:u={},easing:s="ease-out",speed:f=1,once:l=false,axis:c="y",scrollContainer:h,native:P=true,velocityScale:R=false,onProgress:E,onComplete:j,onEnter:he,onLeave:V,onEnterBack:ee,onLeaveBack:U}=n,Z=window.matchMedia("(prefers-reduced-motion: reduce)").matches,S=typeof s=="function"?s:ae[s]??ae["ease-out"],M=le(u.start??"top bottom"),L=le(u.end??"bottom top"),g=typeof h=="string"?document.querySelector(h):h??null,x=Object.entries(t).map(([i,d])=>({prop:Pt(i),from:Array.isArray(d)?d[0]:"",to:Array.isArray(d)?d[1]:d}));function O(){let i=window.getComputedStyle(e);for(let d of x)d.from===""&&(d.from=i.getPropertyValue(d.prop).trim()||"0");}function G(){for(let i of x)e.style.setProperty(i.prop,String(i.to));}if(Z)return G(),j?.(),r;O();function I(){if(!P||!kt()||typeof s!="string"||!(s in ft)||c!=="y"||g||l||f!==1||E||j||he||V||ee||U||R!==false||(u.start??"top bottom").trim()!=="top bottom"||(u.end??"bottom top").trim()!=="bottom top")return false;for(let i of x)if(!It.has(i.prop))return false;return true}function se(){let i=`ssd-a-${++Ot}`,d=x.map(D=>`${D.prop}:${D.from}`).join(";"),k=x.map(D=>`${D.prop}:${D.to}`).join(";"),re=document.createElement("style");re.setAttribute("data-ssd-animate",""),re.textContent=`@keyframes ${i}{from{${d}}to{${k}}}.${i}{animation-name:${i};animation-duration:auto;animation-timing-function:${ft[s]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(re),e.classList.add(i);let C=()=>c==="x"?window.scrollX:window.scrollY,H=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(i),re.remove();},replay(){e.classList.remove(i),e.offsetWidth,e.classList.add(i);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(D){let ie=Math.min(1,Math.max(0,D));e.classList.remove(i);for(let ce of x)e.style.setProperty(ce.prop,mt(ce.from,ce.to,ie));},getProgress(){let D=e.getBoundingClientRect(),ie=C(),ce=H(),{tStart:ne,tEnd:de}=ye({top:D.top,height:D.height},ie,ce,M,L);return S(Q(ie,ne,de,f))}}}if(I())return se();let $=0,_=0,B=0,X=false,z=false,p=-1,T=0,b=false,y=NaN,q=-1,Se=0,xe=()=>g?c==="x"?g.scrollLeft:g.scrollTop:c==="x"?window.scrollX:window.scrollY,be=()=>g?c==="x"?g.clientWidth:g.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function we(){let i=e.getBoundingClientRect(),d,k;if(g){let C=g.getBoundingClientRect();d=c==="x"?i.left-C.left+g.scrollLeft:i.top-C.top+g.scrollTop,k=c==="x"?i.width:i.height;}else d=c==="x"?i.left:i.top,k=c==="x"?i.width:i.height;let re=ye({top:d,height:k},xe(),be(),M,L);$=re.tStart,_=re.tEnd;}function Ce(i){e.style.setProperty("--scroll-draw-progress",String(i));for(let d of x)e.style.setProperty(d.prop,mt(d.from,d.to,i));E?.(i);}function Ne(i){if(isNaN(y)){y=i;return}y<=0&&i>0?he?.():y>0&&i<=0&&U?.(),y<1&&i>=1?V?.():y>=1&&i<1&&ee?.(),y=i;}function te(){if(!X||z)return;let i=performance.now(),d=xe(),k=f;if(R!==false){let H=i-Se,D=H>0?Math.abs(d-(q<0?d:q))/H:0;k=f*Math.max(.2,1+D*(typeof R=="number"?R:1)*.04);}q=d,Se=i;let re=_===$?0:(d-$)/(_-$);Ne(re);let C=S(Q(d,$,_,k));l&&(p=Math.max(p,C),C=p),T=C,Ce(C),C>=1&&!b?(b=true,j?.()):C<1&&!l&&(b=false),B=requestAnimationFrame(te);}we();{let i=S(Q(xe(),$,_,f));l&&i>0&&(p=i),T=i,Ce(i);}let pe=new IntersectionObserver(i=>{i.forEach(d=>{X=d.isIntersecting,X&&!z?B=requestAnimationFrame(te):cancelAnimationFrame(B);});},{root:g??null}),J;function K(){clearTimeout(J),J=setTimeout(we,150);}return window.addEventListener("resize",K),window.addEventListener("orientationchange",K),pe.observe(e),Le(e,{type:"animate",getProgress:()=>T,getTrigger:()=>({tStart:$,tEnd:_})}),{destroy(){cancelAnimationFrame(B),pe.disconnect(),window.removeEventListener("resize",K),window.removeEventListener("orientationchange",K),clearTimeout(J),$e(e);},replay(){p=-1,b=false,T=0,z=false,Ce(0);},pause(){z=true,cancelAnimationFrame(B);},resume(){z&&(z=false,X&&(B=requestAnimationFrame(te)));},seek(i){let d=Math.min(1,Math.max(0,i));T=d,p=d,z=true,cancelAnimationFrame(B),Ce(d);},getProgress(){return T}}}var Qe={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Xe(e,n){if(typeof window>"u")return Qe;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Qe;let t=r,{from:u=0,to:s,format:f,easing:l="ease-out",trigger:c={},once:h=true,decimals:P,onComplete:R}=n,E=P!==void 0?p=>p.toFixed(P):f??(p=>String(Math.round(p))),j=typeof l=="function"?l:ae[l]??ae["ease-out"],he=le(c.start??"top 80%"),V=le(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=E(s),R?.(),Qe;t.textContent=E(u);let U=0,Z=0,S=0,M=false,L=false,g=-1,x=0,O=false,G=()=>window.scrollY,I=()=>window.innerHeight;function se(){let p=t.getBoundingClientRect(),T=ye({top:p.top,height:p.height},G(),I(),he,V);U=T.tStart,Z=T.tEnd;}function $(p){t.textContent=E(u+(s-u)*p),t.style.setProperty("--scroll-draw-progress",String(p));}function _(){if(!M||L)return;let p=j(Q(G(),U,Z,1));h&&(g=Math.max(g,p),p=g),x=p,$(p),p>=1&&!O?(O=true,R?.()):p<1&&!h&&(O=false),S=requestAnimationFrame(_);}se();{let p=j(Q(G(),U,Z,1));h&&p>0&&(g=p),x=p,$(p);}let B=new IntersectionObserver(p=>{p.forEach(T=>{M=T.isIntersecting,M&&!L?S=requestAnimationFrame(_):cancelAnimationFrame(S);});}),X;function z(){clearTimeout(X),X=setTimeout(se,150);}return window.addEventListener("resize",z),window.addEventListener("orientationchange",z),B.observe(t),Le(t,{type:"counter",getProgress:()=>x,getTrigger:()=>({tStart:U,tEnd:Z})}),{destroy(){cancelAnimationFrame(S),B.disconnect(),window.removeEventListener("resize",z),window.removeEventListener("orientationchange",z),clearTimeout(X),$e(t);},replay(){g=-1,O=false,x=0,L=false,$(0);},pause(){L=true,cancelAnimationFrame(S);},resume(){L&&(L=false,M&&(S=requestAnimationFrame(_)));},seek(p){let T=Math.min(1,Math.max(0,p));x=T,g=T,L=true,cancelAnimationFrame(S),$(T);},getProgress(){return x}}}var pt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ye(e,n={}){if(typeof window>"u")return pt;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollVideo: <video> element not found:",e),pt;let t=r,{trigger:u={},easing:s="linear",once:f=false,axis:l="y",preload:c="auto",onReady:h,onComplete:P,onProgress:R}=n,E=window.matchMedia("(prefers-reduced-motion: reduce)").matches,j=typeof s=="function"?s:ae[s]??ae.linear,he=le(u.start??"top top"),V=le(u.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=c);let ee=n.from??0,U=n.to,Z=0,S=0,M=0,L=false,g=false,x=-1,O=0,G=false,I=false,se=()=>l==="x"?window.scrollX:window.scrollY,$=()=>l==="x"?window.innerWidth:window.innerHeight;function _(){let y=t.getBoundingClientRect(),q=l==="x"?y.left:y.top,Se=l==="x"?y.width:y.height,xe=ye({top:q,height:Se},se(),$(),he,V);Z=xe.tStart,S=xe.tEnd;}function B(y){if(!I)return;let q=U??t.duration??0;t.currentTime=ee+(q-ee)*y,t.style.setProperty("--scroll-draw-progress",String(y)),R?.(y);}function X(){if(!L||g||!I)return;let y=j(Q(se(),Z,S,1));f&&(x=Math.max(x,y),y=x),O=y,B(y),y>=1&&!G?(G=true,P?.()):y<1&&!f&&(G=false),M=requestAnimationFrame(X);}function z(){if(I=true,U===void 0&&(U=t.duration),E){B(1),h?.();return}_(),h?.(),L&&!g&&(M=requestAnimationFrame(X));}t.readyState>=1?z():t.addEventListener("loadedmetadata",z,{once:true}),I||_();let p=new IntersectionObserver(y=>{y.forEach(q=>{L=q.isIntersecting,L&&!g&&I?M=requestAnimationFrame(X):cancelAnimationFrame(M);});}),T;function b(){clearTimeout(T),T=setTimeout(_,150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),p.observe(t),Le(t,{type:"video",getProgress:()=>O,getTrigger:()=>({tStart:Z,tEnd:S})}),{destroy(){cancelAnimationFrame(M),p.disconnect(),t.removeEventListener("loadedmetadata",z),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(T),$e(t);},replay(){x=-1,G=false,O=0,g=false,B(0);},pause(){g=true,cancelAnimationFrame(M);},resume(){g&&(g=false,L&&I&&(M=requestAnimationFrame(X)));},seek(y){let q=Math.min(1,Math.max(0,y));O=q,x=q,g=true,cancelAnimationFrame(M),B(q);},getProgress(){return O}}}function yt(e){let n=e.textContent??"";return e.textContent="",n.split(/(\s+)/).filter(Boolean).map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(r)?(t.textContent=r,t.style.whiteSpace="pre"):(t.textContent=r,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(r)?null:t}).filter(r=>r!==null)}function Dt(e){let n=e.textContent??"";return e.textContent="",n.split("").map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=r,r===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),r===" "?null:t}).filter(r=>r!==null)}function dt(e){let n=yt(e),r=new Map;for(let s of n){let f=s.offsetTop;r.has(f)||r.set(f,[]),r.get(f).push(s);}let t=[],u=Array.from(r.keys()).sort((s,f)=>s-f);for(let s of u){let f=r.get(s),l=document.createElement("span");l.setAttribute("aria-hidden","true"),l.style.display="inline-block";for(let c of f)l.appendChild(c);t.push(l);}e.textContent="";for(let s of t)e.appendChild(s),e.appendChild(document.createTextNode(" "));return t}function Ft(e,n,r,t){if(r<=1||t===0)return e;let u=(r-1)*t,s=n*t,f=s+(1-u);return f<=s?e>=s?1:0:Math.min(1,Math.max(0,(e-s)/(f-s)))}function Nt(e,n){let r=[];if(n?.y!==void 0&&r.push(`translateY(${n.y*(1-e)}px)`),n?.x!==void 0&&r.push(`translateX(${n.x*(1-e)}px)`),n?.rotate!==void 0&&r.push(`rotate(${n.rotate*(1-e)}deg)`),n?.scale!==void 0){let t=n.scale+(1-n.scale)*e;r.push(`scale(${t})`);}return r.join(" ")||""}var gt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function je(e,n={}){if(typeof window>"u")return gt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollText: element not found:",e),gt;let t=r,{split:u="words",stagger:s=.04,easing:f="ease-out",from:l={opacity:0,y:24},trigger:c={},once:h=true,onComplete:P}=n,R=window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=typeof f=="function"?f:ae[f]??ae["ease-out"],j=le(c.start??"top 85%"),he=le(c.end??"top 40%"),V=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let ee;u==="chars"?ee=Dt(t):u==="lines"?ee=dt(t):ee=yt(t);let U=ee.length;function Z(b,y){l?.opacity!==void 0&&(b.style.opacity=String(l.opacity+(1-l.opacity)*y));let q=Nt(y,l);q&&(b.style.transform=q);}function S(b){t.style.setProperty("--scroll-draw-progress",String(b)),ee.forEach((y,q)=>{let Se=E(Ft(b,q,U,s));Z(y,Se);});}if(R)return S(1),P?.(),{destroy(){t.innerHTML=V,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};S(0);let M=0,L=0,g=0,x=false,O=false,G=-1,I=0,se=false,$=()=>window.scrollY,_=()=>window.innerHeight;function B(){let b=t.getBoundingClientRect(),y=ye({top:b.top,height:b.height},$(),_(),j,he);M=y.tStart,L=y.tEnd;}function X(){if(!x||O)return;let b=Q($(),M,L,1);h&&(G=Math.max(G,b),b=G),I=b,S(b),b>=1&&!se?(se=true,P?.()):b<1&&!h&&(se=false),g=requestAnimationFrame(X);}B();let z=new IntersectionObserver(b=>{b.forEach(y=>{x=y.isIntersecting,x&&!O?g=requestAnimationFrame(X):cancelAnimationFrame(g);});}),p;function T(){clearTimeout(p),p=setTimeout(()=>{if(u==="lines"){let b=I;t.innerHTML=V,t.setAttribute("aria-label",t.textContent??""),ee=dt(t),S(b);}B();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),z.observe(t),Le(t,{type:"text",getProgress:()=>I,getTrigger:()=>({tStart:M,tEnd:L})}),{destroy(){cancelAnimationFrame(g),z.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(p),t.innerHTML=V,t.removeAttribute("aria-label"),$e(t);},replay(){G=-1,se=false,I=0,O=false,S(0);},pause(){O=true,cancelAnimationFrame(g);},resume(){O&&(O=false,x&&(g=requestAnimationFrame(X)));},seek(b){let y=Math.min(1,Math.max(0,b));I=y,G=y,O=true,cancelAnimationFrame(g),S(y);},getProgress(){return I}}}function ir(e,n={}){let r=Be(e,n);return {update(t){r.destroy(),r=Be(e,t);},destroy(){r.destroy();}}}function ar(e={}){let n=null;function r(t){return n=Be(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function lr(e,n){let r=Ge(e,n);return {update(t){r.destroy(),r=Ge(e,t);},destroy(){r.destroy();}}}function cr(e){let n=null;function r(t){return n=Ge(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function ur(e,n){let r=Xe(e,n);return {update(t){r.destroy(),r=Xe(e,t);},destroy(){r.destroy();}}}function mr(e){let n=null;function r(t){return n=Xe(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function fr(e,n={}){let r=Ye(e,n);return {update(t){r.destroy(),r=Ye(e,t);},destroy(){r.destroy();}}}function pr(e={}){let n=null;function r(t){return n=Ye(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function dr(e,n={}){let r=je(e,n);return {update(t){r.destroy(),r=je(e,t);},destroy(){r.destroy();}}}function gr(e={}){let n=null;function r(t){return n=je(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}export{cr as createScrollAnimate,mr as createScrollCounter,ar as createScrollDraw,gr as createScrollText,pr as createScrollVideo,lr as scrollAnimate,ur as scrollCounterAction,ir as scrollDraw,dr as scrollTextAction,fr as scrollVideoAction};
1
+ function Vt({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),l=Math.sqrt(t),s=0,c=[];for(let d=0;d<r;d++){let x=Math.pow(l,d);c.push(x),s+=x;}let u=[0],m=0;for(let d=0;d<r;d++)m+=c[d]/s,u.push(m);return d=>{if(d<=0)return 0;if(d>=1)return 1;for(let x=0;x<r;x++)if(d<=u[x+1]){let N=(d-u[x])/(u[x+1]-u[x]);if(x===0)return N*(2-N);let L=1-Math.pow(t,x);return L+(1-L)*(2*N-1)*(2*N-1)}return 1}}function zt({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),l=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return s=>s<=0?0:s>=1?1:r*Math.pow(2,-10*s)*Math.sin((s-l)*(2*Math.PI)/t)+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:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Vt(),elastic:zt()};function fe(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",t="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:t}}function wt(e,n,r,t){switch(t){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function vt(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function ze(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function _t(e,n,r){return Math.min(r,Math.max(n,e))}function Q(e,n,r,t){return r===n?0:_t((e-n)/(r-n)*t,0,1)}function Qe(e,n,r){let t=e.getBoundingClientRect(),l=r==="x"?t.width:t.height;return n?{top:r==="x"?t.left-n.getBoundingClientRect().left+n.scrollLeft:t.top-n.getBoundingClientRect().top+n.scrollTop,height:l,scroll:0}:{top:r==="x"?t.left:t.top,height:l,scroll:r==="x"?window.scrollX:window.scrollY}}function xe(e,n,r,t,l){let s=wt(e.top,e.height,n,t.element)-vt(t.viewport,r),c=wt(e.top,e.height,n,l.element)-vt(l.viewport,r);return {tStart:s,tEnd:c}}function St(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let t=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return t?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]:null}function _e(e,n,r){let t=St(e),l=St(n);return !t||!l?e:`rgb(${Math.round(t[0]+(l[0]-t[0])*r)},${Math.round(t[1]+(l[1]-t[1])*r)},${Math.round(t[2]+(l[2]-t[2])*r)})`}var Et={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 be(e,...n){Ze&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var qt="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Wt="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",Tt=33;function Bt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Gt(e){let n=[];for(let r=0;r<Tt;r++){let t=r/(Tt-1);n.push(String(Math.round(e(t)*1e5)/1e5));}return `linear(${n.join(",")})`}function Ke(e){switch(e){case "linear":return "linear";case "ease-in":return qt;case "ease-out":return Wt;case "ease-in-out":return Bt()?Gt(ee["ease-in-out"]):null;default:return null}}var xt=Symbol.for("svg-scroll-draw.registry");function At(){let e=globalThis;return e[xt]||(e[xt]=new Map)}function Le(e,n){At().set(e,n);}function $e(e){At().delete(e);}var jt=0;function Yt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function Ut(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?be("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&be("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Xt(e,n,r){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.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 l(){let s=r==="x"?window.scrollX:window.scrollY,c=e-s,u=n-s,m=r==="x";t.innerHTML=`
2
+ <div style="position:absolute;${m?`left:${c}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${c}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;${m?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",l,{passive:true}),l(),{el:t,destroy(){window.removeEventListener("scroll",l),t.remove();}}}var Mt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Lt=/[MmLlHhVvCcSsQqTtAaZz]/g;function Qt(e,n,r){if(!Ze)return;let t=(e.match(Lt)??[]).join("").toUpperCase(),l=(n.match(Lt)??[]).join("").toUpperCase(),s=(e.match(Mt)??[]).length,c=(n.match(Mt)??[]).length;if(t!==l){be(`morphTo: command sequence differs (${t||"\u2205"} \u2192 ${l||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}s!==c&&be(`morphTo: coordinate count differs (${s} \u2192 ${c}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function ct(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let c=parseFloat(s),u=t[l++]??c;return String(+(c+(u-c)*r).toFixed(4))})}function Je(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,l=r?{...Et[r],...t}:t,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:c="path, polyline, line, polygon, rect, circle",speed:u=1,fade:m=false,easing:d="linear",trigger:x={},stagger:N=0,direction:L="forward",once:te=false,debug:Ce=false,axis:W="y",scrollContainer:Z,autoReverse:U=false,delay:B=0,strokeColor:A,strokeWidth:$,fillOpacity:M,waypoints:v,velocityScale:I=false,threshold:O=0,rootMargin:C="0px",repeat:E=0,repeatDelay:re=0,morphTo:k,clip:ne,autoplay:oe=false,duration:K=1e3,native:ce=true,onProgress:y,onStart:T,onComplete:g,onEnter:p,onLeave:F,onEnterBack:pe,onLeaveBack:Se}=l,ue=ne===true?"left":typeof ne=="string"?ne:false,Ee=typeof d=="function"?d:ee[d]??ee.linear,Pe=fe(x.start??"top bottom"),Ne=fe(x.end??"bottom top"),we=typeof Z=="string"?document.querySelector(Z):Z??null,ve=Array.isArray(A)?A[0]:null,se=Array.isArray(A)?A[1]:typeof A=="string"?A:null,ie=Array.isArray($)?$[0]:null,G=Array.isArray($)?$[1]:typeof $=="number"?$:null,me=Array.isArray(M)?M[0]:null,X=Array.isArray(M)?M[1]:typeof M=="number"?M:null;function Ie(o){let a=o*100;switch(ue){case "right":return `inset(0 0 0 ${100-a}%)`;case "top":return `inset(0 0 ${100-a}% 0)`;case "bottom":return `inset(${100-a}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-a}% 0 0)`}}let V=ue?[]:Array.from(e.querySelectorAll(c)),P=[],i=[],f=0,de=0,R=false,z=false,_=0,Ae=false,ge=-1,J=-1,j=false,ye=0,ke=0,Fe,ot=null;function mt(){ot?.destroy(),ot=null;}let Re=new Set,ft=NaN,He=true,Be=-1,pt=performance.now(),Ve=NaN;function st(){return we?W==="x"?we.scrollLeft:we.scrollTop:W==="x"?window.scrollX:window.scrollY}function dt(){return we?W==="x"?we.clientWidth:we.clientHeight:W==="x"?window.innerWidth:window.innerHeight}function gt(){let o=Qe(e,we,W);return xe(o,o.scroll,dt(),Pe,Ne)}function yt(){(({tStart:f,tEnd:de}=gt())),Ce&&Ze&&(mt(),ot=Xt(f,de,W));}function it(o,a=gt){Le(e,{type:"draw",getProgress:()=>o.getProgress(),getTrigger:a});let w=o.destroy;return o.destroy=()=>{w.call(o),$e(e);},o}function Ft(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),ue){let w=a==="reverse"?1-o:o;e.style.clipPath=Ie(w);return}V.forEach((w,ae)=>{w.style.strokeDashoffset=a==="reverse"?`${P[ae]*o}`:`${P[ae]*(1-o)}`,m&&(w.style.opacity=a==="reverse"?`${1-o}`:`${o}`),ve&&se?w.style.stroke=_e(ve,se,o):se&&(w.style.stroke=se),ie!==null&&G!==null?w.style.strokeWidth=`${ie+(G-ie)*o}`:G!==null&&(w.style.strokeWidth=`${G}`),me!==null&&X!==null?w.style.fillOpacity=`${me+(X-me)*o}`:X!==null&&(w.style.fillOpacity=`${X}`),k&&w.tagName.toLowerCase()==="path"&&i[ae]&&w.setAttribute("d",ct(i[ae],k,o));});}function Ge(){if(e.style.setProperty("--scroll-draw-progress","0"),ue){e.style.clipPath=Ie(0);return}V.forEach((o,a)=>{o.style.strokeDasharray=`${P[a]}`,o.style.strokeDashoffset=L==="reverse"?"0":`${P[a]}`,m?o.style.opacity=L==="reverse"?"1":"0":o.style.opacity="",ve&&(o.style.stroke=ve),ie!==null&&(o.style.strokeWidth=`${ie}`),me!==null&&(o.style.fillOpacity=`${me}`),k&&o.tagName.toLowerCase()==="path"&&i[a]&&o.setAttribute("d",i[a]);});}if(V.forEach(o=>{Ut(o);let a=ze(o);P.push(a);let w=o.tagName.toLowerCase()==="path";w?i.push(o.getAttribute("d")??""):i.push(""),k&&(w?Qt(i[i.length-1],k,o):be(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),s?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=L==="reverse"?`${a}`:"0",m&&(o.style.opacity="1"),se&&(o.style.stroke=se),G!==null&&(o.style.strokeWidth=`${G}`),X!==null&&(o.style.fillOpacity=`${X}`),k&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",k)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=L==="reverse"?"0":`${a}`,m?o.style.opacity=L==="reverse"?"1":"0":o.style.opacity="",ve&&(o.style.stroke=ve),ie!==null&&(o.style.strokeWidth=`${ie}`),me!==null&&(o.style.fillOpacity=`${me}`));}),ue){if(s)return e.style.clipPath=Ie(1),g?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=Ie(0);}else if(s)return g?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let ht=typeof d=="string"?Ke(d):null;function Rt(){return !(ce===false||!Yt()||!V.length||!ht||ue||W!=="y"||we||u!==1||N!==0||te||U||I!==false||k||v||E||B>0||y||T||g||p||F||pe||Se||A!=null||$!=null||M!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function Ht(){let o=++jt,a=`svg-scroll-draw-${o}`,w=`svg-scroll-draw-host-${o}`,ae=`--svg-scroll-draw-${o}`,De=L==="reverse"?"0":"var(--ssd-len)",Oe=L==="reverse"?"var(--ssd-len)":"0",Me=`stroke-dashoffset:${De};`,S=`stroke-dashoffset:${Oe};`;m&&(Me+=`opacity:${L==="reverse"?1:0};`,S+=`opacity:${L==="reverse"?0:1};`);let D=document.createElement("style");D.setAttribute("data-svg-scroll-draw",""),D.textContent=`@keyframes ${a}{from{${Me}}to{${S}}}.${w}{view-timeline-name:${ae};view-timeline-axis:block;}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${ht};animation-fill-mode:both;animation-timeline:${ae};animation-range:cover 0% cover 100%;}`,document.head.appendChild(D),e.classList.add(w);function le(h,Y){h.style.setProperty("--ssd-len",String(P[Y])),h.style.strokeDasharray=`${P[Y]}`,h.style.strokeDashoffset="",h.style.opacity="",h.style.animationPlayState="",h.classList.add(a);}V.forEach(le);let b=false,H=-1;function q(){if(H>=0)return H;let h=e.getBoundingClientRect(),{tStart:Y,tEnd:Te}=xe({top:h.top,height:h.height},st(),dt(),Pe,Ne);return Ee(Q(st(),Y,Te,u))}return {destroy(){e.classList.remove(w),V.forEach(h=>{h.classList.remove(a),h.style.removeProperty("--ssd-len"),h.style.animationPlayState="";}),D.remove();},replay(){b=false,H=-1,V.forEach(le);},pause(){b=true,V.forEach(h=>{h.style.animationPlayState="paused";});},resume(){b&&(b=false,V.forEach(h=>{h.style.animationPlayState="running";}));},seek(h){let Y=Math.min(1,Math.max(0,h));H=Y,b=true,V.forEach((Te,he)=>{Te.classList.remove(a),Te.style.strokeDashoffset=L==="reverse"?`${P[he]*Y}`:`${P[he]*(1-Y)}`,m&&(Te.style.opacity=L==="reverse"?`${1-Y}`:`${Y}`);});},getProgress(){return q()},refresh(){V.forEach((h,Y)=>{P[Y]=ze(h),h.style.setProperty("--ssd-len",String(P[Y])),h.style.strokeDasharray=`${P[Y]}`;});}}}if(Rt())return it(Ht());function Nt(){let o=Math.max(1,K),a=0,w=0,ae=false;function De(b){let H=true;if(ue){let q=Math.min(1,Math.max(0,b/o)),h=Ee(q);ye=h,e.style.setProperty("--scroll-draw-progress",String(h)),e.style.clipPath=Ie(L==="reverse"?1-h:h),y?.(h),q<1&&(H=false);}else V.forEach((q,h)=>{let Y=h*N*o,Te=Math.min(1,Math.max(0,(b-Y)/o)),he=Ee(Te);q.style.strokeDashoffset=L==="reverse"?`${P[h]*he}`:`${P[h]*(1-he)}`,m&&(q.style.opacity=L==="reverse"?`${1-he}`:`${he}`),ve&&se?q.style.stroke=_e(ve,se,he):se&&(q.style.stroke=se),ie!==null&&G!==null?q.style.strokeWidth=`${ie+(G-ie)*he}`:G!==null&&(q.style.strokeWidth=`${G}`),me!==null&&X!==null?q.style.fillOpacity=`${me+(X-me)*he}`:X!==null&&(q.style.fillOpacity=`${X}`),k&&q.tagName.toLowerCase()==="path"&&i[h]&&q.setAttribute("d",ct(i[h],k,he)),h===0&&(ye=he,y?.(he),e.style.setProperty("--scroll-draw-progress",String(he))),Te<1&&(H=false);});if(v){let q=Math.min(1,Math.max(0,b/o)),h=Ee(q);for(let Y in v){let Te=parseFloat(Y);h>=Te&&!Re.has(Te)&&(Re.add(Te),v[Y]?.());}}return H}function Oe(b){if(j)return;let H=b-a;z||(z=true,T?.());let q=De(H);if(q&&!R){R=true,De(o*(1+Math.max(0,V.length-1)*N)),g?.(),ke<(E==="infinite"?1/0:E??0)&&(ke++,Fe=setTimeout(()=>{a=performance.now(),z=false,R=false,Re.clear(),Ge(),_=requestAnimationFrame(Oe);},re));return}q||(_=requestAnimationFrame(Oe));}function Me(){cancelAnimationFrame(_),clearTimeout(Fe),a=performance.now(),w=0,j=false,z=false,R=false,ke=0,ae=true,ye=0,Re.clear(),Ge(),_=requestAnimationFrame(Oe);}let S=new IntersectionObserver(b=>{b.forEach(H=>{H.isIntersecting&&!(te&&R)?Me():!H.isIntersecting&&!te&&!R&&(cancelAnimationFrame(_),clearTimeout(Fe),ae=false);});},{root:we??null,threshold:O,rootMargin:C}),D;function le(){clearTimeout(D),D=setTimeout(()=>{V.forEach((b,H)=>{P[H]=ze(b),b.style.strokeDasharray=`${P[H]}`;});},150);}return window.addEventListener("resize",le),window.addEventListener("orientationchange",le),B>0?setTimeout(()=>S.observe(e),B):S.observe(e),{destroy(){cancelAnimationFrame(_),clearTimeout(Fe),S.disconnect(),window.removeEventListener("resize",le),window.removeEventListener("orientationchange",le),clearTimeout(D);},replay(){ke=0,Me();},pause(){j||!ae||(j=true,w=performance.now()-a,cancelAnimationFrame(_));},resume(){j&&(j=false,ae=true,a=performance.now()-w,_=requestAnimationFrame(Oe));},seek(b){let H=Math.min(1,Math.max(0,b));ye=H,j=true,w=H*o,a=performance.now()-w,cancelAnimationFrame(_),De(w);},getProgress(){return ye},refresh(){clearTimeout(D),V.forEach((b,H)=>{P[H]=ze(b),b.style.strokeDasharray=`${P[H]}`;});}}}if(oe)return it(Nt());yt();function je(){if(!Ae||j)return;let o=performance.now(),a=st();if(!He&&I===false&&a===ft){_=requestAnimationFrame(je);return}He=false,ft=a;let w=u;if(I!==false){let S=o-pt,D=S>0?Math.abs(a-(Be<0?a:Be))/S:0;w=u*Math.max(.2,1+D*(typeof I=="number"?I:1)*.04);}Be=a,pt=o;let ae=U?J===-1||a>=J?"forward":"reverse":L;J=a;let De=de-f,Oe=true,Me=De===0?0:(a-f)/De;if(isNaN(Ve)||(Ve<=0&&Me>0?p?.():Ve>0&&Me<=0&&Se?.(),Ve<1&&Me>=1?F?.():Ve>=1&&Me<1&&pe?.()),Ve=Me,ue){let S=Ee(Q(a,f,de,w));te&&!U&&(ge=Math.max(ge,S),S=ge),ye=S,e.style.setProperty("--scroll-draw-progress",String(S));let D=ae==="reverse"?1-S:S;e.style.clipPath=Ie(D),y?.(S),!z&&Q(a,f,de,w)>0&&(z=true,T?.()),S>=1&&!R?(R=true,g?.(),ke<(E==="infinite"?1/0:E??0)&&(ke++,Fe=setTimeout(()=>{ge=-1,z=false,R=false,e.style.clipPath=Ie(0);},re))):S<1&&!te&&(R=false),_=requestAnimationFrame(je);return}if(V.forEach((S,D)=>{let le=D*N*De,b=Ee(Q(a,f+le,de+le,w));te&&!U&&(ge=Math.max(ge,b),b=ge),ye=b,S.style.strokeDashoffset=ae==="reverse"?`${P[D]*b}`:`${P[D]*(1-b)}`,m&&(S.style.opacity=ae==="reverse"?`${1-b}`:`${b}`),ve&&se?S.style.stroke=_e(ve,se,b):se&&(S.style.stroke=se),ie!==null&&G!==null?S.style.strokeWidth=`${ie+(G-ie)*b}`:G!==null&&(S.style.strokeWidth=`${G}`),me!==null&&X!==null?S.style.fillOpacity=`${me+(X-me)*b}`:X!==null&&(S.style.fillOpacity=`${X}`),k&&S.tagName.toLowerCase()==="path"&&i[D]&&S.setAttribute("d",ct(i[D],k,b)),D===0&&(y?.(b),e.style.setProperty("--scroll-draw-progress",String(b))),b<1&&(Oe=false);}),v){let S=Ee(Q(a,f,de,w));for(let D in v){let le=parseFloat(D);S>=le&&!Re.has(le)&&(Re.add(le),v[D]?.());}}!z&&Q(a,f,de,w)>0&&(z=true,T?.()),Oe&&!R?(R=true,g?.(),ke<(E==="infinite"?1/0:E??0)&&(ke++,Fe=setTimeout(()=>{ge=-1,z=false,R=false,Re.clear(),Ge(),He=true;},re))):!Oe&&!te&&(R=false),_=requestAnimationFrame(je);}let at=false;function Ye(){at||(at=true,_=requestAnimationFrame(function(){je();}));}function Ue(){at=false,cancelAnimationFrame(_);}let lt=new IntersectionObserver(o=>{o.forEach(a=>{Ae=a.isIntersecting,Ae&&!j?(He=true,Ye()):Ue();});},{root:we??null,threshold:O,rootMargin:C});function bt(){V.forEach((o,a)=>{P[a]=ze(o),o.style.strokeDasharray=`${P[a]}`;}),yt(),He=true;}let Xe;function qe(){clearTimeout(Xe),Xe=setTimeout(bt,150);}window.addEventListener("resize",qe),window.addEventListener("orientationchange",qe);let We;return typeof ResizeObserver<"u"&&(We=new ResizeObserver(()=>qe()),We.observe(document.body),We.observe(document.documentElement),We.observe(e)),B>0?setTimeout(()=>lt.observe(e),B):lt.observe(e),it({destroy(){cancelAnimationFrame(_),clearTimeout(Fe),Ue(),lt.disconnect(),We?.disconnect(),window.removeEventListener("resize",qe),window.removeEventListener("orientationchange",qe),clearTimeout(Xe),mt();},replay(){ge=-1,J=-1,Be=-1,z=false,R=false,ke=0,j=false,ye=0,Re.clear(),clearTimeout(Fe),Ge(),He=true,Ae&&Ye();},pause(){j=true,Ue();},resume(){j&&(j=false,He=true,Ae&&Ye());},seek(o){let a=Math.min(1,Math.max(0,o));ye=a,ge=a,j=true,Ue(),Ft(a,L),He=true;},getProgress(){return ye},refresh(){clearTimeout(Xe),bt(),Ae&&!j&&Ye();}},()=>({tStart:f,tEnd:de}))}function Zt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function $t(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let l=[],s=[],c=t[2].trim();if(c)for(let u of c.split(/[\s,]+/)){let m=u.match(/^([-+]?[\d.eE]+)(.*)$/);l.push(m?parseFloat(m[1]):0),s.push(m?m[2]:"");}n.push({fn:t[1],nums:l,units:s});}return n}function Kt(e,n,r){let t=$t(e),l=$t(n);return t.length===0||t.length!==l.length?r<1?e:n:t.map((s,c)=>{let u=l[c];return s.fn!==u.fn||s.nums.length!==u.nums.length?r<1?`${s.fn}(${s.nums.map((m,d)=>`${m}${s.units[d]}`).join(", ")})`:`${u.fn}(${u.nums.map((m,d)=>`${m}${u.units[d]}`).join(", ")})`:`${s.fn}(${s.nums.map((m,d)=>`${m+(u.nums[d]-m)*r}${s.units[d]}`).join(", ")})`}).join(" ")}function Ct(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),l=String(n);if(Zt(t))return _e(t,l,r);if(t.includes("("))return Kt(t,l,r);let s=t.match(/^([-+]?[\d.]+)(.*)$/),c=l.match(/^([-+]?[\d.]+)(.*)$/);if(s&&c){let u=parseFloat(s[1]),m=parseFloat(c[1]);return `${u+(m-u)*r}${s[2]||c[2]}`}return r<1?t:l}function Jt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var er=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),tr=0,Pt="--scroll-draw-progress";function rr(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function et(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:l={},easing:s="ease-out",speed:c=1,once:u=false,axis:m="y",scrollContainer:d,native:x=true,velocityScale:N=false,respectReducedMotion:L=true,triggerElement:te,onProgress:Ce,onComplete:W,onEnter:Z,onLeave:U,onEnterBack:B,onLeaveBack:A}=n,$=L&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,M=typeof s=="function"?s:ee[s]??ee["ease-out"],v=fe(l.start??"top bottom"),I=fe(l.end??"bottom top"),O=te??e,C=typeof d=="string"?document.querySelector(d):d??null,E=Object.entries(t).map(([i,f])=>({prop:Jt(i),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function re(){let i=window.getComputedStyle(e);for(let f of E)f.from===""&&(f.from=i.getPropertyValue(f.prop).trim()||"0");}function k(){for(let i of E)e.style.setProperty(i.prop,String(i.to));}let ne=new Map;for(let i of [...E.map(f=>f.prop),Pt])ne.set(i,e.style.getPropertyValue(i));function oe(){for(let[i,f]of ne)f?e.style.setProperty(i,f):e.style.removeProperty(i);}if($)return k(),W?.(),{...r,destroy:oe,getProgress:()=>1};re();let K=typeof s=="string"?Ke(s):null;function ce(){if(!x||!rr()||!K||m!=="y"||C||O!==e||u||c!==1||Ce||W||Z||U||B||A||N!==false||(l.start??"top bottom").trim()!=="top bottom"||(l.end??"bottom top").trim()!=="bottom top")return false;for(let i of E)if(!er.has(i.prop))return false;return true}function y(){let i=`ssd-a-${++tr}`,f=E.map(J=>`${J.prop}:${J.from}`).join(";"),de=E.map(J=>`${J.prop}:${J.to}`).join(";"),R=document.createElement("style");R.setAttribute("data-ssd-animate",""),R.textContent=`@keyframes ${i}{from{${f}}to{${de}}}.${i}{animation-name:${i};animation-duration:auto;animation-timing-function:${K};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(R),e.classList.add(i);let z=()=>m==="x"?window.scrollX:window.scrollY,_=()=>m==="x"?window.innerWidth:window.innerHeight,Ae=()=>{let J=e.getBoundingClientRect();return xe({top:J.top,height:J.height},z(),_(),v,I)};Le(e,{type:"animate",getProgress:()=>ge.getProgress(),getTrigger:Ae});let ge={destroy(){e.classList.remove(i),R.remove(),e.style.animationPlayState="",oe(),$e(e);},replay(){e.classList.remove(i),e.offsetWidth,e.classList.add(i);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(J){let j=Math.min(1,Math.max(0,J));e.classList.remove(i);for(let ye of E)e.style.setProperty(ye.prop,Ct(ye.from,ye.to,j));},getProgress(){let{tStart:J,tEnd:j}=Ae();return M(Q(z(),J,j,c))}};return ge}if(ce())return y();let T=0,g=0,p=0,F=false,pe=false,Se=-1,ue=0,Ee=false,Pe=NaN,Ne=-1,we=0,ve=()=>C?m==="x"?C.scrollLeft:C.scrollTop:m==="x"?window.scrollX:window.scrollY,se=()=>C?m==="x"?C.clientWidth:C.clientHeight:m==="x"?window.innerWidth:window.innerHeight;function ie(){let i=Qe(O,C,m),f=xe(i,i.scroll,se(),v,I);T=f.tStart,g=f.tEnd;}function G(i){e.style.setProperty(Pt,String(i));for(let f of E)e.style.setProperty(f.prop,Ct(f.from,f.to,i));Ce?.(i);}function me(i){if(isNaN(Pe)){Pe=i;return}Pe<=0&&i>0?Z?.():Pe>0&&i<=0&&A?.(),Pe<1&&i>=1?U?.():Pe>=1&&i<1&&B?.(),Pe=i;}function X(){if(!F||pe)return;let i=performance.now(),f=ve(),de=c;if(N!==false){let _=i-we,Ae=_>0?Math.abs(f-(Ne<0?f:Ne))/_:0;de=c*Math.max(.2,1+Ae*(typeof N=="number"?N:1)*.04);}Ne=f,we=i;let R=g===T?0:(f-T)/(g-T);me(R);let z=M(Q(f,T,g,de));u&&(Se=Math.max(Se,z),z=Se),ue=z,G(z),z>=1&&!Ee?(Ee=true,W?.()):z<1&&!u&&(Ee=false),p=requestAnimationFrame(X);}ie(),g===T&&be("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let i=M(Q(ve(),T,g,c));u&&i>0&&(Se=i),ue=i,G(i);}let Ie=new IntersectionObserver(i=>{i.forEach(f=>{F=f.isIntersecting,F&&!pe?p=requestAnimationFrame(X):cancelAnimationFrame(p);});},{root:C??null}),V;function P(){clearTimeout(V),V=setTimeout(ie,150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),Ie.observe(e),Le(e,{type:"animate",getProgress:()=>ue,getTrigger:()=>({tStart:T,tEnd:g})}),{destroy(){cancelAnimationFrame(p),Ie.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),clearTimeout(V),oe(),$e(e);},replay(){Se=-1,Ee=false,ue=0,pe=false,G(0);},pause(){pe=true,cancelAnimationFrame(p);},resume(){pe&&(pe=false,F&&(p=requestAnimationFrame(X)));},seek(i){let f=Math.min(1,Math.max(0,i));ue=f,Se=f,pe=true,cancelAnimationFrame(p),G(f);},getProgress(){return ue}}}var ut={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function tt(e,n){if(typeof window>"u")return ut;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return be("scrollCounter: element not found:",e),ut;let t=r,{from:l=0,to:s,format:c,easing:u="ease-out",trigger:m={},once:d=true,decimals:x,onComplete:N}=n,L=x!==void 0?y=>y.toFixed(x):c??(y=>String(Math.round(y))),te=typeof u=="function"?u:ee[u]??ee["ease-out"],Ce=fe(m.start??"top 80%"),W=fe(m.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=L(s),N?.(),ut;let U=0,B=0,A=0,$=false,M=false,v=-1,I=0,O=false,C=()=>window.scrollY,E=()=>window.innerHeight;function re(){let y=t.getBoundingClientRect(),T=xe({top:y.top,height:y.height},C(),E(),Ce,W);U=T.tStart,B=T.tEnd;}function k(y){t.textContent=L(l+(s-l)*y),t.style.setProperty("--scroll-draw-progress",String(y));}function ne(){if(!$||M)return;let y=te(Q(C(),U,B,1));d&&(v=Math.max(v,y),y=v),I=y,k(y),y>=1&&!O?(O=true,N?.()):y<1&&!d&&(O=false),A=requestAnimationFrame(ne);}re();{let y=te(Q(C(),U,B,1));d&&y>0&&(v=y),I=y,k(y);}let oe=new IntersectionObserver(y=>{y.forEach(T=>{$=T.isIntersecting,$&&!M?A=requestAnimationFrame(ne):cancelAnimationFrame(A);});}),K;function ce(){clearTimeout(K),K=setTimeout(re,150);}return window.addEventListener("resize",ce),window.addEventListener("orientationchange",ce),oe.observe(t),Le(t,{type:"counter",getProgress:()=>I,getTrigger:()=>({tStart:U,tEnd:B})}),{destroy(){cancelAnimationFrame(A),oe.disconnect(),window.removeEventListener("resize",ce),window.removeEventListener("orientationchange",ce),clearTimeout(K),$e(t);},replay(){v=-1,O=false,I=0,M=false,k(0);},pause(){M=true,cancelAnimationFrame(A);},resume(){M&&(M=false,$&&(A=requestAnimationFrame(ne)));},seek(y){let T=Math.min(1,Math.max(0,y));I=T,v=T,M=true,cancelAnimationFrame(A),k(T);},getProgress(){return I}}}var It={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function rt(e,n={}){if(typeof window>"u")return It;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return be("scrollVideo: <video> element not found:",e),It;let t=r,{trigger:l={},easing:s="linear",once:c=false,axis:u="y",preload:m="auto",onReady:d,onComplete:x,onProgress:N}=n,L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,te=typeof s=="function"?s:ee[s]??ee.linear,Ce=fe(l.start??"top top"),W=fe(l.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=m);let Z=n.from??0,U=n.to,B=0,A=0,$=0,M=false,v=false,I=-1,O=0,C=false,E=false,re=()=>u==="x"?window.scrollX:window.scrollY,k=()=>u==="x"?window.innerWidth:window.innerHeight;function ne(){let p=t.getBoundingClientRect(),F=u==="x"?p.left:p.top,pe=u==="x"?p.width:p.height,Se=xe({top:F,height:pe},re(),k(),Ce,W);B=Se.tStart,A=Se.tEnd;}function oe(p){if(!E)return;let F=U??t.duration??0;t.currentTime=Z+(F-Z)*p,t.style.setProperty("--scroll-draw-progress",String(p)),N?.(p);}function K(){if(!M||v||!E)return;let p=te(Q(re(),B,A,1));c&&(I=Math.max(I,p),p=I),O=p,oe(p),p>=1&&!C?(C=true,x?.()):p<1&&!c&&(C=false),$=requestAnimationFrame(K);}function ce(){if(E=true,U===void 0&&(U=t.duration),L){oe(1),d?.();return}ne(),d?.(),M&&!v&&($=requestAnimationFrame(K));}t.readyState>=1?ce():t.addEventListener("loadedmetadata",ce,{once:true}),E||ne();let y=new IntersectionObserver(p=>{p.forEach(F=>{M=F.isIntersecting,M&&!v&&E?$=requestAnimationFrame(K):cancelAnimationFrame($);});}),T;function g(){clearTimeout(T),T=setTimeout(ne,150);}return window.addEventListener("resize",g),window.addEventListener("orientationchange",g),y.observe(t),Le(t,{type:"video",getProgress:()=>O,getTrigger:()=>({tStart:B,tEnd:A})}),{destroy(){cancelAnimationFrame($),y.disconnect(),t.removeEventListener("loadedmetadata",ce),window.removeEventListener("resize",g),window.removeEventListener("orientationchange",g),clearTimeout(T),$e(t);},replay(){I=-1,C=false,O=0,v=false,oe(0);},pause(){v=true,cancelAnimationFrame($);},resume(){v&&(v=false,M&&E&&($=requestAnimationFrame(K)));},seek(p){let F=Math.min(1,Math.max(0,p));O=F,I=F,v=true,cancelAnimationFrame($),oe(F);},getProgress(){return O}}}function Dt(e){let n=e.textContent??"";return e.textContent="",n.split(/(\s+)/).filter(Boolean).map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(r)?(t.textContent=r,t.style.whiteSpace="pre"):(t.textContent=r,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(r)?null:t}).filter(r=>r!==null)}function nr(e){let n=e.textContent??"";return e.textContent="",n.split("").map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=r,r===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),r===" "?null:t}).filter(r=>r!==null)}function Ot(e){let n=Dt(e),r=new Map;for(let s of n){let c=s.offsetTop;r.has(c)||r.set(c,[]),r.get(c).push(s);}let t=[],l=Array.from(r.keys()).sort((s,c)=>s-c);for(let s of l){let c=r.get(s),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block",c.forEach((m,d)=>{let x=m.nextElementSibling;u.appendChild(m),d<c.length-1&&x&&x.style.whiteSpace==="pre"&&u.appendChild(x);}),t.push(u);}return e.textContent="",t.forEach((s,c)=>{e.appendChild(s),c<t.length-1&&e.appendChild(document.createTextNode(" "));}),t}function or(e,n,r,t){if(r<=1||t===0)return e;let l=(r-1)*t,s=n*t,c=s+(1-l);return c<=s?e>=s?1:0:Math.min(1,Math.max(0,(e-s)/(c-s)))}function sr(e,n){let r=[];if(n?.y!==void 0&&r.push(`translateY(${n.y*(1-e)}px)`),n?.x!==void 0&&r.push(`translateX(${n.x*(1-e)}px)`),n?.rotate!==void 0&&r.push(`rotate(${n.rotate*(1-e)}deg)`),n?.scale!==void 0){let t=n.scale+(1-n.scale)*e;r.push(`scale(${t})`);}return r.join(" ")||""}var kt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function nt(e,n={}){if(typeof window>"u")return kt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return be("scrollText: element not found:",e),kt;let t=r,{split:l="words",stagger:s=.04,easing:c="ease-out",from:u={opacity:0,y:24},trigger:m={},once:d=true,onComplete:x}=n,N=window.matchMedia("(prefers-reduced-motion: reduce)").matches,L=typeof c=="function"?c:ee[c]??ee["ease-out"],te=fe(m.start??"top 85%"),Ce=fe(m.end??"top 40%"),W=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let Z;l==="chars"?Z=nr(t):l==="lines"?Z=Ot(t):Z=Dt(t);let U=Z.length;function B(g,p){u?.opacity!==void 0&&(g.style.opacity=String(u.opacity+(1-u.opacity)*p));let F=sr(p,u);F&&(g.style.transform=F);}function A(g){t.style.setProperty("--scroll-draw-progress",String(g)),Z.forEach((p,F)=>{let pe=L(or(g,F,U,s));B(p,pe);});}if(N)return A(1),x?.(),{destroy(){t.innerHTML=W,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};A(0);let $=0,M=0,v=0,I=false,O=false,C=-1,E=0,re=false,k=()=>window.scrollY,ne=()=>window.innerHeight;function oe(){let g=t.getBoundingClientRect(),p=xe({top:g.top,height:g.height},k(),ne(),te,Ce);$=p.tStart,M=p.tEnd;}function K(){if(!I||O)return;let g=Q(k(),$,M,1);d&&(C=Math.max(C,g),g=C),E=g,A(g),g>=1&&!re?(re=true,x?.()):g<1&&!d&&(re=false),v=requestAnimationFrame(K);}oe();let ce=new IntersectionObserver(g=>{g.forEach(p=>{I=p.isIntersecting,I&&!O?v=requestAnimationFrame(K):cancelAnimationFrame(v);});}),y;function T(){clearTimeout(y),y=setTimeout(()=>{if(l==="lines"){let g=E;t.innerHTML=W,t.setAttribute("aria-label",t.textContent??""),Z=Ot(t),A(g);}oe();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),ce.observe(t),Le(t,{type:"text",getProgress:()=>E,getTrigger:()=>({tStart:$,tEnd:M})}),{destroy(){cancelAnimationFrame(v),ce.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(y),t.innerHTML=W,t.removeAttribute("aria-label"),$e(t);},replay(){C=-1,re=false,E=0,O=false,A(0);},pause(){O=true,cancelAnimationFrame(v);},resume(){O&&(O=false,I&&(v=requestAnimationFrame(K)));},seek(g){let p=Math.min(1,Math.max(0,g));E=p,C=p,O=true,cancelAnimationFrame(v),A(p);},getProgress(){return E}}}function zr(e,n={}){let r=Je(e,n);return {update(t){r.destroy(),r=Je(e,t);},destroy(){r.destroy();}}}function _r(e={}){let n=null;function r(t){return n=Je(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function qr(e,n){let r=et(e,n);return {update(t){r.destroy(),r=et(e,t);},destroy(){r.destroy();}}}function Wr(e){let n=null;function r(t){return n=et(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function Br(e,n){let r=tt(e,n);return {update(t){r.destroy(),r=tt(e,t);},destroy(){r.destroy();}}}function Gr(e){let n=null;function r(t){return n=tt(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function jr(e,n={}){let r=rt(e,n);return {update(t){r.destroy(),r=rt(e,t);},destroy(){r.destroy();}}}function Yr(e={}){let n=null;function r(t){return n=rt(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}function Ur(e,n={}){let r=nt(e,n);return {update(t){r.destroy(),r=nt(e,t);},destroy(){r.destroy();}}}function Xr(e={}){let n=null;function r(t){return n=nt(t,e),{destroy(){n?.destroy(),n=null;}}}return {action:r,getInstance:()=>n}}export{Wr as createScrollAnimate,Gr as createScrollCounter,_r as createScrollDraw,Xr as createScrollText,Yr as createScrollVideo,qr as scrollAnimate,Br as scrollCounterAction,zr as scrollDraw,Ur as scrollTextAction,jr as scrollVideoAction};
@@ -1 +1 @@
1
- 'use strict';function Q({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(t),o=0,i=[];for(let u=0;u<n;u++){let l=Math.pow(c,u);i.push(l),o+=l;}let a=[0],m=0;for(let u=0;u<n;u++)m+=i[u]/o,a.push(m);return u=>{if(u<=0)return 0;if(u>=1)return 1;for(let l=0;l<n;l++)if(u<=a[l+1]){let b=(u-a[l])/(a[l+1]-a[l]);if(l===0)return b*(2-b);let w=1-Math.pow(t,l);return w+(1-w)*(2*b-1)*(2*b-1)}return 1}}function Y({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),t=Math.max(.1,r),c=n<=1?t/4:t/(2*Math.PI)*Math.asin(1/n);return o=>o<=0?0:o>=1?1:n*Math.pow(2,-10*o)*Math.sin((o-c)*(2*Math.PI)/t)+1}var P={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Q(),elastic:Y()};function $(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",t="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:t}}function N(e,r,n,t){switch(t){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function O(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Z(e,r,n){return Math.min(n,Math.max(r,e))}function _(e,r,n,t){return n===r?0:Z((e-r)/(n-r)*t,0,1)}function q(e,r,n,t,c){let o=N(e.top,e.height,r,t.element)-O(t.viewport,n),i=N(e.top,e.height,r,c.element)-O(c.viewport,n);return {tStart:o,tEnd:i}}var z=new Map;function D(e,r){z.set(e,r);}function G(e){z.delete(e);}function V(e){let r=e.textContent??"";return e.textContent="",r.split(/(\s+)/).filter(Boolean).map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(t.textContent=n,t.style.whiteSpace="pre"):(t.textContent=n,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(n)?null:t}).filter(n=>n!==null)}function ee(e){let r=e.textContent??"";return e.textContent="",r.split("").map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=n,n===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),n===" "?null:t}).filter(n=>n!==null)}function k(e){let r=V(e),n=new Map;for(let o of r){let i=o.offsetTop;n.has(i)||n.set(i,[]),n.get(i).push(o);}let t=[],c=Array.from(n.keys()).sort((o,i)=>o-i);for(let o of c){let i=n.get(o),a=document.createElement("span");a.setAttribute("aria-hidden","true"),a.style.display="inline-block";for(let m of i)a.appendChild(m);t.push(a);}e.textContent="";for(let o of t)e.appendChild(o),e.appendChild(document.createTextNode(" "));return t}function te(e,r,n,t){if(n<=1||t===0)return e;let c=(n-1)*t,o=r*t,i=o+(1-c);return i<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(i-o)))}function ne(e,r){let n=[];if(r?.y!==void 0&&n.push(`translateY(${r.y*(1-e)}px)`),r?.x!==void 0&&n.push(`translateX(${r.x*(1-e)}px)`),r?.rotate!==void 0&&n.push(`rotate(${r.rotate*(1-e)}deg)`),r?.scale!==void 0){let t=r.scale+(1-r.scale)*e;n.push(`scale(${t})`);}return n.join(" ")||""}var B={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function ae(e,r={}){if(typeof window>"u")return B;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollText: element not found:",e),B;let t=n,{split:c="words",stagger:o=.04,easing:i="ease-out",from:a={opacity:0,y:24},trigger:m={},once:u=true,onComplete:l}=r,b=window.matchMedia("(prefers-reduced-motion: reduce)").matches,w=typeof i=="function"?i:P[i]??P["ease-out"],W=$(m.start??"top 85%"),j=$(m.end??"top 40%"),v=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let g;c==="chars"?g=ee(t):c==="lines"?g=k(t):g=V(t);let U=g.length;function X(s,p){a?.opacity!==void 0&&(s.style.opacity=String(a.opacity+(1-a.opacity)*p));let S=ne(p,a);S&&(s.style.transform=S);}function h(s){t.style.setProperty("--scroll-draw-progress",String(s)),g.forEach((p,S)=>{let K=w(te(s,S,U,o));X(p,K);});}if(b)return h(1),l?.(),{destroy(){t.innerHTML=v,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};h(0);let I=0,A=0,d=0,M=false,f=false,x=-1,y=0,E=false,F=()=>window.scrollY,J=()=>window.innerHeight;function H(){let s=t.getBoundingClientRect(),p=q({top:s.top,height:s.height},F(),J(),W,j);I=p.tStart,A=p.tEnd;}function C(){if(!M||f)return;let s=_(F(),I,A,1);u&&(x=Math.max(x,s),s=x),y=s,h(s),s>=1&&!E?(E=true,l?.()):s<1&&!u&&(E=false),d=requestAnimationFrame(C);}H();let R=new IntersectionObserver(s=>{s.forEach(p=>{M=p.isIntersecting,M&&!f?d=requestAnimationFrame(C):cancelAnimationFrame(d);});}),L;function T(){clearTimeout(L),L=setTimeout(()=>{if(c==="lines"){let s=y;t.innerHTML=v,t.setAttribute("aria-label",t.textContent??""),g=k(t),h(s);}H();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),R.observe(t),D(t,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:I,tEnd:A})}),{destroy(){cancelAnimationFrame(d),R.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(L),t.innerHTML=v,t.removeAttribute("aria-label"),G(t);},replay(){x=-1,E=false,y=0,f=false,h(0);},pause(){f=true,cancelAnimationFrame(d);},resume(){f&&(f=false,M&&(d=requestAnimationFrame(C)));},seek(s){let p=Math.min(1,Math.max(0,s));y=p,x=p,f=true,cancelAnimationFrame(d),h(p);},getProgress(){return y}}}exports.scrollText=ae;
1
+ 'use strict';function Z({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,r)),l=Math.sqrt(t),o=0,s=[];for(let u=0;u<n;u++){let a=Math.pow(l,u);s.push(a),o+=a;}let c=[0],m=0;for(let u=0;u<n;u++)m+=s[u]/o,c.push(m);return u=>{if(u<=0)return 0;if(u>=1)return 1;for(let a=0;a<n;a++)if(u<=c[a+1]){let g=(u-c[a])/(c[a+1]-c[a]);if(a===0)return g*(2-g);let x=1-Math.pow(t,a);return x+(1-x)*(2*g-1)*(2*g-1)}return 1}}function ee({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),t=Math.max(.1,r),l=n<=1?t/4:t/(2*Math.PI)*Math.asin(1/n);return o=>o<=0?0:o>=1?1:n*Math.pow(2,-10*o)*Math.sin((o-l)*(2*Math.PI)/t)+1}var _={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Z(),elastic:ee()};function R(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",t="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:t}}function F(e,r,n,t){switch(t){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function H(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function te(e,r,n){return Math.min(n,Math.max(r,e))}function V(e,r,n,t){return n===r?0:te((e-r)/(n-r)*t,0,1)}function O(e,r,n,t,l){let o=F(e.top,e.height,r,t.element)-H(t.viewport,n),s=F(e.top,e.height,r,l.element)-H(l.viewport,n);return {tStart:o,tEnd:s}}var N=Symbol.for("svg-scroll-draw.registry");function G(){let e=globalThis;return e[N]||(e[N]=new Map)}function z(e,r){G().set(e,r);}function B(e){G().delete(e);}var ne=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function k(e,...r){ne&&console.warn(`[svg-scroll-draw] ${e}`,...r);}function X(e){let r=e.textContent??"";return e.textContent="",r.split(/(\s+)/).filter(Boolean).map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(t.textContent=n,t.style.whiteSpace="pre"):(t.textContent=n,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(n)?null:t}).filter(n=>n!==null)}function re(e){let r=e.textContent??"";return e.textContent="",r.split("").map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=n,n===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),n===" "?null:t}).filter(n=>n!==null)}function q(e){let r=X(e),n=new Map;for(let o of r){let s=o.offsetTop;n.has(s)||n.set(s,[]),n.get(s).push(o);}let t=[],l=Array.from(n.keys()).sort((o,s)=>o-s);for(let o of l){let s=n.get(o),c=document.createElement("span");c.setAttribute("aria-hidden","true"),c.style.display="inline-block",s.forEach((m,u)=>{let a=m.nextElementSibling;c.appendChild(m),u<s.length-1&&a&&a.style.whiteSpace==="pre"&&c.appendChild(a);}),t.push(c);}return e.textContent="",t.forEach((o,s)=>{e.appendChild(o),s<t.length-1&&e.appendChild(document.createTextNode(" "));}),t}function oe(e,r,n,t){if(n<=1||t===0)return e;let l=(n-1)*t,o=r*t,s=o+(1-l);return s<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(s-o)))}function se(e,r){let n=[];if(r?.y!==void 0&&n.push(`translateY(${r.y*(1-e)}px)`),r?.x!==void 0&&n.push(`translateX(${r.x*(1-e)}px)`),r?.rotate!==void 0&&n.push(`rotate(${r.rotate*(1-e)}deg)`),r?.scale!==void 0){let t=r.scale+(1-r.scale)*e;n.push(`scale(${t})`);}return n.join(" ")||""}var W={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function me(e,r={}){if(typeof window>"u")return W;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return k("scrollText: element not found:",e),W;let t=n,{split:l="words",stagger:o=.04,easing:s="ease-out",from:c={opacity:0,y:24},trigger:m={},once:u=true,onComplete:a}=r,g=window.matchMedia("(prefers-reduced-motion: reduce)").matches,x=typeof s=="function"?s:_[s]??_["ease-out"],Y=R(m.start??"top 85%"),j=R(m.end??"top 40%"),v=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let b;l==="chars"?b=re(t):l==="lines"?b=q(t):b=X(t);let K=b.length;function U(i,p){c?.opacity!==void 0&&(i.style.opacity=String(c.opacity+(1-c.opacity)*p));let S=se(p,c);S&&(i.style.transform=S);}function h(i){t.style.setProperty("--scroll-draw-progress",String(i)),b.forEach((p,S)=>{let Q=x(oe(i,S,K,o));U(p,Q);});}if(g)return h(1),a?.(),{destroy(){t.innerHTML=v,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};h(0);let C=0,L=0,d=0,E=false,f=false,w=-1,y=0,M=false,P=()=>window.scrollY,J=()=>window.innerHeight;function $(){let i=t.getBoundingClientRect(),p=O({top:i.top,height:i.height},P(),J(),Y,j);C=p.tStart,L=p.tEnd;}function A(){if(!E||f)return;let i=V(P(),C,L,1);u&&(w=Math.max(w,i),i=w),y=i,h(i),i>=1&&!M?(M=true,a?.()):i<1&&!u&&(M=false),d=requestAnimationFrame(A);}$();let D=new IntersectionObserver(i=>{i.forEach(p=>{E=p.isIntersecting,E&&!f?d=requestAnimationFrame(A):cancelAnimationFrame(d);});}),I;function T(){clearTimeout(I),I=setTimeout(()=>{if(l==="lines"){let i=y;t.innerHTML=v,t.setAttribute("aria-label",t.textContent??""),b=q(t),h(i);}$();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),D.observe(t),z(t,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:C,tEnd:L})}),{destroy(){cancelAnimationFrame(d),D.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(I),t.innerHTML=v,t.removeAttribute("aria-label"),B(t);},replay(){w=-1,M=false,y=0,f=false,h(0);},pause(){f=true,cancelAnimationFrame(d);},resume(){f&&(f=false,E&&(d=requestAnimationFrame(A)));},seek(i){let p=Math.min(1,Math.max(0,i));y=p,w=p,f=true,cancelAnimationFrame(d),h(p);},getProgress(){return y}}}exports.scrollText=me;
@@ -15,6 +15,21 @@ interface ScrollDrawInstance {
15
15
  seek: (progress: number) => void;
16
16
  /** Returns current draw progress (0–1). */
17
17
  getProgress: () => number;
18
+ /**
19
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
20
+ *
21
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
22
+ * `ResizeObserver` on the document element — but none of those fire for a layout
23
+ * change that leaves the document height alone, such as a tab switching, a
24
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
25
+ * after one of those.
26
+ *
27
+ * Optional on this shared type because several instances here are fan-outs over
28
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
29
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
30
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
31
+ */
32
+ refresh?: () => void;
18
33
  }
19
34
 
20
35
  interface ScrollTextOptions {
@@ -15,6 +15,21 @@ interface ScrollDrawInstance {
15
15
  seek: (progress: number) => void;
16
16
  /** Returns current draw progress (0–1). */
17
17
  getProgress: () => number;
18
+ /**
19
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
20
+ *
21
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
22
+ * `ResizeObserver` on the document element — but none of those fire for a layout
23
+ * change that leaves the document height alone, such as a tab switching, a
24
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
25
+ * after one of those.
26
+ *
27
+ * Optional on this shared type because several instances here are fan-outs over
28
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
29
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
30
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
31
+ */
32
+ refresh?: () => void;
18
33
  }
19
34
 
20
35
  interface ScrollTextOptions {
@@ -1 +1 @@
1
- function Q({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(t),o=0,i=[];for(let u=0;u<n;u++){let l=Math.pow(c,u);i.push(l),o+=l;}let a=[0],m=0;for(let u=0;u<n;u++)m+=i[u]/o,a.push(m);return u=>{if(u<=0)return 0;if(u>=1)return 1;for(let l=0;l<n;l++)if(u<=a[l+1]){let b=(u-a[l])/(a[l+1]-a[l]);if(l===0)return b*(2-b);let w=1-Math.pow(t,l);return w+(1-w)*(2*b-1)*(2*b-1)}return 1}}function Y({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),t=Math.max(.1,r),c=n<=1?t/4:t/(2*Math.PI)*Math.asin(1/n);return o=>o<=0?0:o>=1?1:n*Math.pow(2,-10*o)*Math.sin((o-c)*(2*Math.PI)/t)+1}var P={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Q(),elastic:Y()};function $(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",t="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:t}}function N(e,r,n,t){switch(t){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function O(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Z(e,r,n){return Math.min(n,Math.max(r,e))}function _(e,r,n,t){return n===r?0:Z((e-r)/(n-r)*t,0,1)}function q(e,r,n,t,c){let o=N(e.top,e.height,r,t.element)-O(t.viewport,n),i=N(e.top,e.height,r,c.element)-O(c.viewport,n);return {tStart:o,tEnd:i}}var z=new Map;function D(e,r){z.set(e,r);}function G(e){z.delete(e);}function V(e){let r=e.textContent??"";return e.textContent="",r.split(/(\s+)/).filter(Boolean).map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(t.textContent=n,t.style.whiteSpace="pre"):(t.textContent=n,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(n)?null:t}).filter(n=>n!==null)}function ee(e){let r=e.textContent??"";return e.textContent="",r.split("").map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=n,n===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),n===" "?null:t}).filter(n=>n!==null)}function k(e){let r=V(e),n=new Map;for(let o of r){let i=o.offsetTop;n.has(i)||n.set(i,[]),n.get(i).push(o);}let t=[],c=Array.from(n.keys()).sort((o,i)=>o-i);for(let o of c){let i=n.get(o),a=document.createElement("span");a.setAttribute("aria-hidden","true"),a.style.display="inline-block";for(let m of i)a.appendChild(m);t.push(a);}e.textContent="";for(let o of t)e.appendChild(o),e.appendChild(document.createTextNode(" "));return t}function te(e,r,n,t){if(n<=1||t===0)return e;let c=(n-1)*t,o=r*t,i=o+(1-c);return i<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(i-o)))}function ne(e,r){let n=[];if(r?.y!==void 0&&n.push(`translateY(${r.y*(1-e)}px)`),r?.x!==void 0&&n.push(`translateX(${r.x*(1-e)}px)`),r?.rotate!==void 0&&n.push(`rotate(${r.rotate*(1-e)}deg)`),r?.scale!==void 0){let t=r.scale+(1-r.scale)*e;n.push(`scale(${t})`);}return n.join(" ")||""}var B={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function ae(e,r={}){if(typeof window>"u")return B;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollText: element not found:",e),B;let t=n,{split:c="words",stagger:o=.04,easing:i="ease-out",from:a={opacity:0,y:24},trigger:m={},once:u=true,onComplete:l}=r,b=window.matchMedia("(prefers-reduced-motion: reduce)").matches,w=typeof i=="function"?i:P[i]??P["ease-out"],W=$(m.start??"top 85%"),j=$(m.end??"top 40%"),v=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let g;c==="chars"?g=ee(t):c==="lines"?g=k(t):g=V(t);let U=g.length;function X(s,p){a?.opacity!==void 0&&(s.style.opacity=String(a.opacity+(1-a.opacity)*p));let S=ne(p,a);S&&(s.style.transform=S);}function h(s){t.style.setProperty("--scroll-draw-progress",String(s)),g.forEach((p,S)=>{let K=w(te(s,S,U,o));X(p,K);});}if(b)return h(1),l?.(),{destroy(){t.innerHTML=v,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};h(0);let I=0,A=0,d=0,M=false,f=false,x=-1,y=0,E=false,F=()=>window.scrollY,J=()=>window.innerHeight;function H(){let s=t.getBoundingClientRect(),p=q({top:s.top,height:s.height},F(),J(),W,j);I=p.tStart,A=p.tEnd;}function C(){if(!M||f)return;let s=_(F(),I,A,1);u&&(x=Math.max(x,s),s=x),y=s,h(s),s>=1&&!E?(E=true,l?.()):s<1&&!u&&(E=false),d=requestAnimationFrame(C);}H();let R=new IntersectionObserver(s=>{s.forEach(p=>{M=p.isIntersecting,M&&!f?d=requestAnimationFrame(C):cancelAnimationFrame(d);});}),L;function T(){clearTimeout(L),L=setTimeout(()=>{if(c==="lines"){let s=y;t.innerHTML=v,t.setAttribute("aria-label",t.textContent??""),g=k(t),h(s);}H();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),R.observe(t),D(t,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:I,tEnd:A})}),{destroy(){cancelAnimationFrame(d),R.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(L),t.innerHTML=v,t.removeAttribute("aria-label"),G(t);},replay(){x=-1,E=false,y=0,f=false,h(0);},pause(){f=true,cancelAnimationFrame(d);},resume(){f&&(f=false,M&&(d=requestAnimationFrame(C)));},seek(s){let p=Math.min(1,Math.max(0,s));y=p,x=p,f=true,cancelAnimationFrame(d),h(p);},getProgress(){return y}}}export{ae as scrollText};
1
+ function Z({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,r)),l=Math.sqrt(t),o=0,s=[];for(let u=0;u<n;u++){let a=Math.pow(l,u);s.push(a),o+=a;}let c=[0],m=0;for(let u=0;u<n;u++)m+=s[u]/o,c.push(m);return u=>{if(u<=0)return 0;if(u>=1)return 1;for(let a=0;a<n;a++)if(u<=c[a+1]){let g=(u-c[a])/(c[a+1]-c[a]);if(a===0)return g*(2-g);let x=1-Math.pow(t,a);return x+(1-x)*(2*g-1)*(2*g-1)}return 1}}function ee({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),t=Math.max(.1,r),l=n<=1?t/4:t/(2*Math.PI)*Math.asin(1/n);return o=>o<=0?0:o>=1?1:n*Math.pow(2,-10*o)*Math.sin((o-l)*(2*Math.PI)/t)+1}var _={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Z(),elastic:ee()};function R(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",t="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:t}}function F(e,r,n,t){switch(t){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function H(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function te(e,r,n){return Math.min(n,Math.max(r,e))}function V(e,r,n,t){return n===r?0:te((e-r)/(n-r)*t,0,1)}function O(e,r,n,t,l){let o=F(e.top,e.height,r,t.element)-H(t.viewport,n),s=F(e.top,e.height,r,l.element)-H(l.viewport,n);return {tStart:o,tEnd:s}}var N=Symbol.for("svg-scroll-draw.registry");function G(){let e=globalThis;return e[N]||(e[N]=new Map)}function z(e,r){G().set(e,r);}function B(e){G().delete(e);}var ne=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function k(e,...r){ne&&console.warn(`[svg-scroll-draw] ${e}`,...r);}function X(e){let r=e.textContent??"";return e.textContent="",r.split(/(\s+)/).filter(Boolean).map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(t.textContent=n,t.style.whiteSpace="pre"):(t.textContent=n,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(n)?null:t}).filter(n=>n!==null)}function re(e){let r=e.textContent??"";return e.textContent="",r.split("").map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=n,n===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),n===" "?null:t}).filter(n=>n!==null)}function q(e){let r=X(e),n=new Map;for(let o of r){let s=o.offsetTop;n.has(s)||n.set(s,[]),n.get(s).push(o);}let t=[],l=Array.from(n.keys()).sort((o,s)=>o-s);for(let o of l){let s=n.get(o),c=document.createElement("span");c.setAttribute("aria-hidden","true"),c.style.display="inline-block",s.forEach((m,u)=>{let a=m.nextElementSibling;c.appendChild(m),u<s.length-1&&a&&a.style.whiteSpace==="pre"&&c.appendChild(a);}),t.push(c);}return e.textContent="",t.forEach((o,s)=>{e.appendChild(o),s<t.length-1&&e.appendChild(document.createTextNode(" "));}),t}function oe(e,r,n,t){if(n<=1||t===0)return e;let l=(n-1)*t,o=r*t,s=o+(1-l);return s<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(s-o)))}function se(e,r){let n=[];if(r?.y!==void 0&&n.push(`translateY(${r.y*(1-e)}px)`),r?.x!==void 0&&n.push(`translateX(${r.x*(1-e)}px)`),r?.rotate!==void 0&&n.push(`rotate(${r.rotate*(1-e)}deg)`),r?.scale!==void 0){let t=r.scale+(1-r.scale)*e;n.push(`scale(${t})`);}return n.join(" ")||""}var W={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function me(e,r={}){if(typeof window>"u")return W;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return k("scrollText: element not found:",e),W;let t=n,{split:l="words",stagger:o=.04,easing:s="ease-out",from:c={opacity:0,y:24},trigger:m={},once:u=true,onComplete:a}=r,g=window.matchMedia("(prefers-reduced-motion: reduce)").matches,x=typeof s=="function"?s:_[s]??_["ease-out"],Y=R(m.start??"top 85%"),j=R(m.end??"top 40%"),v=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let b;l==="chars"?b=re(t):l==="lines"?b=q(t):b=X(t);let K=b.length;function U(i,p){c?.opacity!==void 0&&(i.style.opacity=String(c.opacity+(1-c.opacity)*p));let S=se(p,c);S&&(i.style.transform=S);}function h(i){t.style.setProperty("--scroll-draw-progress",String(i)),b.forEach((p,S)=>{let Q=x(oe(i,S,K,o));U(p,Q);});}if(g)return h(1),a?.(),{destroy(){t.innerHTML=v,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};h(0);let C=0,L=0,d=0,E=false,f=false,w=-1,y=0,M=false,P=()=>window.scrollY,J=()=>window.innerHeight;function $(){let i=t.getBoundingClientRect(),p=O({top:i.top,height:i.height},P(),J(),Y,j);C=p.tStart,L=p.tEnd;}function A(){if(!E||f)return;let i=V(P(),C,L,1);u&&(w=Math.max(w,i),i=w),y=i,h(i),i>=1&&!M?(M=true,a?.()):i<1&&!u&&(M=false),d=requestAnimationFrame(A);}$();let D=new IntersectionObserver(i=>{i.forEach(p=>{E=p.isIntersecting,E&&!f?d=requestAnimationFrame(A):cancelAnimationFrame(d);});}),I;function T(){clearTimeout(I),I=setTimeout(()=>{if(l==="lines"){let i=y;t.innerHTML=v,t.setAttribute("aria-label",t.textContent??""),b=q(t),h(i);}$();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),D.observe(t),z(t,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:C,tEnd:L})}),{destroy(){cancelAnimationFrame(d),D.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(I),t.innerHTML=v,t.removeAttribute("aria-label"),B(t);},replay(){w=-1,M=false,y=0,f=false,h(0);},pause(){f=true,cancelAnimationFrame(d);},resume(){f&&(f=false,E&&(d=requestAnimationFrame(A)));},seek(i){let p=Math.min(1,Math.max(0,i));y=p,w=p,f=true,cancelAnimationFrame(d),h(p);},getProgress(){return y}}}export{me as scrollText};
@@ -1,17 +1,17 @@
1
- 'use strict';function pe({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,n)),p=Math.sqrt(o),m=0,M=[];for(let a=0;a<r;a++){let c=Math.pow(p,a);M.push(c),m+=c;}let d=[0],x=0;for(let a=0;a<r;a++)x+=M[a]/m,d.push(x);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let c=0;c<r;c++)if(a<=d[c+1]){let b=(a-d[c])/(d[c+1]-d[c]);if(c===0)return b*(2-b);let E=1-Math.pow(o,c);return E+(1-E)*(2*b-1)*(2*b-1)}return 1}}function me({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),o=Math.max(.1,n),p=r<=1?o/4:o/(2*Math.PI)*Math.asin(1/r);return m=>m<=0?0:m>=1?1:r*Math.pow(2,-10*m)*Math.sin((m-p)*(2*Math.PI)/o)+1}var B={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:pe(),elastic:me()};function V(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",o="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function Z(e,n,r,o){switch(o){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function Y(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function W(e){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 fe(e,n,r){return Math.min(r,Math.max(n,e))}function ee(e,n,r,o){return r===n?0:fe((e-n)/(r-n)*o,0,1)}function te(e,n,r,o,p){let m=Z(e.top,e.height,n,o.element)-Y(o.viewport,r),M=Z(e.top,e.height,n,p.element)-Y(p.viewport,r);return {tStart:m,tEnd:M}}var ne=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function ge(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let o=typeof e=="string"?document.querySelector(e):e;if(!o)return console.warn("[svg-scroll-draw/timeline] Container not found:",e),r;let p=o,{trigger:m={},speed:M=1,once:d=false,axis:x="y",tracks:a,onComplete:c,repeat:b,repeatDelay:E=0,loop:R=false,loopDuration:re=1500,debug:oe=false,label:ie}=n,se=V(m.start??"top bottom"),ae=V(m.end??"bottom top"),A=b==="infinite"?1/0:b??0,f,L=R===true?1/0:typeof R=="number"?R:0,h=false,G=0,T=L,q=a.map(t=>{let u=typeof t.easing=="function"?t.easing:B[t.easing??"linear"]??B.linear,l=Array.from(p.querySelectorAll(t.selector)),s=l.map(i=>W(i));return l.forEach((i,g)=>{i.style.strokeDasharray=`${s[g]}`,i.style.strokeDashoffset=`${s[g]}`,t.fade&&(i.style.opacity="0");}),{...t,elements:l,lengths:s,easeFn:u}}),H=0,U=0,F=false,y=false,v=0,S=false,D=-1,I=0,w=null;oe&&(w=document.createElement("div"),Object.assign(w.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(w));function ue(t){if(!w)return;let u=ie??(typeof e=="string"?e:"timeline"),l=a.map(({selector:s,from:i,to:g},j)=>{let $=ne[j%ne.length],z=g>i?Math.min(1,Math.max(0,(t-i)/(g-i))):0,C=Math.round(z*100);return `<div style="margin:4px 0">
1
+ 'use strict';function Le({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,n)),s=Math.sqrt(o),m=0,E=[];for(let c=0;c<r;c++){let p=Math.pow(s,c);E.push(p),m+=p;}let f=[0],w=0;for(let c=0;c<r;c++)w+=E[c]/m,f.push(w);return c=>{if(c<=0)return 0;if(c>=1)return 1;for(let p=0;p<r;p++)if(c<=f[p+1]){let g=(c-f[p])/(f[p+1]-f[p]);if(p===0)return g*(2-g);let T=1-Math.pow(o,p);return T+(1-T)*(2*g-1)*(2*g-1)}return 1}}function Ie({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),o=Math.max(.1,n),s=r<=1?o/4:o/(2*Math.PI)*Math.asin(1/r);return m=>m<=0?0:m>=1?1:r*Math.pow(2,-10*m)*Math.sin((m-s)*(2*Math.PI)/o)+1}var H={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Le(),elastic:Ie()};function X(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",o="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function re(e,n,r,o){switch(o){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function oe(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function K(e){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 Re(e,n,r){return Math.min(r,Math.max(n,e))}function ie(e,n,r,o){return r===n?0:Re((e-n)/(r-n)*o,0,1)}function se(e,n,r,o,s){let m=re(e.top,e.height,n,o.element)-oe(o.viewport,r),E=re(e.top,e.height,n,s.element)-oe(s.viewport,r);return {tStart:m,tEnd:E}}function ae(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ue(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=s=>e(!!s.matches);if(typeof n.addEventListener=="function")return n.addEventListener("change",r),()=>n.removeEventListener("change",r);let o=n;return o.addListener?.(r),()=>o.removeListener?.(r)}var Se=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function ce(e,...n){Se&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var le=Symbol.for("svg-scroll-draw.registry");function de(){let e=globalThis;return e[le]||(e[le]=new Map)}function pe(e,n){de().set(e,n);}function me(e){de().delete(e);}var fe=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function Ve(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let o=typeof e=="string"?document.querySelector(e):e;if(!o)return ce("timeline: Container not found:",e),r;let s=o,{trigger:m={},speed:E=1,once:f=false,axis:w="y",tracks:c,onComplete:p,repeat:g,repeatDelay:T=0,loop:P=false,loopDuration:ge=1500,debug:be=false,label:he,respectReducedMotion:U=true}=n,ye=X(m.start??"top bottom"),we=X(m.end??"bottom top"),D=g==="infinite"?1/0:g??0,l,V=P===true?1/0:typeof P=="number"?P:0,b=false,G=0,L=V,z=U&&ae(),xe=ue(t=>{z=U&&t,z&&(b=false,clearTimeout(l),l=void 0);}),O=()=>V>0&&!z,Q=new Map,q=c.map(t=>{let a=typeof t.easing=="function"?t.easing:H[t.easing??"linear"]??H.linear,d=Array.from(s.querySelectorAll(t.selector)),u=d.map(i=>K(i));return d.forEach((i,h)=>{Q.has(i)||Q.set(i,i.getAttribute("style")??""),i.style.strokeDasharray=`${u[h]}`,i.style.strokeDashoffset=`${u[h]}`,t.fade&&(i.style.opacity="0");}),{...t,elements:d,lengths:u,easeFn:a}});function ve(){for(let[t,a]of Q)a?t.setAttribute("style",a):t.removeAttribute("style");}let N=0,W=0,_=false,x=false,v=0,R=false,S=-1,M=0,y=null;be&&(y=document.createElement("div"),Object.assign(y.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(y));function Me(t){if(!y)return;let a=he??(typeof e=="string"?e:"timeline"),d=c.map(({selector:u,from:i,to:h},j)=>{let I=fe[j%fe.length],C=h>i?Math.min(1,Math.max(0,(t-i)/(h-i))):0,F=Math.round(C*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:${$};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${s}</span>
4
- <span style="color:#666;margin-left:8px">${C}%</span>
3
+ <span style="color:${I};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${u}</span>
4
+ <span style="color:#666;margin-left:8px">${F}%</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:${i*100}%;width:${(g-i)*100}%;height:100%;background:${$}33;border-radius:2px"></div>
8
- <div style="position:absolute;left:${i*100}%;width:${(g-i)*z*100}%;height:100%;background:${$};border-radius:2px;transition:width 0.05s linear"></div>
7
+ <div style="position:absolute;left:${i*100}%;width:${(h-i)*100}%;height:100%;background:${I}33;border-radius:2px"></div>
8
+ <div style="position:absolute;left:${i*100}%;width:${(h-i)*C*100}%;height:100%;background:${I};border-radius:2px;transition:width 0.05s linear"></div>
9
9
  </div>
10
- </div>`}).join("");w.innerHTML=`
10
+ </div>`}).join("");y.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 ${u}
12
+ scrollDrawTimeline \xB7 ${a}
13
13
  </div>
14
- ${l}
14
+ ${d}
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:${t*100}%;transition:width 0.05s linear"></div>
22
22
  </div>
23
- </div>`;}function X(){return x==="x"?window.scrollX:window.scrollY}function le(){return x==="x"?window.innerWidth:window.innerHeight}function _(){let t=p.getBoundingClientRect(),u=X(),l=x==="x"?t.left:t.top,s=x==="x"?t.width:t.height,i=te({top:l,height:s},u,le(),se,ae);H=i.tStart,U=i.tEnd;}function J(t){p.style.setProperty("--scroll-draw-progress",String(t)),q.forEach(({elements:u,lengths:l,from:s,to:i,easeFn:g,fade:j})=>{let $=i-s,z=$>0?Math.min(1,Math.max(0,(t-s)/$)):0,C=g(z);u.forEach((Q,ce)=>{Q.style.strokeDashoffset=`${l[ce]*(1-C)}`,j&&(Q.style.opacity=String(C));});}),ue(t);}function k(){D=-1,I=0,S=false,q.forEach(({elements:t,lengths:u,fade:l})=>{t.forEach((s,i)=>{s.style.strokeDashoffset=`${u[i]}`,l&&(s.style.opacity="0");});}),p.style.setProperty("--scroll-draw-progress","0");}function O(){if(!F||y)return;let t;h?t=Math.min(1,(performance.now()-G)/re):(t=ee(X(),H,U,M),(d||L>0)&&(D=Math.max(D,t),t=D)),I=t,J(t),t>=1&&!S?(S=true,c?.(),L>0&&!h&&!f?f=setTimeout(()=>{f=void 0,T!==1/0&&T--,k(),h=true,G=performance.now();},E):A>0&&d&&!h&&!f&&(f=setTimeout(()=>{f=void 0,A!==1/0&&A--,k();},E))):!h&&t<1&&!d&&(S=false),h&&t>=1&&!f&&(S=false,T>0?f=setTimeout(()=>{f=void 0,T!==1/0&&T--,k(),G=performance.now();},E):h=false),v=requestAnimationFrame(O);}_();let K=new IntersectionObserver(t=>{t.forEach(u=>{F=u.isIntersecting,F&&!y?v=requestAnimationFrame(O):cancelAnimationFrame(v);});},{threshold:0});K.observe(p);let N;function P(){clearTimeout(N),N=setTimeout(()=>{q.forEach(({elements:t,lengths:u})=>{t.forEach((l,s)=>{u[s]=W(l),l.style.strokeDasharray=`${u[s]}`;});}),_();},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),{destroy(){cancelAnimationFrame(v),clearTimeout(N),clearTimeout(f),K.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),w&&(w.remove(),w=null);},replay(){A=b==="infinite"?1/0:b??0,T=L,h=false,clearTimeout(f),f=void 0,k(),y=false;},pause(){y=true,cancelAnimationFrame(v);},resume(){y&&(y=false,F&&(v=requestAnimationFrame(O)));},seek(t){I=Math.min(1,Math.max(0,t)),D=I,y=true,cancelAnimationFrame(v),J(I);},getProgress(){return I}}}exports.scrollDrawTimeline=ge;
23
+ </div>`;}function Y(){return w==="x"?window.scrollX:window.scrollY}function Ee(){return w==="x"?window.innerWidth:window.innerHeight}function J(){let t=s.getBoundingClientRect(),a=Y(),d=w==="x"?t.left:t.top,u=w==="x"?t.width:t.height,i=se({top:d,height:u},a,Ee(),ye,we);N=i.tStart,W=i.tEnd;}function Z(t){s.style.setProperty("--scroll-draw-progress",String(t)),q.forEach(({elements:a,lengths:d,from:u,to:i,easeFn:h,fade:j})=>{let I=i-u,C=I>0?Math.min(1,Math.max(0,(t-u)/I)):0,F=h(C);a.forEach((ne,Te)=>{ne.style.strokeDashoffset=`${d[Te]*(1-F)}`,j&&(ne.style.opacity=String(F));});}),Me(t);}function $(){S=-1,M=0,R=false,q.forEach(({elements:t,lengths:a,fade:d})=>{t.forEach((u,i)=>{u.style.strokeDashoffset=`${a[i]}`,d&&(u.style.opacity="0");});}),s.style.setProperty("--scroll-draw-progress","0");}function B(){if(!_||x)return;let t;b?t=Math.min(1,(performance.now()-G)/ge):(t=ie(Y(),N,W,E),(f||O())&&(S=Math.max(S,t),t=S)),M=t,Z(t),t>=1&&!R?(R=true,p?.(),O()&&!b&&!l?l=setTimeout(()=>{l=void 0,L!==1/0&&L--,$(),b=true,G=performance.now();},T):D>0&&f&&!b&&!l&&(l=setTimeout(()=>{l=void 0,D!==1/0&&D--,$();},T))):!b&&t<1&&!f&&(R=false),b&&t>=1&&!l&&(R=false,L>0&&O()?l=setTimeout(()=>{l=void 0,L!==1/0&&L--,$(),G=performance.now();},T):b=false),v=requestAnimationFrame(B);}J();let ee=new IntersectionObserver(t=>{t.forEach(a=>{_=a.isIntersecting,_&&!x?v=requestAnimationFrame(B):cancelAnimationFrame(v);});},{threshold:0});ee.observe(s);function te(){q.forEach(({elements:t,lengths:a})=>{t.forEach((d,u)=>{a[u]=K(d),d.style.strokeDasharray=`${a[u]}`;});}),J();}let A;function k(){clearTimeout(A),A=setTimeout(te,150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),pe(s,{type:"draw",getProgress:()=>M,getTrigger:()=>({tStart:N,tEnd:W})}),{destroy(){cancelAnimationFrame(v),clearTimeout(A),clearTimeout(l),ee.disconnect(),me(s),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),xe(),y&&(y.remove(),y=null),ve(),s.style.removeProperty("--scroll-draw-progress");},refresh(){clearTimeout(A),te();},replay(){D=g==="infinite"?1/0:g??0,L=V,b=false,clearTimeout(l),l=void 0,$(),x=false;},pause(){x=true,cancelAnimationFrame(v);},resume(){x&&(x=false,_&&(v=requestAnimationFrame(B)));},seek(t){M=Math.min(1,Math.max(0,t)),S=M,x=true,cancelAnimationFrame(v),Z(M);},getProgress(){return M}}}exports.scrollDrawTimeline=Ve;
@@ -11,6 +11,21 @@ interface ScrollDrawInstance {
11
11
  seek: (progress: number) => void;
12
12
  /** Returns current draw progress (0–1). */
13
13
  getProgress: () => number;
14
+ /**
15
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
16
+ *
17
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
18
+ * `ResizeObserver` on the document element — but none of those fire for a layout
19
+ * change that leaves the document height alone, such as a tab switching, a
20
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
21
+ * after one of those.
22
+ *
23
+ * Optional on this shared type because several instances here are fan-outs over
24
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
25
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
26
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
27
+ */
28
+ refresh?: () => void;
14
29
  }
15
30
 
16
31
  interface TimelineTrack {
@@ -69,6 +84,22 @@ interface ScrollDrawTimelineOptions {
69
84
  debug?: boolean;
70
85
  /** Label shown in the debug panel header. Defaults to the target selector string. */
71
86
  label?: string;
87
+ /**
88
+ * Honour `prefers-reduced-motion: reduce` for the time-driven `loop` only.
89
+ * Default: `true`.
90
+ *
91
+ * The two halves of this API deserve different answers. Scroll scrubbing
92
+ * advances 1:1 with the user's own input — direct manipulation, not motion
93
+ * played at them — and suppressing it would freeze the drawing at whatever
94
+ * fraction the first paint happened to compute, so it keeps scrubbing. `loop`
95
+ * is the opposite: it replays the whole timeline off `performance.now()` with
96
+ * no scroll input at all, which is autonomous motion by any definition and had
97
+ * no check whatsoever. With reduced motion requested, the scroll pass runs
98
+ * normally and the loop simply does not start.
99
+ *
100
+ * Set to `false` to loop regardless of the preference.
101
+ */
102
+ respectReducedMotion?: boolean;
72
103
  }
73
104
  /**
74
105
  * Animate multiple path groups with independent start/end windows within a
@@ -11,6 +11,21 @@ interface ScrollDrawInstance {
11
11
  seek: (progress: number) => void;
12
12
  /** Returns current draw progress (0–1). */
13
13
  getProgress: () => number;
14
+ /**
15
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
16
+ *
17
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
18
+ * `ResizeObserver` on the document element — but none of those fire for a layout
19
+ * change that leaves the document height alone, such as a tab switching, a
20
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
21
+ * after one of those.
22
+ *
23
+ * Optional on this shared type because several instances here are fan-outs over
24
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
25
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
26
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
27
+ */
28
+ refresh?: () => void;
14
29
  }
15
30
 
16
31
  interface TimelineTrack {
@@ -69,6 +84,22 @@ interface ScrollDrawTimelineOptions {
69
84
  debug?: boolean;
70
85
  /** Label shown in the debug panel header. Defaults to the target selector string. */
71
86
  label?: string;
87
+ /**
88
+ * Honour `prefers-reduced-motion: reduce` for the time-driven `loop` only.
89
+ * Default: `true`.
90
+ *
91
+ * The two halves of this API deserve different answers. Scroll scrubbing
92
+ * advances 1:1 with the user's own input — direct manipulation, not motion
93
+ * played at them — and suppressing it would freeze the drawing at whatever
94
+ * fraction the first paint happened to compute, so it keeps scrubbing. `loop`
95
+ * is the opposite: it replays the whole timeline off `performance.now()` with
96
+ * no scroll input at all, which is autonomous motion by any definition and had
97
+ * no check whatsoever. With reduced motion requested, the scroll pass runs
98
+ * normally and the loop simply does not start.
99
+ *
100
+ * Set to `false` to loop regardless of the preference.
101
+ */
102
+ respectReducedMotion?: boolean;
72
103
  }
73
104
  /**
74
105
  * Animate multiple path groups with independent start/end windows within a
@@ -1,17 +1,17 @@
1
- function pe({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,n)),p=Math.sqrt(o),m=0,M=[];for(let a=0;a<r;a++){let c=Math.pow(p,a);M.push(c),m+=c;}let d=[0],x=0;for(let a=0;a<r;a++)x+=M[a]/m,d.push(x);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let c=0;c<r;c++)if(a<=d[c+1]){let b=(a-d[c])/(d[c+1]-d[c]);if(c===0)return b*(2-b);let E=1-Math.pow(o,c);return E+(1-E)*(2*b-1)*(2*b-1)}return 1}}function me({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),o=Math.max(.1,n),p=r<=1?o/4:o/(2*Math.PI)*Math.asin(1/r);return m=>m<=0?0:m>=1?1:r*Math.pow(2,-10*m)*Math.sin((m-p)*(2*Math.PI)/o)+1}var B={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:pe(),elastic:me()};function V(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",o="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function Z(e,n,r,o){switch(o){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function Y(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function W(e){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 fe(e,n,r){return Math.min(r,Math.max(n,e))}function ee(e,n,r,o){return r===n?0:fe((e-n)/(r-n)*o,0,1)}function te(e,n,r,o,p){let m=Z(e.top,e.height,n,o.element)-Y(o.viewport,r),M=Z(e.top,e.height,n,p.element)-Y(p.viewport,r);return {tStart:m,tEnd:M}}var ne=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function ge(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let o=typeof e=="string"?document.querySelector(e):e;if(!o)return console.warn("[svg-scroll-draw/timeline] Container not found:",e),r;let p=o,{trigger:m={},speed:M=1,once:d=false,axis:x="y",tracks:a,onComplete:c,repeat:b,repeatDelay:E=0,loop:R=false,loopDuration:re=1500,debug:oe=false,label:ie}=n,se=V(m.start??"top bottom"),ae=V(m.end??"bottom top"),A=b==="infinite"?1/0:b??0,f,L=R===true?1/0:typeof R=="number"?R:0,h=false,G=0,T=L,q=a.map(t=>{let u=typeof t.easing=="function"?t.easing:B[t.easing??"linear"]??B.linear,l=Array.from(p.querySelectorAll(t.selector)),s=l.map(i=>W(i));return l.forEach((i,g)=>{i.style.strokeDasharray=`${s[g]}`,i.style.strokeDashoffset=`${s[g]}`,t.fade&&(i.style.opacity="0");}),{...t,elements:l,lengths:s,easeFn:u}}),H=0,U=0,F=false,y=false,v=0,S=false,D=-1,I=0,w=null;oe&&(w=document.createElement("div"),Object.assign(w.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(w));function ue(t){if(!w)return;let u=ie??(typeof e=="string"?e:"timeline"),l=a.map(({selector:s,from:i,to:g},j)=>{let $=ne[j%ne.length],z=g>i?Math.min(1,Math.max(0,(t-i)/(g-i))):0,C=Math.round(z*100);return `<div style="margin:4px 0">
1
+ function Le({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,n)),s=Math.sqrt(o),m=0,E=[];for(let c=0;c<r;c++){let p=Math.pow(s,c);E.push(p),m+=p;}let f=[0],w=0;for(let c=0;c<r;c++)w+=E[c]/m,f.push(w);return c=>{if(c<=0)return 0;if(c>=1)return 1;for(let p=0;p<r;p++)if(c<=f[p+1]){let g=(c-f[p])/(f[p+1]-f[p]);if(p===0)return g*(2-g);let T=1-Math.pow(o,p);return T+(1-T)*(2*g-1)*(2*g-1)}return 1}}function Ie({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),o=Math.max(.1,n),s=r<=1?o/4:o/(2*Math.PI)*Math.asin(1/r);return m=>m<=0?0:m>=1?1:r*Math.pow(2,-10*m)*Math.sin((m-s)*(2*Math.PI)/o)+1}var H={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Le(),elastic:Ie()};function X(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",o="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function re(e,n,r,o){switch(o){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function oe(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function K(e){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 Re(e,n,r){return Math.min(r,Math.max(n,e))}function ie(e,n,r,o){return r===n?0:Re((e-n)/(r-n)*o,0,1)}function se(e,n,r,o,s){let m=re(e.top,e.height,n,o.element)-oe(o.viewport,r),E=re(e.top,e.height,n,s.element)-oe(s.viewport,r);return {tStart:m,tEnd:E}}function ae(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ue(e){if(typeof window>"u"||typeof window.matchMedia!="function")return ()=>{};let n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=s=>e(!!s.matches);if(typeof n.addEventListener=="function")return n.addEventListener("change",r),()=>n.removeEventListener("change",r);let o=n;return o.addListener?.(r),()=>o.removeListener?.(r)}var Se=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function ce(e,...n){Se&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var le=Symbol.for("svg-scroll-draw.registry");function de(){let e=globalThis;return e[le]||(e[le]=new Map)}function pe(e,n){de().set(e,n);}function me(e){de().delete(e);}var fe=["#ff90e8","#ffc900","#5865F2","#22c55e","#f59e0b","#ef4444","#aaa","#60a5fa"];function Ve(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let o=typeof e=="string"?document.querySelector(e):e;if(!o)return ce("timeline: Container not found:",e),r;let s=o,{trigger:m={},speed:E=1,once:f=false,axis:w="y",tracks:c,onComplete:p,repeat:g,repeatDelay:T=0,loop:P=false,loopDuration:ge=1500,debug:be=false,label:he,respectReducedMotion:U=true}=n,ye=X(m.start??"top bottom"),we=X(m.end??"bottom top"),D=g==="infinite"?1/0:g??0,l,V=P===true?1/0:typeof P=="number"?P:0,b=false,G=0,L=V,z=U&&ae(),xe=ue(t=>{z=U&&t,z&&(b=false,clearTimeout(l),l=void 0);}),O=()=>V>0&&!z,Q=new Map,q=c.map(t=>{let a=typeof t.easing=="function"?t.easing:H[t.easing??"linear"]??H.linear,d=Array.from(s.querySelectorAll(t.selector)),u=d.map(i=>K(i));return d.forEach((i,h)=>{Q.has(i)||Q.set(i,i.getAttribute("style")??""),i.style.strokeDasharray=`${u[h]}`,i.style.strokeDashoffset=`${u[h]}`,t.fade&&(i.style.opacity="0");}),{...t,elements:d,lengths:u,easeFn:a}});function ve(){for(let[t,a]of Q)a?t.setAttribute("style",a):t.removeAttribute("style");}let N=0,W=0,_=false,x=false,v=0,R=false,S=-1,M=0,y=null;be&&(y=document.createElement("div"),Object.assign(y.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(y));function Me(t){if(!y)return;let a=he??(typeof e=="string"?e:"timeline"),d=c.map(({selector:u,from:i,to:h},j)=>{let I=fe[j%fe.length],C=h>i?Math.min(1,Math.max(0,(t-i)/(h-i))):0,F=Math.round(C*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:${$};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${s}</span>
4
- <span style="color:#666;margin-left:8px">${C}%</span>
3
+ <span style="color:${I};max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${u}</span>
4
+ <span style="color:#666;margin-left:8px">${F}%</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:${i*100}%;width:${(g-i)*100}%;height:100%;background:${$}33;border-radius:2px"></div>
8
- <div style="position:absolute;left:${i*100}%;width:${(g-i)*z*100}%;height:100%;background:${$};border-radius:2px;transition:width 0.05s linear"></div>
7
+ <div style="position:absolute;left:${i*100}%;width:${(h-i)*100}%;height:100%;background:${I}33;border-radius:2px"></div>
8
+ <div style="position:absolute;left:${i*100}%;width:${(h-i)*C*100}%;height:100%;background:${I};border-radius:2px;transition:width 0.05s linear"></div>
9
9
  </div>
10
- </div>`}).join("");w.innerHTML=`
10
+ </div>`}).join("");y.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 ${u}
12
+ scrollDrawTimeline \xB7 ${a}
13
13
  </div>
14
- ${l}
14
+ ${d}
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 @@ function pe({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.
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:${t*100}%;transition:width 0.05s linear"></div>
22
22
  </div>
23
- </div>`;}function X(){return x==="x"?window.scrollX:window.scrollY}function le(){return x==="x"?window.innerWidth:window.innerHeight}function _(){let t=p.getBoundingClientRect(),u=X(),l=x==="x"?t.left:t.top,s=x==="x"?t.width:t.height,i=te({top:l,height:s},u,le(),se,ae);H=i.tStart,U=i.tEnd;}function J(t){p.style.setProperty("--scroll-draw-progress",String(t)),q.forEach(({elements:u,lengths:l,from:s,to:i,easeFn:g,fade:j})=>{let $=i-s,z=$>0?Math.min(1,Math.max(0,(t-s)/$)):0,C=g(z);u.forEach((Q,ce)=>{Q.style.strokeDashoffset=`${l[ce]*(1-C)}`,j&&(Q.style.opacity=String(C));});}),ue(t);}function k(){D=-1,I=0,S=false,q.forEach(({elements:t,lengths:u,fade:l})=>{t.forEach((s,i)=>{s.style.strokeDashoffset=`${u[i]}`,l&&(s.style.opacity="0");});}),p.style.setProperty("--scroll-draw-progress","0");}function O(){if(!F||y)return;let t;h?t=Math.min(1,(performance.now()-G)/re):(t=ee(X(),H,U,M),(d||L>0)&&(D=Math.max(D,t),t=D)),I=t,J(t),t>=1&&!S?(S=true,c?.(),L>0&&!h&&!f?f=setTimeout(()=>{f=void 0,T!==1/0&&T--,k(),h=true,G=performance.now();},E):A>0&&d&&!h&&!f&&(f=setTimeout(()=>{f=void 0,A!==1/0&&A--,k();},E))):!h&&t<1&&!d&&(S=false),h&&t>=1&&!f&&(S=false,T>0?f=setTimeout(()=>{f=void 0,T!==1/0&&T--,k(),G=performance.now();},E):h=false),v=requestAnimationFrame(O);}_();let K=new IntersectionObserver(t=>{t.forEach(u=>{F=u.isIntersecting,F&&!y?v=requestAnimationFrame(O):cancelAnimationFrame(v);});},{threshold:0});K.observe(p);let N;function P(){clearTimeout(N),N=setTimeout(()=>{q.forEach(({elements:t,lengths:u})=>{t.forEach((l,s)=>{u[s]=W(l),l.style.strokeDasharray=`${u[s]}`;});}),_();},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),{destroy(){cancelAnimationFrame(v),clearTimeout(N),clearTimeout(f),K.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),w&&(w.remove(),w=null);},replay(){A=b==="infinite"?1/0:b??0,T=L,h=false,clearTimeout(f),f=void 0,k(),y=false;},pause(){y=true,cancelAnimationFrame(v);},resume(){y&&(y=false,F&&(v=requestAnimationFrame(O)));},seek(t){I=Math.min(1,Math.max(0,t)),D=I,y=true,cancelAnimationFrame(v),J(I);},getProgress(){return I}}}export{ge as scrollDrawTimeline};
23
+ </div>`;}function Y(){return w==="x"?window.scrollX:window.scrollY}function Ee(){return w==="x"?window.innerWidth:window.innerHeight}function J(){let t=s.getBoundingClientRect(),a=Y(),d=w==="x"?t.left:t.top,u=w==="x"?t.width:t.height,i=se({top:d,height:u},a,Ee(),ye,we);N=i.tStart,W=i.tEnd;}function Z(t){s.style.setProperty("--scroll-draw-progress",String(t)),q.forEach(({elements:a,lengths:d,from:u,to:i,easeFn:h,fade:j})=>{let I=i-u,C=I>0?Math.min(1,Math.max(0,(t-u)/I)):0,F=h(C);a.forEach((ne,Te)=>{ne.style.strokeDashoffset=`${d[Te]*(1-F)}`,j&&(ne.style.opacity=String(F));});}),Me(t);}function $(){S=-1,M=0,R=false,q.forEach(({elements:t,lengths:a,fade:d})=>{t.forEach((u,i)=>{u.style.strokeDashoffset=`${a[i]}`,d&&(u.style.opacity="0");});}),s.style.setProperty("--scroll-draw-progress","0");}function B(){if(!_||x)return;let t;b?t=Math.min(1,(performance.now()-G)/ge):(t=ie(Y(),N,W,E),(f||O())&&(S=Math.max(S,t),t=S)),M=t,Z(t),t>=1&&!R?(R=true,p?.(),O()&&!b&&!l?l=setTimeout(()=>{l=void 0,L!==1/0&&L--,$(),b=true,G=performance.now();},T):D>0&&f&&!b&&!l&&(l=setTimeout(()=>{l=void 0,D!==1/0&&D--,$();},T))):!b&&t<1&&!f&&(R=false),b&&t>=1&&!l&&(R=false,L>0&&O()?l=setTimeout(()=>{l=void 0,L!==1/0&&L--,$(),G=performance.now();},T):b=false),v=requestAnimationFrame(B);}J();let ee=new IntersectionObserver(t=>{t.forEach(a=>{_=a.isIntersecting,_&&!x?v=requestAnimationFrame(B):cancelAnimationFrame(v);});},{threshold:0});ee.observe(s);function te(){q.forEach(({elements:t,lengths:a})=>{t.forEach((d,u)=>{a[u]=K(d),d.style.strokeDasharray=`${a[u]}`;});}),J();}let A;function k(){clearTimeout(A),A=setTimeout(te,150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),pe(s,{type:"draw",getProgress:()=>M,getTrigger:()=>({tStart:N,tEnd:W})}),{destroy(){cancelAnimationFrame(v),clearTimeout(A),clearTimeout(l),ee.disconnect(),me(s),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),xe(),y&&(y.remove(),y=null),ve(),s.style.removeProperty("--scroll-draw-progress");},refresh(){clearTimeout(A),te();},replay(){D=g==="infinite"?1/0:g??0,L=V,b=false,clearTimeout(l),l=void 0,$(),x=false;},pause(){x=true,cancelAnimationFrame(v);},resume(){x&&(x=false,_&&(v=requestAnimationFrame(B)));},seek(t){M=Math.min(1,Math.max(0,t)),S=M,x=true,cancelAnimationFrame(v),Z(M);},getProgress(){return M}}}export{Ve as scrollDrawTimeline};