svg-scroll-draw 0.6.0 → 0.6.2

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 (43) hide show
  1. package/README.md +5 -4
  2. package/dist/angular/index.cjs +3 -3
  3. package/dist/angular/index.d.mts +8 -0
  4. package/dist/angular/index.d.ts +8 -0
  5. package/dist/angular/index.mjs +3 -3
  6. package/dist/astro/index.cjs +3 -3
  7. package/dist/astro/index.d.mts +8 -0
  8. package/dist/astro/index.d.ts +8 -0
  9. package/dist/astro/index.mjs +3 -3
  10. package/dist/cdn/svg-scroll-draw.global.js +3 -3
  11. package/dist/group/index.cjs +3 -3
  12. package/dist/group/index.d.mts +8 -0
  13. package/dist/group/index.d.ts +8 -0
  14. package/dist/group/index.mjs +3 -3
  15. package/dist/index.cjs +3 -3
  16. package/dist/index.d.mts +8 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.mjs +3 -3
  19. package/dist/nuxt/index.cjs +3 -3
  20. package/dist/nuxt/index.d.mts +8 -0
  21. package/dist/nuxt/index.d.ts +8 -0
  22. package/dist/nuxt/index.mjs +3 -3
  23. package/dist/react/index.cjs +3 -3
  24. package/dist/react/index.d.mts +36 -2
  25. package/dist/react/index.d.ts +36 -2
  26. package/dist/react/index.mjs +3 -3
  27. package/dist/solid/index.cjs +3 -3
  28. package/dist/solid/index.d.mts +8 -0
  29. package/dist/solid/index.d.ts +8 -0
  30. package/dist/solid/index.mjs +3 -3
  31. package/dist/svelte/index.cjs +3 -3
  32. package/dist/svelte/index.d.mts +8 -0
  33. package/dist/svelte/index.d.ts +8 -0
  34. package/dist/svelte/index.mjs +3 -3
  35. package/dist/vue/index.cjs +3 -3
  36. package/dist/vue/index.d.mts +8 -0
  37. package/dist/vue/index.d.ts +8 -0
  38. package/dist/vue/index.mjs +3 -3
  39. package/dist/web-component/index.cjs +3 -0
  40. package/dist/web-component/index.d.mts +2 -0
  41. package/dist/web-component/index.d.ts +2 -0
  42. package/dist/web-component/index.mjs +3 -0
  43. package/package.json +8 -3
@@ -1,3 +1,3 @@
1
- import {defineComponent,ref,onMounted,onUnmounted,h}from'vue';var re={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)};function ne(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[o="top",n="bottom"]=r.split(/\s+/).filter(Boolean);return {element:o,viewport:n}}function be(e,r,o,n){switch(n){case "top":return e+o;case "center":return e+o+r/2;case "bottom":return e+o+r;default:return e+o}}function he(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 oe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let o=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(o+n)}if(r==="circle"){let o=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*o}return e.getTotalLength()}function Ne(e,r,o){return Math.min(o,Math.max(r,e))}function H(e,r,o,n){return o===r?0:Ne((e-r)/(o-r)*n,0,1)}function ve(e,r,o,n,i){let c=be(e.top,e.height,r,n.element)-he(n.viewport,o),u=be(e.top,e.height,r,i.element)-he(i.viewport,o);return {tStart:c,tEnd:u}}function we(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let o=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(o)return [parseInt(o[1],16),parseInt(o[2],16),parseInt(o[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function se(e,r,o){let n=we(e),i=we(r);return !n||!i?e:`rgb(${Math.round(n[0]+(i[0]-n[0])*o)},${Math.round(n[1]+(i[1]-n[1])*o)},${Math.round(n[2]+(i[2]-n[2])*o)})`}function xe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Re(e){let r=e.getAttribute("stroke"),o=e.getAttribute("fill");!r||r==="none"?xe("Element has no stroke \u2014 path will not be visible.",e):o&&o!=="none"&&o!=="transparent"&&xe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function We(e,r,o){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.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 i(){let c=o==="x"?window.scrollX:window.scrollY,u=e-c,S=r-c,N=o==="x";n.innerHTML=`
2
- <div style="position:absolute;${N?`left:${u}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${u}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;${N?`left:${S}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${S}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(n),window.addEventListener("scroll",i,{passive:true}),i(),n}function Se(e,r,o){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),S=n[i++]??u;return String(+(u+(S-u)*o).toFixed(4))})}function ie(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:n="path, polyline, line, polygon, rect, circle",speed:i=1,fade:c=false,easing:u="linear",trigger:S={},stagger:N=0,direction:E="forward",once:le=false,debug:ke=false,axis:h="y",scrollContainer:X,autoReverse:ce=false,delay:ue=0,strokeColor:T,strokeWidth:C,waypoints:_,velocityScale:j=false,threshold:$e=0,rootMargin:Te="0px",repeat:fe=0,repeatDelay:Ce=0,morphTo:A,onProgress:Me,onStart:Fe,onComplete:me}=r,de=typeof u=="function"?u:re[u]??re.linear,Le=ne(S.start??"top bottom"),Ie=ne(S.end??"bottom top"),m=typeof X=="string"?document.querySelector(X):X??null,v=Array.isArray(T)?T[0]:null,g=Array.isArray(T)?T[1]:typeof T=="string"?T:null,y=Array.isArray(C)?C[0]:null,b=Array.isArray(C)?C[1]:typeof C=="number"?C:null,O=Array.from(e.querySelectorAll(n)),w=[],x=[],M=0,F=0,P=false,R=false,D=0,W=false,L=-1,V=-1,k=false,U=0,J=0,K,Q=null,z=new Set,G=-1,pe=performance.now();function Y(){return m?h==="x"?m.scrollLeft:m.scrollTop:h==="x"?window.scrollX:window.scrollY}function Oe(){return m?h==="x"?m.clientWidth:m.clientHeight:h==="x"?window.innerWidth:window.innerHeight}function ge(){let t=e.getBoundingClientRect(),s,a,d;if(m){let I=m.getBoundingClientRect();s=h==="x"?t.left-I.left+m.scrollLeft:t.top-I.top+m.scrollTop,a=h==="x"?t.width:t.height,d=Y();}else s=h==="x"?t.left:t.top,a=h==="x"?t.width:t.height,d=Y();let q=ve({top:s,height:a},d,Oe(),Le,Ie);M=q.tStart,F=q.tEnd,ke&&process.env.NODE_ENV!=="production"&&(Q?.remove(),Q=We(M,F,h));}function Pe(t,s){O.forEach((a,d)=>{a.style.strokeDashoffset=s==="reverse"?`${w[d]*t}`:`${w[d]*(1-t)}`,c&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),v&&g?a.style.stroke=se(v,g,t):g&&(a.style.stroke=g),y!==null&&b!==null?a.style.strokeWidth=`${y+(b-y)*t}`:b!==null&&(a.style.strokeWidth=`${b}`),A&&a.tagName.toLowerCase()==="path"&&x[d]&&a.setAttribute("d",Se(x[d],A,t));});}function ye(){O.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=E==="reverse"?"0":`${w[s]}`,c?t.style.opacity=E==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`),A&&t.tagName.toLowerCase()==="path"&&x[s]&&t.setAttribute("d",x[s]);});}if(O.forEach(t=>{Re(t);let s=oe(t);w.push(s),t.tagName.toLowerCase()==="path"?x.push(t.getAttribute("d")??""):x.push(""),o?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=E==="reverse"?`${s}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),A&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",A)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=E==="reverse"?"0":`${s}`,c?t.style.opacity=E==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`));}),o)return me?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};ge();function Z(){if(!W||k)return;let t=performance.now(),s=Y(),a=i;if(j!==false){let l=t-pe,p=l>0?Math.abs(s-(G<0?s:G))/l:0;a=i*Math.max(.2,1+p*(typeof j=="number"?j:1)*.04);}G=s,pe=t;let d=ce?V===-1||s>=V?"forward":"reverse":E;V=s;let q=F-M,I=true;if(O.forEach((l,p)=>{let $=p*N*q,f=de(H(s,M+$,F+$,a));le&&!ce&&(L=Math.max(L,f),f=L),U=f,l.style.strokeDashoffset=d==="reverse"?`${w[p]*f}`:`${w[p]*(1-f)}`,c&&(l.style.opacity=d==="reverse"?`${1-f}`:`${f}`),v&&g?l.style.stroke=se(v,g,f):g&&(l.style.stroke=g),y!==null&&b!==null?l.style.strokeWidth=`${y+(b-y)*f}`:b!==null&&(l.style.strokeWidth=`${b}`),A&&l.tagName.toLowerCase()==="path"&&x[p]&&l.setAttribute("d",Se(x[p],A,f)),p===0&&Me?.(f),f<1&&(I=false);}),_){let l=de(H(s,M,F,a));for(let p in _){let $=parseFloat(p);l>=$&&!z.has($)&&(z.add($),_[p]?.());}}!R&&H(s,M,F,a)>0&&(R=true,Fe?.()),I&&!P?(P=true,me?.(),J<(fe==="infinite"?1/0:fe??0)&&(J++,K=setTimeout(()=>{L=-1,R=false,P=false,z.clear(),ye();},Ce))):!I&&!le&&(P=false),D=requestAnimationFrame(Z);}let ee=new IntersectionObserver(t=>{t.forEach(s=>{W=s.isIntersecting,W&&!k?D=requestAnimationFrame(Z):cancelAnimationFrame(D);});},{root:m??null,threshold:$e,rootMargin:Te}),te;function B(){clearTimeout(te),te=setTimeout(()=>{O.forEach((t,s)=>{w[s]=oe(t),t.style.strokeDasharray=`${w[s]}`;}),ge();},150);}return window.addEventListener("resize",B),window.addEventListener("orientationchange",B),ue>0?setTimeout(()=>ee.observe(e),ue):ee.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(K),ee.disconnect(),window.removeEventListener("resize",B),window.removeEventListener("orientationchange",B),clearTimeout(te),Q?.remove();},replay(){L=-1,V=-1,G=-1,R=false,P=false,J=0,k=false,z.clear(),clearTimeout(K),ye();},pause(){k=true,cancelAnimationFrame(D);},resume(){k&&(k=false,W&&(D=requestAnimationFrame(Z)));},seek(t){let s=Math.min(1,Math.max(0,t));U=s,L=s,k=true,cancelAnimationFrame(D),Pe(s,E);},getProgress(){return U}}}function Ge(e={}){let r=ref(null);return onMounted(()=>{if(!r.value)return;let o=ie(r.value,e);onUnmounted(()=>o.destroy());}),r}var ae=defineComponent({name:"ScrollDraw",props:{selector:{type:String},speed:{type:Number},fade:{type:Boolean},stagger:{type:Number},easing:{type:[String,Function]},direction:{type:String},trigger:{type:Object},onProgress:{type:Function},onStart:{type:Function},onComplete:{type:Function},once:{type:Boolean},debug:{type:Boolean}},setup(e,{slots:r}){let o=ref(null);return onMounted(()=>{if(!o.value)return;let n={};e.selector!=null&&(n.selector=e.selector),e.speed!=null&&(n.speed=e.speed),e.fade!=null&&(n.fade=e.fade),e.stagger!=null&&(n.stagger=e.stagger),e.easing!=null&&(n.easing=e.easing),e.direction!=null&&(n.direction=e.direction),e.trigger!=null&&(n.trigger=e.trigger),e.once!=null&&(n.once=e.once),e.debug!=null&&(n.debug=e.debug),e.onProgress!=null&&(n.onProgress=e.onProgress),e.onStart!=null&&(n.onStart=e.onStart),e.onComplete!=null&&(n.onComplete=e.onComplete);let i=ie(o.value,n);onUnmounted(()=>i.destroy());}),()=>h("div",{ref:o},r.default?.())}});function Je(){return {install(e){e.component("ScrollDraw",ae);}}}export{ae as ScrollDraw,Je as createScrollDrawPlugin,Ge as useScrollDraw};
1
+ import {defineComponent,ref,onMounted,onUnmounted,h}from'vue';var pe={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)};function de(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[o="top",n="bottom"]=r.split(/\s+/).filter(Boolean);return {element:o,viewport:n}}function De(e,r,o,n){switch(n){case "top":return e+o;case "center":return e+o+r/2;case "bottom":return e+o+r;default:return e+o}}function Te(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 ge(e){let r=e.tagName.toLowerCase();if(r==="rect"){let o=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(o+n)}if(r==="circle"){let o=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*o}return e.getTotalLength()}function Ge(e,r,o){return Math.min(o,Math.max(r,e))}function H(e,r,o,n){return o===r?0:Ge((e-r)/(o-r)*n,0,1)}function Me(e,r,o,n,a){let f=De(e.top,e.height,r,n.element)-Te(n.viewport,o),m=De(e.top,e.height,r,a.element)-Te(a.viewport,o);return {tStart:f,tEnd:m}}function ke(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let o=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(o)return [parseInt(o[1],16),parseInt(o[2],16),parseInt(o[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function ye(e,r,o){let n=ke(e),a=ke(r);return !n||!a?e:`rgb(${Math.round(n[0]+(a[0]-n[0])*o)},${Math.round(n[1]+(a[1]-n[1])*o)},${Math.round(n[2]+(a[2]-n[2])*o)})`}function Oe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function qe(e){let r=e.getAttribute("stroke"),o=e.getAttribute("fill");!r||r==="none"?Oe("Element has no stroke \u2014 path will not be visible.",e):o&&o!=="none"&&o!=="transparent"&&Oe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Be(e,r,o){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.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 a(){let f=o==="x"?window.scrollX:window.scrollY,m=e-f,O=r-f,B=o==="x";n.innerHTML=`
2
+ <div style="position:absolute;${B?`left:${m}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${m}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;${B?`left:${O}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${O}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(n),window.addEventListener("scroll",a,{passive:true}),a(),n}function Le(e,r,o){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,f=>{let m=parseFloat(f),O=n[a++]??m;return String(+(m+(O-m)*o).toFixed(4))})}function he(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:n="path, polyline, line, polygon, rect, circle",speed:a=1,fade:f=false,easing:m="linear",trigger:O={},stagger:B=0,direction:L="forward",once:X=false,debug:Ie=false,axis:x="y",scrollContainer:ne,autoReverse:oe=false,delay:we=0,strokeColor:I,strokeWidth:N,fillOpacity:R,waypoints:se,velocityScale:ie=false,threshold:Ne=0,rootMargin:Re="0px",repeat:_=0,repeatDelay:ve=0,morphTo:P,clip:le,onProgress:xe,onStart:Se,onComplete:j}=r,W=le===true?"left":typeof le=="string"?le:false,ae=typeof m=="function"?m:pe[m]??pe.linear,We=de(O.start??"top bottom"),Ve=de(O.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,$=Array.isArray(I)?I[0]:null,g=Array.isArray(I)?I[1]:typeof I=="string"?I:null,y=Array.isArray(N)?N[0]:null,h=Array.isArray(N)?N[1]:typeof N=="number"?N:null,b=Array.isArray(R)?R[0]:null,w=Array.isArray(R)?R[1]:typeof R=="number"?R:null;function V(t){let s=t*100;switch(W){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let G=W?[]:Array.from(e.querySelectorAll(n)),S=[],A=[],D=0,T=0,E=false,C=false,k=0,U=false,v=-1,J=-1,F=false,K=0,q=0,Q,ue=null,Y=new Set,Z=-1,Ee=performance.now();function ce(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function ze(){return d?x==="x"?d.clientWidth:d.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),s,l,p;if(d){let z=d.getBoundingClientRect();s=x==="x"?t.left-z.left+d.scrollLeft:t.top-z.top+d.scrollTop,l=x==="x"?t.width:t.height,p=ce();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,p=ce();let re=Me({top:s,height:l},p,ze(),We,Ve);D=re.tStart,T=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=Be(D,T,x));}function He(t,s){if(W){let l=s==="reverse"?1-t:t;e.style.clipPath=V(l);return}G.forEach((l,p)=>{l.style.strokeDashoffset=s==="reverse"?`${S[p]*t}`:`${S[p]*(1-t)}`,f&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),$&&g?l.style.stroke=ye($,g,t):g&&(l.style.stroke=g),y!==null&&h!==null?l.style.strokeWidth=`${y+(h-y)*t}`:h!==null&&(l.style.strokeWidth=`${h}`),b!==null&&w!==null?l.style.fillOpacity=`${b+(w-b)*t}`:w!==null&&(l.style.fillOpacity=`${w}`),P&&l.tagName.toLowerCase()==="path"&&A[p]&&l.setAttribute("d",Le(A[p],P,t));});}function Ae(){if(W){e.style.clipPath=V(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${S[s]}`,t.style.strokeDashoffset=L==="reverse"?"0":`${S[s]}`,f?t.style.opacity=L==="reverse"?"1":"0":t.style.opacity="",$&&(t.style.stroke=$),y!==null&&(t.style.strokeWidth=`${y}`),b!==null&&(t.style.fillOpacity=`${b}`),P&&t.tagName.toLowerCase()==="path"&&A[s]&&t.setAttribute("d",A[s]);});}if(G.forEach(t=>{qe(t);let s=ge(t);S.push(s),t.tagName.toLowerCase()==="path"?A.push(t.getAttribute("d")??""):A.push(""),o?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=L==="reverse"?`${s}`:"0",f&&(t.style.opacity="1"),g&&(t.style.stroke=g),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=L==="reverse"?"0":`${s}`,f?t.style.opacity=L==="reverse"?"1":"0":t.style.opacity="",$&&(t.style.stroke=$),y!==null&&(t.style.strokeWidth=`${y}`),b!==null&&(t.style.fillOpacity=`${b}`));}),W){if(o)return e.style.clipPath=V(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=V(0);}else if(o)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!U||F)return;let t=performance.now(),s=ce(),l=a;if(ie!==false){let i=t-Ee,u=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+u*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let p=oe?J===-1||s>=J?"forward":"reverse":L;J=s;let re=T-D,z=true;if(W){let i=ae(H(s,D,T,l));X&&!oe&&(v=Math.max(v,i),i=v),K=i;let u=p==="reverse"?1-i:i;e.style.clipPath=V(u),xe?.(i),!C&&H(s,D,T,l)>0&&(C=true,Se?.()),i>=1&&!E?(E=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,C=false,E=false,e.style.clipPath=V(0);},ve))):i<1&&!X&&(E=false),k=requestAnimationFrame(ee);return}if(G.forEach((i,u)=>{let M=u*B*re,c=ae(H(s,D+M,T+M,l));X&&!oe&&(v=Math.max(v,c),c=v),K=c,i.style.strokeDashoffset=p==="reverse"?`${S[u]*c}`:`${S[u]*(1-c)}`,f&&(i.style.opacity=p==="reverse"?`${1-c}`:`${c}`),$&&g?i.style.stroke=ye($,g,c):g&&(i.style.stroke=g),y!==null&&h!==null?i.style.strokeWidth=`${y+(h-y)*c}`:h!==null&&(i.style.strokeWidth=`${h}`),b!==null&&w!==null?i.style.fillOpacity=`${b+(w-b)*c}`:w!==null&&(i.style.fillOpacity=`${w}`),P&&i.tagName.toLowerCase()==="path"&&A[u]&&i.setAttribute("d",Le(A[u],P,c)),u===0&&xe?.(c),c<1&&(z=false);}),se){let i=ae(H(s,D,T,l));for(let u in se){let M=parseFloat(u);i>=M&&!Y.has(M)&&(Y.add(M),se[u]?.());}}!C&&H(s,D,T,l)>0&&(C=true,Se?.()),z&&!E?(E=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,C=false,E=false,Y.clear(),Ae();},ve))):!z&&!X&&(E=false),k=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{U=s.isIntersecting,U&&!F?k=requestAnimationFrame(ee):cancelAnimationFrame(k);});},{root:d??null,threshold:Ne,rootMargin:Re}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{S[s]=ge(t),t.style.strokeDasharray=`${S[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),we>0?setTimeout(()=>fe.observe(e),we):fe.observe(e),{destroy(){cancelAnimationFrame(k),clearTimeout(Q),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,J=-1,Z=-1,C=false,E=false,q=0,F=false,Y.clear(),clearTimeout(Q),Ae();},pause(){F=true,cancelAnimationFrame(k);},resume(){F&&(F=false,U&&(k=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,v=s,F=true,cancelAnimationFrame(k),He(s,L);},getProgress(){return K}}}function je(e={}){let r=ref(null);return onMounted(()=>{if(!r.value)return;let o=he(r.value,e);onUnmounted(()=>o.destroy());}),r}var be=defineComponent({name:"ScrollDraw",props:{selector:{type:String},speed:{type:Number},fade:{type:Boolean},stagger:{type:Number},easing:{type:[String,Function]},direction:{type:String},trigger:{type:Object},onProgress:{type:Function},onStart:{type:Function},onComplete:{type:Function},once:{type:Boolean},debug:{type:Boolean}},setup(e,{slots:r}){let o=ref(null);return onMounted(()=>{if(!o.value)return;let n={};e.selector!=null&&(n.selector=e.selector),e.speed!=null&&(n.speed=e.speed),e.fade!=null&&(n.fade=e.fade),e.stagger!=null&&(n.stagger=e.stagger),e.easing!=null&&(n.easing=e.easing),e.direction!=null&&(n.direction=e.direction),e.trigger!=null&&(n.trigger=e.trigger),e.once!=null&&(n.once=e.once),e.debug!=null&&(n.debug=e.debug),e.onProgress!=null&&(n.onProgress=e.onProgress),e.onStart!=null&&(n.onStart=e.onStart),e.onComplete!=null&&(n.onComplete=e.onComplete);let a=he(o.value,n);onUnmounted(()=>a.destroy());}),()=>h("div",{ref:o},r.default?.())}});function tt(){return {install(e){e.component("ScrollDraw",be);}}}export{be as ScrollDraw,tt as createScrollDrawPlugin,je as useScrollDraw};
@@ -1,3 +1,3 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var re={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)};function ne(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function ge(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function ye(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 oe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ce(e,r,n){return Math.min(n,Math.max(r,e))}function H(e,r,n,o){return n===r?0:Ce((e-r)/(n-r)*o,0,1)}function be(e,r,n,o,i){let l=ge(e.top,e.height,r,o.element)-ye(o.viewport,n),u=ge(e.top,e.height,r,i.element)-ye(i.viewport,n);return {tStart:l,tEnd:u}}function he(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function se(e,r,n){let o=he(e),i=he(r);return !o||!i?e:`rgb(${Math.round(o[0]+(i[0]-o[0])*n)},${Math.round(o[1]+(i[1]-o[1])*n)},${Math.round(o[2]+(i[2]-o[2])*n)})`}function we(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Fe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?we("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&we("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ne(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 i(){let l=n==="x"?window.scrollX:window.scrollY,u=e-l,E=r-l,P=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${P?`left:${u}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${u}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;${P?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",i,{passive:true}),i(),o}function ve(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,l=>{let u=parseFloat(l),E=o[i++]??u;return String(+(u+(E-u)*n).toFixed(4))})}function xe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:i=1,fade:l=false,easing:u="linear",trigger:E={},stagger:P=0,direction:k="forward",once:ie=false,debug:Ee=false,axis:b="y",scrollContainer:X,autoReverse:ae=false,delay:le=0,strokeColor:D,strokeWidth:L,waypoints:_,velocityScale:J=false,threshold:ke=0,rootMargin:$e="0px",repeat:ce=0,repeatDelay:Ae=0,morphTo:$,onProgress:Se,onStart:Te,onComplete:ue}=r,fe=typeof u=="function"?u:re[u]??re.linear,De=ne(E.start??"top bottom"),Le=ne(E.end??"bottom top"),p=typeof X=="string"?document.querySelector(X):X??null,v=Array.isArray(D)?D[0]:null,g=Array.isArray(D)?D[1]:typeof D=="string"?D:null,y=Array.isArray(L)?L[0]:null,h=Array.isArray(L)?L[1]:typeof L=="number"?L:null,N=Array.from(e.querySelectorAll(o)),w=[],x=[],M=0,I=0,R=false,W=false,A=0,V=false,C=-1,z=-1,S=false,K=0,Q=0,U,Y=null,O=new Set,G=-1,pe=performance.now();function Z(){return p?b==="x"?p.scrollLeft:p.scrollTop:b==="x"?window.scrollX:window.scrollY}function Me(){return p?b==="x"?p.clientWidth:p.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function me(){let t=e.getBoundingClientRect(),s,a,m;if(p){let F=p.getBoundingClientRect();s=b==="x"?t.left-F.left+p.scrollLeft:t.top-F.top+p.scrollTop,a=b==="x"?t.width:t.height,m=Z();}else s=b==="x"?t.left:t.top,a=b==="x"?t.width:t.height,m=Z();let B=be({top:s,height:a},m,Me(),De,Le);M=B.tStart,I=B.tEnd,Ee&&process.env.NODE_ENV!=="production"&&(Y?.remove(),Y=Ne(M,I,b));}function Ie(t,s){N.forEach((a,m)=>{a.style.strokeDashoffset=s==="reverse"?`${w[m]*t}`:`${w[m]*(1-t)}`,l&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),v&&g?a.style.stroke=se(v,g,t):g&&(a.style.stroke=g),y!==null&&h!==null?a.style.strokeWidth=`${y+(h-y)*t}`:h!==null&&(a.style.strokeWidth=`${h}`),$&&a.tagName.toLowerCase()==="path"&&x[m]&&a.setAttribute("d",ve(x[m],$,t));});}function de(){N.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=k==="reverse"?"0":`${w[s]}`,l?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`),$&&t.tagName.toLowerCase()==="path"&&x[s]&&t.setAttribute("d",x[s]);});}if(N.forEach(t=>{Fe(t);let s=oe(t);w.push(s),t.tagName.toLowerCase()==="path"?x.push(t.getAttribute("d")??""):x.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?`${s}`:"0",l&&(t.style.opacity="1"),g&&(t.style.stroke=g),h!==null&&(t.style.strokeWidth=`${h}`),$&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",$)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?"0":`${s}`,l?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`));}),n)return ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};me();function j(){if(!V||S)return;let t=performance.now(),s=Z(),a=i;if(J!==false){let c=t-pe,d=c>0?Math.abs(s-(G<0?s:G))/c:0;a=i*Math.max(.2,1+d*(typeof J=="number"?J:1)*.04);}G=s,pe=t;let m=ae?z===-1||s>=z?"forward":"reverse":k;z=s;let B=I-M,F=true;if(N.forEach((c,d)=>{let T=d*P*B,f=fe(H(s,M+T,I+T,a));ie&&!ae&&(C=Math.max(C,f),f=C),K=f,c.style.strokeDashoffset=m==="reverse"?`${w[d]*f}`:`${w[d]*(1-f)}`,l&&(c.style.opacity=m==="reverse"?`${1-f}`:`${f}`),v&&g?c.style.stroke=se(v,g,f):g&&(c.style.stroke=g),y!==null&&h!==null?c.style.strokeWidth=`${y+(h-y)*f}`:h!==null&&(c.style.strokeWidth=`${h}`),$&&c.tagName.toLowerCase()==="path"&&x[d]&&c.setAttribute("d",ve(x[d],$,f)),d===0&&Se?.(f),f<1&&(F=false);}),_){let c=fe(H(s,M,I,a));for(let d in _){let T=parseFloat(d);c>=T&&!O.has(T)&&(O.add(T),_[d]?.());}}!W&&H(s,M,I,a)>0&&(W=true,Te?.()),F&&!R?(R=true,ue?.(),Q<(ce==="infinite"?1/0:ce??0)&&(Q++,U=setTimeout(()=>{C=-1,W=false,R=false,O.clear(),de();},Ae))):!F&&!ie&&(R=false),A=requestAnimationFrame(j);}let ee=new IntersectionObserver(t=>{t.forEach(s=>{V=s.isIntersecting,V&&!S?A=requestAnimationFrame(j):cancelAnimationFrame(A);});},{root:p??null,threshold:ke,rootMargin:$e}),te;function q(){clearTimeout(te),te=setTimeout(()=>{N.forEach((t,s)=>{w[s]=oe(t),t.style.strokeDasharray=`${w[s]}`;}),me();},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),le>0?setTimeout(()=>ee.observe(e),le):ee.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(U),ee.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(te),Y?.remove();},replay(){C=-1,z=-1,G=-1,W=false,R=false,Q=0,S=false,O.clear(),clearTimeout(U),de();},pause(){S=true,cancelAnimationFrame(A);},resume(){S&&(S=false,V&&(A=requestAnimationFrame(j)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,C=s,S=true,cancelAnimationFrame(A),Ie(s,k);},getProgress(){return K}}}function He({children:e,className:r,style:n,...o}){let i=react.useRef(null);return react.useEffect(()=>{if(!i.current)return;let l=xe(i.current,o);return ()=>l.destroy()},[]),jsxRuntime.jsx("div",{ref:i,className:r,style:n,children:e})}exports.ScrollDraw=He;
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var Z={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)};function ee(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",s="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:s}}function De(e,r,n,s){switch(s){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Le(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){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),s=parseFloat(e.getAttribute("height")??"0");return 2*(n+s)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function We(e,r,n){return Math.min(n,Math.max(r,e))}function H(e,r,n,s){return n===r?0:We((e-r)/(n-r)*s,0,1)}function he(e,r,n,s,l){let c=De(e.top,e.height,r,s.element)-Le(s.viewport,n),f=De(e.top,e.height,r,l.element)-Le(l.viewport,n);return {tStart:c,tEnd:f}}function Pe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function $e(e,r,n){let s=Pe(e),l=Pe(r);return !s||!l?e:`rgb(${Math.round(s[0]+(l[0]-s[0])*n)},${Math.round(s[1]+(l[1]-s[1])*n)},${Math.round(s[2]+(l[2]-s[2])*n)})`}function Me(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Ve(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Me("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Me("Element has a fill \u2014 it may obscure the stroke animation.",e);}function qe(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.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 c=n==="x"?window.scrollX:window.scrollY,f=e-c,x=r-c,g=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${g?`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;${g?`left:${x}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${x}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(s),window.addEventListener("scroll",l,{passive:true}),l(),s}function Ce(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let f=parseFloat(c),x=s[l++]??f;return String(+(f+(x-f)*n).toFixed(4))})}function Oe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:l=1,fade:c=false,easing:f="linear",trigger:x={},stagger:g=0,direction:y="forward",once:G=false,debug:P=false,axis:h="y",scrollContainer:te,autoReverse:_=false,delay:re=0,strokeColor:E,strokeWidth:b,fillOpacity:M,waypoints:ne,velocityScale:j=false,threshold:ie=0,rootMargin:le="0px",repeat:F=0,repeatDelay:B=0,morphTo:u,clip:w,onProgress:Y,onStart:J,onComplete:C}=r,T=w===true?"left":typeof w=="string"?w:false,be=typeof f=="function"?f:Z[f]??Z.linear,Fe=ee(x.start??"top bottom"),Ie=ee(x.end??"bottom top"),v=typeof te=="string"?document.querySelector(te):te??null,I=Array.isArray(E)?E[0]:null,$=Array.isArray(E)?E[1]:typeof E=="string"?E:null,S=Array.isArray(b)?b[0]:null,A=Array.isArray(b)?b[1]:typeof b=="number"?b:null,k=Array.isArray(M)?M[0]:null,D=Array.isArray(M)?M[1]:typeof M=="number"?M:null;function K(t){let o=t*100;switch(T){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let oe=T?[]:Array.from(e.querySelectorAll(s)),O=[],N=[],z=0,W=0,R=false,U=false,V=0,ae=false,L=-1,ce=-1,X=false,ue=0,se=0,fe,we=null,pe=new Set,me=-1,Se=performance.now();function ve(){return v?h==="x"?v.scrollLeft:v.scrollTop:h==="x"?window.scrollX:window.scrollY}function Ne(){return v?h==="x"?v.clientWidth:v.clientHeight:h==="x"?window.innerWidth:window.innerHeight}function Ae(){let t=e.getBoundingClientRect(),o,a,d;if(v){let Q=v.getBoundingClientRect();o=h==="x"?t.left-Q.left+v.scrollLeft:t.top-Q.top+v.scrollTop,a=h==="x"?t.width:t.height,d=ve();}else o=h==="x"?t.left:t.top,a=h==="x"?t.width:t.height,d=ve();let ye=he({top:o,height:a},d,Ne(),Fe,Ie);z=ye.tStart,W=ye.tEnd,P&&process.env.NODE_ENV!=="production"&&(we?.remove(),we=qe(z,W,h));}function ze(t,o){if(T){let a=o==="reverse"?1-t:t;e.style.clipPath=K(a);return}oe.forEach((a,d)=>{a.style.strokeDashoffset=o==="reverse"?`${O[d]*t}`:`${O[d]*(1-t)}`,c&&(a.style.opacity=o==="reverse"?`${1-t}`:`${t}`),I&&$?a.style.stroke=$e(I,$,t):$&&(a.style.stroke=$),S!==null&&A!==null?a.style.strokeWidth=`${S+(A-S)*t}`:A!==null&&(a.style.strokeWidth=`${A}`),k!==null&&D!==null?a.style.fillOpacity=`${k+(D-k)*t}`:D!==null&&(a.style.fillOpacity=`${D}`),u&&a.tagName.toLowerCase()==="path"&&N[d]&&a.setAttribute("d",Ce(N[d],u,t));});}function ke(){if(T){e.style.clipPath=K(0);return}oe.forEach((t,o)=>{t.style.strokeDasharray=`${O[o]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${O[o]}`,c?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),S!==null&&(t.style.strokeWidth=`${S}`),k!==null&&(t.style.fillOpacity=`${k}`),u&&t.tagName.toLowerCase()==="path"&&N[o]&&t.setAttribute("d",N[o]);});}if(oe.forEach(t=>{Ve(t);let o=Te(t);O.push(o),t.tagName.toLowerCase()==="path"?N.push(t.getAttribute("d")??""):N.push(""),n?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?`${o}`:"0",c&&(t.style.opacity="1"),$&&(t.style.stroke=$),A!==null&&(t.style.strokeWidth=`${A}`),D!==null&&(t.style.fillOpacity=`${D}`),u&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",u)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?"0":`${o}`,c?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),S!==null&&(t.style.strokeWidth=`${S}`),k!==null&&(t.style.fillOpacity=`${k}`));}),T){if(n)return e.style.clipPath=K(1),C?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=K(0);}else if(n)return C?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};Ae();function de(){if(!ae||X)return;let t=performance.now(),o=ve(),a=l;if(j!==false){let i=t-Se,p=i>0?Math.abs(o-(me<0?o:me))/i:0;a=l*Math.max(.2,1+p*(typeof j=="number"?j:1)*.04);}me=o,Se=t;let d=_?ce===-1||o>=ce?"forward":"reverse":y;ce=o;let ye=W-z,Q=true;if(T){let i=be(H(o,z,W,a));G&&!_&&(L=Math.max(L,i),i=L),ue=i;let p=d==="reverse"?1-i:i;e.style.clipPath=K(p),Y?.(i),!U&&H(o,z,W,a)>0&&(U=true,J?.()),i>=1&&!R?(R=true,C?.(),se<(F==="infinite"?1/0:F??0)&&(se++,fe=setTimeout(()=>{L=-1,U=false,R=false,e.style.clipPath=K(0);},B))):i<1&&!G&&(R=false),V=requestAnimationFrame(de);return}if(oe.forEach((i,p)=>{let q=p*g*ye,m=be(H(o,z+q,W+q,a));G&&!_&&(L=Math.max(L,m),m=L),ue=m,i.style.strokeDashoffset=d==="reverse"?`${O[p]*m}`:`${O[p]*(1-m)}`,c&&(i.style.opacity=d==="reverse"?`${1-m}`:`${m}`),I&&$?i.style.stroke=$e(I,$,m):$&&(i.style.stroke=$),S!==null&&A!==null?i.style.strokeWidth=`${S+(A-S)*m}`:A!==null&&(i.style.strokeWidth=`${A}`),k!==null&&D!==null?i.style.fillOpacity=`${k+(D-k)*m}`:D!==null&&(i.style.fillOpacity=`${D}`),u&&i.tagName.toLowerCase()==="path"&&N[p]&&i.setAttribute("d",Ce(N[p],u,m)),p===0&&Y?.(m),m<1&&(Q=false);}),ne){let i=be(H(o,z,W,a));for(let p in ne){let q=parseFloat(p);i>=q&&!pe.has(q)&&(pe.add(q),ne[p]?.());}}!U&&H(o,z,W,a)>0&&(U=true,J?.()),Q&&!R?(R=true,C?.(),se<(F==="infinite"?1/0:F??0)&&(se++,fe=setTimeout(()=>{L=-1,U=false,R=false,pe.clear(),ke();},B))):!Q&&!G&&(R=false),V=requestAnimationFrame(de);}let xe=new IntersectionObserver(t=>{t.forEach(o=>{ae=o.isIntersecting,ae&&!X?V=requestAnimationFrame(de):cancelAnimationFrame(V);});},{root:v??null,threshold:ie,rootMargin:le}),Ee;function ge(){clearTimeout(Ee),Ee=setTimeout(()=>{oe.forEach((t,o)=>{O[o]=Te(t),t.style.strokeDasharray=`${O[o]}`;}),Ae();},150);}return window.addEventListener("resize",ge),window.addEventListener("orientationchange",ge),re>0?setTimeout(()=>xe.observe(e),re):xe.observe(e),{destroy(){cancelAnimationFrame(V),clearTimeout(fe),xe.disconnect(),window.removeEventListener("resize",ge),window.removeEventListener("orientationchange",ge),clearTimeout(Ee),we?.remove();},replay(){L=-1,ce=-1,me=-1,U=false,R=false,se=0,X=false,pe.clear(),clearTimeout(fe),ke();},pause(){X=true,cancelAnimationFrame(V);},resume(){X&&(X=false,ae&&(V=requestAnimationFrame(de)));},seek(t){let o=Math.min(1,Math.max(0,t));ue=o,L=o,X=true,cancelAnimationFrame(V),ze(o,y);},getProgress(){return ue}}}function Be(e,r={}){let[n,s]=react.useState(0),l=react.useRef(r);l.current=r;let c=react.useRef(-1);return react.useEffect(()=>{if(typeof window>"u")return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){s(1);return}let f=typeof e=="string"?document.querySelector(e):e.current;if(!f)return;let x=f,{axis:g="y",scrollContainer:y,trigger:G={}}=l.current,P=typeof y=="string"?document.querySelector(y):y??null,h=ee(G.start??"top bottom"),te=ee(G.end??"bottom top"),_=0,re=0,E=false,b=0;function M(){return P?g==="x"?P.scrollLeft:P.scrollTop:g==="x"?window.scrollX:window.scrollY}function ne(){return P?g==="x"?P.clientWidth:P.clientHeight:g==="x"?window.innerWidth:window.innerHeight}function j(){let u=x.getBoundingClientRect(),w=M(),Y=g==="x"?u.left:u.top,J=g==="x"?u.width:u.height,C=he({top:Y,height:J},w,ne(),h,te);_=C.tStart,re=C.tEnd;}function ie(){if(!E)return;let{speed:u=1,easing:w="linear",once:Y=false}=l.current,J=typeof w=="function"?w:Z[w]??Z.linear,C=H(M(),_,re,u),T=J(C);Y&&(c.current=Math.max(c.current,T),T=c.current),s(T),b=requestAnimationFrame(ie);}let le=new IntersectionObserver(u=>{u.forEach(w=>{E=w.isIntersecting,E?b=requestAnimationFrame(ie):cancelAnimationFrame(b);});},{root:P??null,threshold:0});j(),le.observe(x);let F;function B(){clearTimeout(F),F=setTimeout(j,150);}return window.addEventListener("resize",B),window.addEventListener("orientationchange",B),()=>{cancelAnimationFrame(b),clearTimeout(F),le.disconnect(),window.removeEventListener("resize",B),window.removeEventListener("orientationchange",B);}},[]),n}function nt({children:e,className:r,style:n,...s}){let l=react.useRef(null);return react.useEffect(()=>{if(!l.current)return;let c=Oe(l.current,s);return ()=>c.destroy()},[]),jsxRuntime.jsx("div",{ref:l,className:r,style:n,children:e})}exports.ScrollDraw=nt;exports.useScrollDrawProgress=Be;
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React from 'react';
2
+ import React, { RefObject } from 'react';
3
3
 
4
4
  type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
5
5
  interface TriggerConfig {
@@ -28,6 +28,14 @@ interface ScrollDrawOptions {
28
28
  strokeColor?: string | [string, string];
29
29
  /** Animate stroke width. Single number = static override. Tuple = interpolate from → to. */
30
30
  strokeWidth?: number | [number, number];
31
+ /** Animate fill opacity. Single number = static override. Tuple [from, to] = interpolate as the path draws. Use [0, 1] to flood fill in sync with the stroke draw. */
32
+ fillOpacity?: number | [number, number];
33
+ /**
34
+ * Reveal the container using CSS clip-path instead of stroke-dashoffset.
35
+ * Works on any content — SVG, images, text, divs.
36
+ * `true` defaults to `'left'`. Values: `'left' | 'right' | 'top' | 'bottom' | 'center'`.
37
+ */
38
+ clip?: boolean | 'left' | 'right' | 'top' | 'bottom' | 'center';
31
39
  /** Fire callbacks at specific progress thresholds (0–1). Resets on replay(). */
32
40
  waypoints?: Record<number, () => void>;
33
41
  /** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
@@ -47,6 +55,32 @@ interface ScrollDrawOptions {
47
55
  onComplete?: () => void;
48
56
  }
49
57
 
58
+ interface UseScrollDrawProgressOptions {
59
+ /** Same speed multiplier as ScrollDraw. Values > 1 complete faster. Default 1. */
60
+ speed?: number;
61
+ /** Same easing curves as ScrollDraw. Default 'linear'. */
62
+ easing?: EasingName | ((t: number) => number);
63
+ /** Same trigger syntax as ScrollDraw. Default: start 'top bottom', end 'bottom top'. */
64
+ trigger?: TriggerConfig;
65
+ /** Scroll axis. Default 'y'. */
66
+ axis?: 'x' | 'y';
67
+ /** CSS selector or Element for a custom scroll container. Default: window. */
68
+ scrollContainer?: string | Element;
69
+ /** Lock at maximum progress once reached — never decreases on scroll back. Default false. */
70
+ once?: boolean;
71
+ }
72
+ /**
73
+ * Returns a reactive scroll progress value (0–1) for the given element.
74
+ * Identical trigger/speed/easing semantics to ScrollDraw — use this to
75
+ * drive any animation alongside or independent of an SVG draw.
76
+ *
77
+ * @example
78
+ * const ref = useRef<HTMLDivElement>(null);
79
+ * const progress = useScrollDrawProgress(ref, { speed: 1.2, easing: 'ease-out' });
80
+ * // progress is 0→1 as ref scrolls through the viewport
81
+ */
82
+ declare function useScrollDrawProgress(target: RefObject<Element | null> | string, options?: UseScrollDrawProgressOptions): number;
83
+
50
84
  type ScrollDrawProps = ScrollDrawOptions & {
51
85
  children: React.ReactNode;
52
86
  className?: string;
@@ -54,4 +88,4 @@ type ScrollDrawProps = ScrollDrawOptions & {
54
88
  };
55
89
  declare function ScrollDraw({ children, className, style, ...options }: ScrollDrawProps): react_jsx_runtime.JSX.Element;
56
90
 
57
- export { ScrollDraw };
91
+ export { ScrollDraw, type UseScrollDrawProgressOptions, useScrollDrawProgress };
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React from 'react';
2
+ import React, { RefObject } from 'react';
3
3
 
4
4
  type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
5
5
  interface TriggerConfig {
@@ -28,6 +28,14 @@ interface ScrollDrawOptions {
28
28
  strokeColor?: string | [string, string];
29
29
  /** Animate stroke width. Single number = static override. Tuple = interpolate from → to. */
30
30
  strokeWidth?: number | [number, number];
31
+ /** Animate fill opacity. Single number = static override. Tuple [from, to] = interpolate as the path draws. Use [0, 1] to flood fill in sync with the stroke draw. */
32
+ fillOpacity?: number | [number, number];
33
+ /**
34
+ * Reveal the container using CSS clip-path instead of stroke-dashoffset.
35
+ * Works on any content — SVG, images, text, divs.
36
+ * `true` defaults to `'left'`. Values: `'left' | 'right' | 'top' | 'bottom' | 'center'`.
37
+ */
38
+ clip?: boolean | 'left' | 'right' | 'top' | 'bottom' | 'center';
31
39
  /** Fire callbacks at specific progress thresholds (0–1). Resets on replay(). */
32
40
  waypoints?: Record<number, () => void>;
33
41
  /** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
@@ -47,6 +55,32 @@ interface ScrollDrawOptions {
47
55
  onComplete?: () => void;
48
56
  }
49
57
 
58
+ interface UseScrollDrawProgressOptions {
59
+ /** Same speed multiplier as ScrollDraw. Values > 1 complete faster. Default 1. */
60
+ speed?: number;
61
+ /** Same easing curves as ScrollDraw. Default 'linear'. */
62
+ easing?: EasingName | ((t: number) => number);
63
+ /** Same trigger syntax as ScrollDraw. Default: start 'top bottom', end 'bottom top'. */
64
+ trigger?: TriggerConfig;
65
+ /** Scroll axis. Default 'y'. */
66
+ axis?: 'x' | 'y';
67
+ /** CSS selector or Element for a custom scroll container. Default: window. */
68
+ scrollContainer?: string | Element;
69
+ /** Lock at maximum progress once reached — never decreases on scroll back. Default false. */
70
+ once?: boolean;
71
+ }
72
+ /**
73
+ * Returns a reactive scroll progress value (0–1) for the given element.
74
+ * Identical trigger/speed/easing semantics to ScrollDraw — use this to
75
+ * drive any animation alongside or independent of an SVG draw.
76
+ *
77
+ * @example
78
+ * const ref = useRef<HTMLDivElement>(null);
79
+ * const progress = useScrollDrawProgress(ref, { speed: 1.2, easing: 'ease-out' });
80
+ * // progress is 0→1 as ref scrolls through the viewport
81
+ */
82
+ declare function useScrollDrawProgress(target: RefObject<Element | null> | string, options?: UseScrollDrawProgressOptions): number;
83
+
50
84
  type ScrollDrawProps = ScrollDrawOptions & {
51
85
  children: React.ReactNode;
52
86
  className?: string;
@@ -54,4 +88,4 @@ type ScrollDrawProps = ScrollDrawOptions & {
54
88
  };
55
89
  declare function ScrollDraw({ children, className, style, ...options }: ScrollDrawProps): react_jsx_runtime.JSX.Element;
56
90
 
57
- export { ScrollDraw };
91
+ export { ScrollDraw, type UseScrollDrawProgressOptions, useScrollDrawProgress };
@@ -1,3 +1,3 @@
1
- import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var re={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)};function ne(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function ge(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function ye(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 oe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ce(e,r,n){return Math.min(n,Math.max(r,e))}function H(e,r,n,o){return n===r?0:Ce((e-r)/(n-r)*o,0,1)}function be(e,r,n,o,i){let l=ge(e.top,e.height,r,o.element)-ye(o.viewport,n),u=ge(e.top,e.height,r,i.element)-ye(i.viewport,n);return {tStart:l,tEnd:u}}function he(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function se(e,r,n){let o=he(e),i=he(r);return !o||!i?e:`rgb(${Math.round(o[0]+(i[0]-o[0])*n)},${Math.round(o[1]+(i[1]-o[1])*n)},${Math.round(o[2]+(i[2]-o[2])*n)})`}function we(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Fe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?we("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&we("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ne(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 i(){let l=n==="x"?window.scrollX:window.scrollY,u=e-l,E=r-l,P=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${P?`left:${u}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${u}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;${P?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",i,{passive:true}),i(),o}function ve(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,l=>{let u=parseFloat(l),E=o[i++]??u;return String(+(u+(E-u)*n).toFixed(4))})}function xe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:i=1,fade:l=false,easing:u="linear",trigger:E={},stagger:P=0,direction:k="forward",once:ie=false,debug:Ee=false,axis:b="y",scrollContainer:X,autoReverse:ae=false,delay:le=0,strokeColor:D,strokeWidth:L,waypoints:_,velocityScale:J=false,threshold:ke=0,rootMargin:$e="0px",repeat:ce=0,repeatDelay:Ae=0,morphTo:$,onProgress:Se,onStart:Te,onComplete:ue}=r,fe=typeof u=="function"?u:re[u]??re.linear,De=ne(E.start??"top bottom"),Le=ne(E.end??"bottom top"),p=typeof X=="string"?document.querySelector(X):X??null,v=Array.isArray(D)?D[0]:null,g=Array.isArray(D)?D[1]:typeof D=="string"?D:null,y=Array.isArray(L)?L[0]:null,h=Array.isArray(L)?L[1]:typeof L=="number"?L:null,N=Array.from(e.querySelectorAll(o)),w=[],x=[],M=0,I=0,R=false,W=false,A=0,V=false,C=-1,z=-1,S=false,K=0,Q=0,U,Y=null,O=new Set,G=-1,pe=performance.now();function Z(){return p?b==="x"?p.scrollLeft:p.scrollTop:b==="x"?window.scrollX:window.scrollY}function Me(){return p?b==="x"?p.clientWidth:p.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function me(){let t=e.getBoundingClientRect(),s,a,m;if(p){let F=p.getBoundingClientRect();s=b==="x"?t.left-F.left+p.scrollLeft:t.top-F.top+p.scrollTop,a=b==="x"?t.width:t.height,m=Z();}else s=b==="x"?t.left:t.top,a=b==="x"?t.width:t.height,m=Z();let B=be({top:s,height:a},m,Me(),De,Le);M=B.tStart,I=B.tEnd,Ee&&process.env.NODE_ENV!=="production"&&(Y?.remove(),Y=Ne(M,I,b));}function Ie(t,s){N.forEach((a,m)=>{a.style.strokeDashoffset=s==="reverse"?`${w[m]*t}`:`${w[m]*(1-t)}`,l&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),v&&g?a.style.stroke=se(v,g,t):g&&(a.style.stroke=g),y!==null&&h!==null?a.style.strokeWidth=`${y+(h-y)*t}`:h!==null&&(a.style.strokeWidth=`${h}`),$&&a.tagName.toLowerCase()==="path"&&x[m]&&a.setAttribute("d",ve(x[m],$,t));});}function de(){N.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=k==="reverse"?"0":`${w[s]}`,l?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`),$&&t.tagName.toLowerCase()==="path"&&x[s]&&t.setAttribute("d",x[s]);});}if(N.forEach(t=>{Fe(t);let s=oe(t);w.push(s),t.tagName.toLowerCase()==="path"?x.push(t.getAttribute("d")??""):x.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?`${s}`:"0",l&&(t.style.opacity="1"),g&&(t.style.stroke=g),h!==null&&(t.style.strokeWidth=`${h}`),$&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",$)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?"0":`${s}`,l?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`));}),n)return ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};me();function j(){if(!V||S)return;let t=performance.now(),s=Z(),a=i;if(J!==false){let c=t-pe,d=c>0?Math.abs(s-(G<0?s:G))/c:0;a=i*Math.max(.2,1+d*(typeof J=="number"?J:1)*.04);}G=s,pe=t;let m=ae?z===-1||s>=z?"forward":"reverse":k;z=s;let B=I-M,F=true;if(N.forEach((c,d)=>{let T=d*P*B,f=fe(H(s,M+T,I+T,a));ie&&!ae&&(C=Math.max(C,f),f=C),K=f,c.style.strokeDashoffset=m==="reverse"?`${w[d]*f}`:`${w[d]*(1-f)}`,l&&(c.style.opacity=m==="reverse"?`${1-f}`:`${f}`),v&&g?c.style.stroke=se(v,g,f):g&&(c.style.stroke=g),y!==null&&h!==null?c.style.strokeWidth=`${y+(h-y)*f}`:h!==null&&(c.style.strokeWidth=`${h}`),$&&c.tagName.toLowerCase()==="path"&&x[d]&&c.setAttribute("d",ve(x[d],$,f)),d===0&&Se?.(f),f<1&&(F=false);}),_){let c=fe(H(s,M,I,a));for(let d in _){let T=parseFloat(d);c>=T&&!O.has(T)&&(O.add(T),_[d]?.());}}!W&&H(s,M,I,a)>0&&(W=true,Te?.()),F&&!R?(R=true,ue?.(),Q<(ce==="infinite"?1/0:ce??0)&&(Q++,U=setTimeout(()=>{C=-1,W=false,R=false,O.clear(),de();},Ae))):!F&&!ie&&(R=false),A=requestAnimationFrame(j);}let ee=new IntersectionObserver(t=>{t.forEach(s=>{V=s.isIntersecting,V&&!S?A=requestAnimationFrame(j):cancelAnimationFrame(A);});},{root:p??null,threshold:ke,rootMargin:$e}),te;function q(){clearTimeout(te),te=setTimeout(()=>{N.forEach((t,s)=>{w[s]=oe(t),t.style.strokeDasharray=`${w[s]}`;}),me();},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),le>0?setTimeout(()=>ee.observe(e),le):ee.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(U),ee.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(te),Y?.remove();},replay(){C=-1,z=-1,G=-1,W=false,R=false,Q=0,S=false,O.clear(),clearTimeout(U),de();},pause(){S=true,cancelAnimationFrame(A);},resume(){S&&(S=false,V&&(A=requestAnimationFrame(j)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,C=s,S=true,cancelAnimationFrame(A),Ie(s,k);},getProgress(){return K}}}function He({children:e,className:r,style:n,...o}){let i=useRef(null);return useEffect(()=>{if(!i.current)return;let l=xe(i.current,o);return ()=>l.destroy()},[]),jsx("div",{ref:i,className:r,style:n,children:e})}export{He as ScrollDraw};
1
+ import {useState,useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var Z={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)};function ee(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",s="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:s}}function De(e,r,n,s){switch(s){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Le(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){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),s=parseFloat(e.getAttribute("height")??"0");return 2*(n+s)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function We(e,r,n){return Math.min(n,Math.max(r,e))}function H(e,r,n,s){return n===r?0:We((e-r)/(n-r)*s,0,1)}function he(e,r,n,s,l){let c=De(e.top,e.height,r,s.element)-Le(s.viewport,n),f=De(e.top,e.height,r,l.element)-Le(l.viewport,n);return {tStart:c,tEnd:f}}function Pe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function $e(e,r,n){let s=Pe(e),l=Pe(r);return !s||!l?e:`rgb(${Math.round(s[0]+(l[0]-s[0])*n)},${Math.round(s[1]+(l[1]-s[1])*n)},${Math.round(s[2]+(l[2]-s[2])*n)})`}function Me(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Ve(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Me("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Me("Element has a fill \u2014 it may obscure the stroke animation.",e);}function qe(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.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 c=n==="x"?window.scrollX:window.scrollY,f=e-c,x=r-c,g=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${g?`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;${g?`left:${x}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${x}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(s),window.addEventListener("scroll",l,{passive:true}),l(),s}function Ce(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let f=parseFloat(c),x=s[l++]??f;return String(+(f+(x-f)*n).toFixed(4))})}function Oe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:l=1,fade:c=false,easing:f="linear",trigger:x={},stagger:g=0,direction:y="forward",once:G=false,debug:P=false,axis:h="y",scrollContainer:te,autoReverse:_=false,delay:re=0,strokeColor:E,strokeWidth:b,fillOpacity:M,waypoints:ne,velocityScale:j=false,threshold:ie=0,rootMargin:le="0px",repeat:F=0,repeatDelay:B=0,morphTo:u,clip:w,onProgress:Y,onStart:J,onComplete:C}=r,T=w===true?"left":typeof w=="string"?w:false,be=typeof f=="function"?f:Z[f]??Z.linear,Fe=ee(x.start??"top bottom"),Ie=ee(x.end??"bottom top"),v=typeof te=="string"?document.querySelector(te):te??null,I=Array.isArray(E)?E[0]:null,$=Array.isArray(E)?E[1]:typeof E=="string"?E:null,S=Array.isArray(b)?b[0]:null,A=Array.isArray(b)?b[1]:typeof b=="number"?b:null,k=Array.isArray(M)?M[0]:null,D=Array.isArray(M)?M[1]:typeof M=="number"?M:null;function K(t){let o=t*100;switch(T){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let oe=T?[]:Array.from(e.querySelectorAll(s)),O=[],N=[],z=0,W=0,R=false,U=false,V=0,ae=false,L=-1,ce=-1,X=false,ue=0,se=0,fe,we=null,pe=new Set,me=-1,Se=performance.now();function ve(){return v?h==="x"?v.scrollLeft:v.scrollTop:h==="x"?window.scrollX:window.scrollY}function Ne(){return v?h==="x"?v.clientWidth:v.clientHeight:h==="x"?window.innerWidth:window.innerHeight}function Ae(){let t=e.getBoundingClientRect(),o,a,d;if(v){let Q=v.getBoundingClientRect();o=h==="x"?t.left-Q.left+v.scrollLeft:t.top-Q.top+v.scrollTop,a=h==="x"?t.width:t.height,d=ve();}else o=h==="x"?t.left:t.top,a=h==="x"?t.width:t.height,d=ve();let ye=he({top:o,height:a},d,Ne(),Fe,Ie);z=ye.tStart,W=ye.tEnd,P&&process.env.NODE_ENV!=="production"&&(we?.remove(),we=qe(z,W,h));}function ze(t,o){if(T){let a=o==="reverse"?1-t:t;e.style.clipPath=K(a);return}oe.forEach((a,d)=>{a.style.strokeDashoffset=o==="reverse"?`${O[d]*t}`:`${O[d]*(1-t)}`,c&&(a.style.opacity=o==="reverse"?`${1-t}`:`${t}`),I&&$?a.style.stroke=$e(I,$,t):$&&(a.style.stroke=$),S!==null&&A!==null?a.style.strokeWidth=`${S+(A-S)*t}`:A!==null&&(a.style.strokeWidth=`${A}`),k!==null&&D!==null?a.style.fillOpacity=`${k+(D-k)*t}`:D!==null&&(a.style.fillOpacity=`${D}`),u&&a.tagName.toLowerCase()==="path"&&N[d]&&a.setAttribute("d",Ce(N[d],u,t));});}function ke(){if(T){e.style.clipPath=K(0);return}oe.forEach((t,o)=>{t.style.strokeDasharray=`${O[o]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${O[o]}`,c?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),S!==null&&(t.style.strokeWidth=`${S}`),k!==null&&(t.style.fillOpacity=`${k}`),u&&t.tagName.toLowerCase()==="path"&&N[o]&&t.setAttribute("d",N[o]);});}if(oe.forEach(t=>{Ve(t);let o=Te(t);O.push(o),t.tagName.toLowerCase()==="path"?N.push(t.getAttribute("d")??""):N.push(""),n?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?`${o}`:"0",c&&(t.style.opacity="1"),$&&(t.style.stroke=$),A!==null&&(t.style.strokeWidth=`${A}`),D!==null&&(t.style.fillOpacity=`${D}`),u&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",u)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?"0":`${o}`,c?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),S!==null&&(t.style.strokeWidth=`${S}`),k!==null&&(t.style.fillOpacity=`${k}`));}),T){if(n)return e.style.clipPath=K(1),C?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=K(0);}else if(n)return C?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};Ae();function de(){if(!ae||X)return;let t=performance.now(),o=ve(),a=l;if(j!==false){let i=t-Se,p=i>0?Math.abs(o-(me<0?o:me))/i:0;a=l*Math.max(.2,1+p*(typeof j=="number"?j:1)*.04);}me=o,Se=t;let d=_?ce===-1||o>=ce?"forward":"reverse":y;ce=o;let ye=W-z,Q=true;if(T){let i=be(H(o,z,W,a));G&&!_&&(L=Math.max(L,i),i=L),ue=i;let p=d==="reverse"?1-i:i;e.style.clipPath=K(p),Y?.(i),!U&&H(o,z,W,a)>0&&(U=true,J?.()),i>=1&&!R?(R=true,C?.(),se<(F==="infinite"?1/0:F??0)&&(se++,fe=setTimeout(()=>{L=-1,U=false,R=false,e.style.clipPath=K(0);},B))):i<1&&!G&&(R=false),V=requestAnimationFrame(de);return}if(oe.forEach((i,p)=>{let q=p*g*ye,m=be(H(o,z+q,W+q,a));G&&!_&&(L=Math.max(L,m),m=L),ue=m,i.style.strokeDashoffset=d==="reverse"?`${O[p]*m}`:`${O[p]*(1-m)}`,c&&(i.style.opacity=d==="reverse"?`${1-m}`:`${m}`),I&&$?i.style.stroke=$e(I,$,m):$&&(i.style.stroke=$),S!==null&&A!==null?i.style.strokeWidth=`${S+(A-S)*m}`:A!==null&&(i.style.strokeWidth=`${A}`),k!==null&&D!==null?i.style.fillOpacity=`${k+(D-k)*m}`:D!==null&&(i.style.fillOpacity=`${D}`),u&&i.tagName.toLowerCase()==="path"&&N[p]&&i.setAttribute("d",Ce(N[p],u,m)),p===0&&Y?.(m),m<1&&(Q=false);}),ne){let i=be(H(o,z,W,a));for(let p in ne){let q=parseFloat(p);i>=q&&!pe.has(q)&&(pe.add(q),ne[p]?.());}}!U&&H(o,z,W,a)>0&&(U=true,J?.()),Q&&!R?(R=true,C?.(),se<(F==="infinite"?1/0:F??0)&&(se++,fe=setTimeout(()=>{L=-1,U=false,R=false,pe.clear(),ke();},B))):!Q&&!G&&(R=false),V=requestAnimationFrame(de);}let xe=new IntersectionObserver(t=>{t.forEach(o=>{ae=o.isIntersecting,ae&&!X?V=requestAnimationFrame(de):cancelAnimationFrame(V);});},{root:v??null,threshold:ie,rootMargin:le}),Ee;function ge(){clearTimeout(Ee),Ee=setTimeout(()=>{oe.forEach((t,o)=>{O[o]=Te(t),t.style.strokeDasharray=`${O[o]}`;}),Ae();},150);}return window.addEventListener("resize",ge),window.addEventListener("orientationchange",ge),re>0?setTimeout(()=>xe.observe(e),re):xe.observe(e),{destroy(){cancelAnimationFrame(V),clearTimeout(fe),xe.disconnect(),window.removeEventListener("resize",ge),window.removeEventListener("orientationchange",ge),clearTimeout(Ee),we?.remove();},replay(){L=-1,ce=-1,me=-1,U=false,R=false,se=0,X=false,pe.clear(),clearTimeout(fe),ke();},pause(){X=true,cancelAnimationFrame(V);},resume(){X&&(X=false,ae&&(V=requestAnimationFrame(de)));},seek(t){let o=Math.min(1,Math.max(0,t));ue=o,L=o,X=true,cancelAnimationFrame(V),ze(o,y);},getProgress(){return ue}}}function Be(e,r={}){let[n,s]=useState(0),l=useRef(r);l.current=r;let c=useRef(-1);return useEffect(()=>{if(typeof window>"u")return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){s(1);return}let f=typeof e=="string"?document.querySelector(e):e.current;if(!f)return;let x=f,{axis:g="y",scrollContainer:y,trigger:G={}}=l.current,P=typeof y=="string"?document.querySelector(y):y??null,h=ee(G.start??"top bottom"),te=ee(G.end??"bottom top"),_=0,re=0,E=false,b=0;function M(){return P?g==="x"?P.scrollLeft:P.scrollTop:g==="x"?window.scrollX:window.scrollY}function ne(){return P?g==="x"?P.clientWidth:P.clientHeight:g==="x"?window.innerWidth:window.innerHeight}function j(){let u=x.getBoundingClientRect(),w=M(),Y=g==="x"?u.left:u.top,J=g==="x"?u.width:u.height,C=he({top:Y,height:J},w,ne(),h,te);_=C.tStart,re=C.tEnd;}function ie(){if(!E)return;let{speed:u=1,easing:w="linear",once:Y=false}=l.current,J=typeof w=="function"?w:Z[w]??Z.linear,C=H(M(),_,re,u),T=J(C);Y&&(c.current=Math.max(c.current,T),T=c.current),s(T),b=requestAnimationFrame(ie);}let le=new IntersectionObserver(u=>{u.forEach(w=>{E=w.isIntersecting,E?b=requestAnimationFrame(ie):cancelAnimationFrame(b);});},{root:P??null,threshold:0});j(),le.observe(x);let F;function B(){clearTimeout(F),F=setTimeout(j,150);}return window.addEventListener("resize",B),window.addEventListener("orientationchange",B),()=>{cancelAnimationFrame(b),clearTimeout(F),le.disconnect(),window.removeEventListener("resize",B),window.removeEventListener("orientationchange",B);}},[]),n}function nt({children:e,className:r,style:n,...s}){let l=useRef(null);return useEffect(()=>{if(!l.current)return;let c=Oe(l.current,s);return ()=>c.destroy()},[]),jsx("div",{ref:l,className:r,style:n,children:e})}export{nt as ScrollDraw,Be as useScrollDrawProgress};
@@ -1,3 +1,3 @@
1
- 'use strict';var solidJs=require('solid-js');var re={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)};function ne(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function ye(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function he(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 oe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ne(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:Ne((e-r)/(n-r)*o,0,1)}function we(e,r,n,o,a){let c=ye(e.top,e.height,r,o.element)-he(o.viewport,n),u=ye(e.top,e.height,r,a.element)-he(a.viewport,n);return {tStart:c,tEnd:u}}function be(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function se(e,r,n){let o=be(e),a=be(r);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*n)},${Math.round(o[1]+(a[1]-o[1])*n)},${Math.round(o[2]+(a[2]-o[2])*n)})`}function ve(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Oe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?ve("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&ve("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Pe(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 a(){let c=n==="x"?window.scrollX:window.scrollY,u=e-c,E=r-c,P=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${P?`left:${u}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${u}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;${P?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",a,{passive:true}),a(),o}function xe(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),E=o[a++]??u;return String(+(u+(E-u)*n).toFixed(4))})}function ie(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:a=1,fade:c=false,easing:u="linear",trigger:E={},stagger:P=0,direction:k="forward",once:ae=false,debug:$e=false,axis:b="y",scrollContainer:X,autoReverse:le=false,delay:ce=0,strokeColor:D,strokeWidth:M,waypoints:_,velocityScale:j=false,threshold:Ae=0,rootMargin:Se="0px",repeat:ue=0,repeatDelay:Te=0,morphTo:$,onProgress:De,onStart:Me,onComplete:fe}=r,pe=typeof u=="function"?u:re[u]??re.linear,Ie=ne(E.start??"top bottom"),Le=ne(E.end??"bottom top"),p=typeof X=="string"?document.querySelector(X):X??null,v=Array.isArray(D)?D[0]:null,g=Array.isArray(D)?D[1]:typeof D=="string"?D:null,y=Array.isArray(M)?M[0]:null,h=Array.isArray(M)?M[1]:typeof M=="number"?M:null,N=Array.from(e.querySelectorAll(o)),w=[],x=[],I=0,L=0,O=false,W=false,A=0,R=false,C=-1,V=-1,S=false,J=0,K=0,Q,U=null,z=new Set,G=-1,me=performance.now();function Y(){return p?b==="x"?p.scrollLeft:p.scrollTop:b==="x"?window.scrollX:window.scrollY}function Ce(){return p?b==="x"?p.clientWidth:p.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function de(){let t=e.getBoundingClientRect(),s,i,m;if(p){let F=p.getBoundingClientRect();s=b==="x"?t.left-F.left+p.scrollLeft:t.top-F.top+p.scrollTop,i=b==="x"?t.width:t.height,m=Y();}else s=b==="x"?t.left:t.top,i=b==="x"?t.width:t.height,m=Y();let H=we({top:s,height:i},m,Ce(),Ie,Le);I=H.tStart,L=H.tEnd,$e&&process.env.NODE_ENV!=="production"&&(U?.remove(),U=Pe(I,L,b));}function Fe(t,s){N.forEach((i,m)=>{i.style.strokeDashoffset=s==="reverse"?`${w[m]*t}`:`${w[m]*(1-t)}`,c&&(i.style.opacity=s==="reverse"?`${1-t}`:`${t}`),v&&g?i.style.stroke=se(v,g,t):g&&(i.style.stroke=g),y!==null&&h!==null?i.style.strokeWidth=`${y+(h-y)*t}`:h!==null&&(i.style.strokeWidth=`${h}`),$&&i.tagName.toLowerCase()==="path"&&x[m]&&i.setAttribute("d",xe(x[m],$,t));});}function ge(){N.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=k==="reverse"?"0":`${w[s]}`,c?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`),$&&t.tagName.toLowerCase()==="path"&&x[s]&&t.setAttribute("d",x[s]);});}if(N.forEach(t=>{Oe(t);let s=oe(t);w.push(s),t.tagName.toLowerCase()==="path"?x.push(t.getAttribute("d")??""):x.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?`${s}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),h!==null&&(t.style.strokeWidth=`${h}`),$&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",$)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?"0":`${s}`,c?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`));}),n)return fe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};de();function Z(){if(!R||S)return;let t=performance.now(),s=Y(),i=a;if(j!==false){let l=t-me,d=l>0?Math.abs(s-(G<0?s:G))/l:0;i=a*Math.max(.2,1+d*(typeof j=="number"?j:1)*.04);}G=s,me=t;let m=le?V===-1||s>=V?"forward":"reverse":k;V=s;let H=L-I,F=true;if(N.forEach((l,d)=>{let T=d*P*H,f=pe(B(s,I+T,L+T,i));ae&&!le&&(C=Math.max(C,f),f=C),J=f,l.style.strokeDashoffset=m==="reverse"?`${w[d]*f}`:`${w[d]*(1-f)}`,c&&(l.style.opacity=m==="reverse"?`${1-f}`:`${f}`),v&&g?l.style.stroke=se(v,g,f):g&&(l.style.stroke=g),y!==null&&h!==null?l.style.strokeWidth=`${y+(h-y)*f}`:h!==null&&(l.style.strokeWidth=`${h}`),$&&l.tagName.toLowerCase()==="path"&&x[d]&&l.setAttribute("d",xe(x[d],$,f)),d===0&&De?.(f),f<1&&(F=false);}),_){let l=pe(B(s,I,L,i));for(let d in _){let T=parseFloat(d);l>=T&&!z.has(T)&&(z.add(T),_[d]?.());}}!W&&B(s,I,L,i)>0&&(W=true,Me?.()),F&&!O?(O=true,fe?.(),K<(ue==="infinite"?1/0:ue??0)&&(K++,Q=setTimeout(()=>{C=-1,W=false,O=false,z.clear(),ge();},Te))):!F&&!ae&&(O=false),A=requestAnimationFrame(Z);}let ee=new IntersectionObserver(t=>{t.forEach(s=>{R=s.isIntersecting,R&&!S?A=requestAnimationFrame(Z):cancelAnimationFrame(A);});},{root:p??null,threshold:Ae,rootMargin:Se}),te;function q(){clearTimeout(te),te=setTimeout(()=>{N.forEach((t,s)=>{w[s]=oe(t),t.style.strokeDasharray=`${w[s]}`;}),de();},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),ce>0?setTimeout(()=>ee.observe(e),ce):ee.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(Q),ee.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(te),U?.remove();},replay(){C=-1,V=-1,G=-1,W=false,O=false,K=0,S=false,z.clear(),clearTimeout(Q),ge();},pause(){S=true,cancelAnimationFrame(A);},resume(){S&&(S=false,R&&(A=requestAnimationFrame(Z)));},seek(t){let s=Math.min(1,Math.max(0,t));J=s,C=s,S=true,cancelAnimationFrame(A),Fe(s,k);},getProgress(){return J}}}function qe(e={}){let r,n;return solidJs.onMount(()=>{r&&(n=ie(r,e));}),solidJs.onCleanup(()=>{n?.destroy();}),o=>{r=o;}}function He(e={}){let r,n;return solidJs.onMount(()=>{r&&(n=ie(r,e));}),solidJs.onCleanup(()=>{n?.destroy(),n=void 0;}),{ref:o=>{r=o;},getInstance:()=>n}}exports.createScrollDraw=He;exports.useScrollDraw=qe;
1
+ 'use strict';var solidJs=require('solid-js');var me={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)};function de(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Te(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function ke(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 ye(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ve(e,r,n){return Math.min(n,Math.max(r,e))}function z(e,r,n,o){return n===r?0:Ve((e-r)/(n-r)*o,0,1)}function Me(e,r,n,o,a){let f=Te(e.top,e.height,r,o.element)-ke(o.viewport,n),p=Te(e.top,e.height,r,a.element)-ke(a.viewport,n);return {tStart:f,tEnd:p}}function Se(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function ge(e,r,n){let o=Se(e),a=Se(r);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*n)},${Math.round(o[1]+(a[1]-o[1])*n)},${Math.round(o[2]+(a[2]-o[2])*n)})`}function De(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function ze(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?De("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&De("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ge(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 a(){let f=n==="x"?window.scrollX:window.scrollY,p=e-f,L=r-f,B=n==="x";o.innerHTML=`
2
+ <div style="position:absolute;${B?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}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;${B?`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(o),window.addEventListener("scroll",a,{passive:true}),a(),o}function Le(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,f=>{let p=parseFloat(f),L=o[a++]??p;return String(+(p+(L-p)*n).toFixed(4))})}function he(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:a=1,fade:f=false,easing:p="linear",trigger:L={},stagger:B=0,direction:I="forward",once:X=false,debug:Ce=false,axis:x="y",scrollContainer:ne,autoReverse:se=false,delay:be=0,strokeColor:P,strokeWidth:N,fillOpacity:R,waypoints:oe,velocityScale:ie=false,threshold:Fe=0,rootMargin:Pe="0px",repeat:_=0,repeatDelay:we=0,morphTo:O,clip:le,onProgress:ve,onStart:xe,onComplete:j}=r,H=le===true?"left":typeof le=="string"?le:false,ae=typeof p=="function"?p:me[p]??me.linear,Ne=de(L.start??"top bottom"),Re=de(L.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,A=Array.isArray(P)?P[0]:null,y=Array.isArray(P)?P[1]:typeof P=="string"?P:null,g=Array.isArray(N)?N[0]:null,h=Array.isArray(N)?N[1]:typeof N=="number"?N:null,b=Array.isArray(R)?R[0]:null,w=Array.isArray(R)?R[1]:typeof R=="number"?R:null;function W(t){let s=t*100;switch(H){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let G=H?[]:Array.from(e.querySelectorAll(o)),E=[],T=[],k=0,S=0,$=false,C=false,M=0,J=false,v=-1,K=-1,F=false,Q=0,q=0,U,ue=null,Y=new Set,Z=-1,Ee=performance.now();function ce(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function He(){return d?x==="x"?d.clientWidth:d.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),s,l,m;if(d){let V=d.getBoundingClientRect();s=x==="x"?t.left-V.left+d.scrollLeft:t.top-V.top+d.scrollTop,l=x==="x"?t.width:t.height,m=ce();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,m=ce();let re=Me({top:s,height:l},m,He(),Ne,Re);k=re.tStart,S=re.tEnd,Ce&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=Ge(k,S,x));}function We(t,s){if(H){let l=s==="reverse"?1-t:t;e.style.clipPath=W(l);return}G.forEach((l,m)=>{l.style.strokeDashoffset=s==="reverse"?`${E[m]*t}`:`${E[m]*(1-t)}`,f&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),A&&y?l.style.stroke=ge(A,y,t):y&&(l.style.stroke=y),g!==null&&h!==null?l.style.strokeWidth=`${g+(h-g)*t}`:h!==null&&(l.style.strokeWidth=`${h}`),b!==null&&w!==null?l.style.fillOpacity=`${b+(w-b)*t}`:w!==null&&(l.style.fillOpacity=`${w}`),O&&l.tagName.toLowerCase()==="path"&&T[m]&&l.setAttribute("d",Le(T[m],O,t));});}function Ae(){if(H){e.style.clipPath=W(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${E[s]}`,t.style.strokeDashoffset=I==="reverse"?"0":`${E[s]}`,f?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",A&&(t.style.stroke=A),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`),O&&t.tagName.toLowerCase()==="path"&&T[s]&&t.setAttribute("d",T[s]);});}if(G.forEach(t=>{ze(t);let s=ye(t);E.push(s),t.tagName.toLowerCase()==="path"?T.push(t.getAttribute("d")??""):T.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?`${s}`:"0",f&&(t.style.opacity="1"),y&&(t.style.stroke=y),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?"0":`${s}`,f?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",A&&(t.style.stroke=A),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`));}),H){if(n)return e.style.clipPath=W(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(n)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||F)return;let t=performance.now(),s=ce(),l=a;if(ie!==false){let i=t-Ee,u=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+u*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let m=se?K===-1||s>=K?"forward":"reverse":I;K=s;let re=S-k,V=true;if(H){let i=ae(z(s,k,S,l));X&&!se&&(v=Math.max(v,i),i=v),Q=i;let u=m==="reverse"?1-i:i;e.style.clipPath=W(u),ve?.(i),!C&&z(s,k,S,l)>0&&(C=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,C=false,$=false,e.style.clipPath=W(0);},we))):i<1&&!X&&($=false),M=requestAnimationFrame(ee);return}if(G.forEach((i,u)=>{let D=u*B*re,c=ae(z(s,k+D,S+D,l));X&&!se&&(v=Math.max(v,c),c=v),Q=c,i.style.strokeDashoffset=m==="reverse"?`${E[u]*c}`:`${E[u]*(1-c)}`,f&&(i.style.opacity=m==="reverse"?`${1-c}`:`${c}`),A&&y?i.style.stroke=ge(A,y,c):y&&(i.style.stroke=y),g!==null&&h!==null?i.style.strokeWidth=`${g+(h-g)*c}`:h!==null&&(i.style.strokeWidth=`${h}`),b!==null&&w!==null?i.style.fillOpacity=`${b+(w-b)*c}`:w!==null&&(i.style.fillOpacity=`${w}`),O&&i.tagName.toLowerCase()==="path"&&T[u]&&i.setAttribute("d",Le(T[u],O,c)),u===0&&ve?.(c),c<1&&(V=false);}),oe){let i=ae(z(s,k,S,l));for(let u in oe){let D=parseFloat(u);i>=D&&!Y.has(D)&&(Y.add(D),oe[u]?.());}}!C&&z(s,k,S,l)>0&&(C=true,xe?.()),V&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,C=false,$=false,Y.clear(),Ae();},we))):!V&&!X&&($=false),M=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!F?M=requestAnimationFrame(ee):cancelAnimationFrame(M);});},{root:d??null,threshold:Fe,rootMargin:Pe}),pe;function te(){clearTimeout(pe),pe=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ye(t),t.style.strokeDasharray=`${E[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>fe.observe(e),be):fe.observe(e),{destroy(){cancelAnimationFrame(M),clearTimeout(U),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(pe),ue?.remove();},replay(){v=-1,K=-1,Z=-1,C=false,$=false,q=0,F=false,Y.clear(),clearTimeout(U),Ae();},pause(){F=true,cancelAnimationFrame(M);},resume(){F&&(F=false,J&&(M=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));Q=s,v=s,F=true,cancelAnimationFrame(M),We(s,I);},getProgress(){return Q}}}function Je(e={}){let r,n;return solidJs.onMount(()=>{r&&(n=he(r,e));}),solidJs.onCleanup(()=>{n?.destroy();}),o=>{r=o;}}function Ke(e={}){let r,n;return solidJs.onMount(()=>{r&&(n=he(r,e));}),solidJs.onCleanup(()=>{n?.destroy(),n=void 0;}),{ref:o=>{r=o;},getInstance:()=>n}}exports.createScrollDraw=Ke;exports.useScrollDraw=Je;
@@ -25,6 +25,14 @@ interface ScrollDrawOptions {
25
25
  strokeColor?: string | [string, string];
26
26
  /** Animate stroke width. Single number = static override. Tuple = interpolate from → to. */
27
27
  strokeWidth?: number | [number, number];
28
+ /** Animate fill opacity. Single number = static override. Tuple [from, to] = interpolate as the path draws. Use [0, 1] to flood fill in sync with the stroke draw. */
29
+ fillOpacity?: number | [number, number];
30
+ /**
31
+ * Reveal the container using CSS clip-path instead of stroke-dashoffset.
32
+ * Works on any content — SVG, images, text, divs.
33
+ * `true` defaults to `'left'`. Values: `'left' | 'right' | 'top' | 'bottom' | 'center'`.
34
+ */
35
+ clip?: boolean | 'left' | 'right' | 'top' | 'bottom' | 'center';
28
36
  /** Fire callbacks at specific progress thresholds (0–1). Resets on replay(). */
29
37
  waypoints?: Record<number, () => void>;
30
38
  /** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
@@ -25,6 +25,14 @@ interface ScrollDrawOptions {
25
25
  strokeColor?: string | [string, string];
26
26
  /** Animate stroke width. Single number = static override. Tuple = interpolate from → to. */
27
27
  strokeWidth?: number | [number, number];
28
+ /** Animate fill opacity. Single number = static override. Tuple [from, to] = interpolate as the path draws. Use [0, 1] to flood fill in sync with the stroke draw. */
29
+ fillOpacity?: number | [number, number];
30
+ /**
31
+ * Reveal the container using CSS clip-path instead of stroke-dashoffset.
32
+ * Works on any content — SVG, images, text, divs.
33
+ * `true` defaults to `'left'`. Values: `'left' | 'right' | 'top' | 'bottom' | 'center'`.
34
+ */
35
+ clip?: boolean | 'left' | 'right' | 'top' | 'bottom' | 'center';
28
36
  /** Fire callbacks at specific progress thresholds (0–1). Resets on replay(). */
29
37
  waypoints?: Record<number, () => void>;
30
38
  /** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
@@ -1,3 +1,3 @@
1
- import {onMount,onCleanup}from'solid-js';var re={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)};function ne(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function ye(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function he(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 oe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ne(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:Ne((e-r)/(n-r)*o,0,1)}function we(e,r,n,o,a){let c=ye(e.top,e.height,r,o.element)-he(o.viewport,n),u=ye(e.top,e.height,r,a.element)-he(a.viewport,n);return {tStart:c,tEnd:u}}function be(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function se(e,r,n){let o=be(e),a=be(r);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*n)},${Math.round(o[1]+(a[1]-o[1])*n)},${Math.round(o[2]+(a[2]-o[2])*n)})`}function ve(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Oe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?ve("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&ve("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Pe(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 a(){let c=n==="x"?window.scrollX:window.scrollY,u=e-c,E=r-c,P=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${P?`left:${u}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${u}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;${P?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",a,{passive:true}),a(),o}function xe(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),E=o[a++]??u;return String(+(u+(E-u)*n).toFixed(4))})}function ie(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:a=1,fade:c=false,easing:u="linear",trigger:E={},stagger:P=0,direction:k="forward",once:ae=false,debug:$e=false,axis:b="y",scrollContainer:X,autoReverse:le=false,delay:ce=0,strokeColor:D,strokeWidth:M,waypoints:_,velocityScale:j=false,threshold:Ae=0,rootMargin:Se="0px",repeat:ue=0,repeatDelay:Te=0,morphTo:$,onProgress:De,onStart:Me,onComplete:fe}=r,pe=typeof u=="function"?u:re[u]??re.linear,Ie=ne(E.start??"top bottom"),Le=ne(E.end??"bottom top"),p=typeof X=="string"?document.querySelector(X):X??null,v=Array.isArray(D)?D[0]:null,g=Array.isArray(D)?D[1]:typeof D=="string"?D:null,y=Array.isArray(M)?M[0]:null,h=Array.isArray(M)?M[1]:typeof M=="number"?M:null,N=Array.from(e.querySelectorAll(o)),w=[],x=[],I=0,L=0,O=false,W=false,A=0,R=false,C=-1,V=-1,S=false,J=0,K=0,Q,U=null,z=new Set,G=-1,me=performance.now();function Y(){return p?b==="x"?p.scrollLeft:p.scrollTop:b==="x"?window.scrollX:window.scrollY}function Ce(){return p?b==="x"?p.clientWidth:p.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function de(){let t=e.getBoundingClientRect(),s,i,m;if(p){let F=p.getBoundingClientRect();s=b==="x"?t.left-F.left+p.scrollLeft:t.top-F.top+p.scrollTop,i=b==="x"?t.width:t.height,m=Y();}else s=b==="x"?t.left:t.top,i=b==="x"?t.width:t.height,m=Y();let H=we({top:s,height:i},m,Ce(),Ie,Le);I=H.tStart,L=H.tEnd,$e&&process.env.NODE_ENV!=="production"&&(U?.remove(),U=Pe(I,L,b));}function Fe(t,s){N.forEach((i,m)=>{i.style.strokeDashoffset=s==="reverse"?`${w[m]*t}`:`${w[m]*(1-t)}`,c&&(i.style.opacity=s==="reverse"?`${1-t}`:`${t}`),v&&g?i.style.stroke=se(v,g,t):g&&(i.style.stroke=g),y!==null&&h!==null?i.style.strokeWidth=`${y+(h-y)*t}`:h!==null&&(i.style.strokeWidth=`${h}`),$&&i.tagName.toLowerCase()==="path"&&x[m]&&i.setAttribute("d",xe(x[m],$,t));});}function ge(){N.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=k==="reverse"?"0":`${w[s]}`,c?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`),$&&t.tagName.toLowerCase()==="path"&&x[s]&&t.setAttribute("d",x[s]);});}if(N.forEach(t=>{Oe(t);let s=oe(t);w.push(s),t.tagName.toLowerCase()==="path"?x.push(t.getAttribute("d")??""):x.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?`${s}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),h!==null&&(t.style.strokeWidth=`${h}`),$&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",$)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=k==="reverse"?"0":`${s}`,c?t.style.opacity=k==="reverse"?"1":"0":t.style.opacity="",v&&(t.style.stroke=v),y!==null&&(t.style.strokeWidth=`${y}`));}),n)return fe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};de();function Z(){if(!R||S)return;let t=performance.now(),s=Y(),i=a;if(j!==false){let l=t-me,d=l>0?Math.abs(s-(G<0?s:G))/l:0;i=a*Math.max(.2,1+d*(typeof j=="number"?j:1)*.04);}G=s,me=t;let m=le?V===-1||s>=V?"forward":"reverse":k;V=s;let H=L-I,F=true;if(N.forEach((l,d)=>{let T=d*P*H,f=pe(B(s,I+T,L+T,i));ae&&!le&&(C=Math.max(C,f),f=C),J=f,l.style.strokeDashoffset=m==="reverse"?`${w[d]*f}`:`${w[d]*(1-f)}`,c&&(l.style.opacity=m==="reverse"?`${1-f}`:`${f}`),v&&g?l.style.stroke=se(v,g,f):g&&(l.style.stroke=g),y!==null&&h!==null?l.style.strokeWidth=`${y+(h-y)*f}`:h!==null&&(l.style.strokeWidth=`${h}`),$&&l.tagName.toLowerCase()==="path"&&x[d]&&l.setAttribute("d",xe(x[d],$,f)),d===0&&De?.(f),f<1&&(F=false);}),_){let l=pe(B(s,I,L,i));for(let d in _){let T=parseFloat(d);l>=T&&!z.has(T)&&(z.add(T),_[d]?.());}}!W&&B(s,I,L,i)>0&&(W=true,Me?.()),F&&!O?(O=true,fe?.(),K<(ue==="infinite"?1/0:ue??0)&&(K++,Q=setTimeout(()=>{C=-1,W=false,O=false,z.clear(),ge();},Te))):!F&&!ae&&(O=false),A=requestAnimationFrame(Z);}let ee=new IntersectionObserver(t=>{t.forEach(s=>{R=s.isIntersecting,R&&!S?A=requestAnimationFrame(Z):cancelAnimationFrame(A);});},{root:p??null,threshold:Ae,rootMargin:Se}),te;function q(){clearTimeout(te),te=setTimeout(()=>{N.forEach((t,s)=>{w[s]=oe(t),t.style.strokeDasharray=`${w[s]}`;}),de();},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),ce>0?setTimeout(()=>ee.observe(e),ce):ee.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(Q),ee.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(te),U?.remove();},replay(){C=-1,V=-1,G=-1,W=false,O=false,K=0,S=false,z.clear(),clearTimeout(Q),ge();},pause(){S=true,cancelAnimationFrame(A);},resume(){S&&(S=false,R&&(A=requestAnimationFrame(Z)));},seek(t){let s=Math.min(1,Math.max(0,t));J=s,C=s,S=true,cancelAnimationFrame(A),Fe(s,k);},getProgress(){return J}}}function qe(e={}){let r,n;return onMount(()=>{r&&(n=ie(r,e));}),onCleanup(()=>{n?.destroy();}),o=>{r=o;}}function He(e={}){let r,n;return onMount(()=>{r&&(n=ie(r,e));}),onCleanup(()=>{n?.destroy(),n=void 0;}),{ref:o=>{r=o;},getInstance:()=>n}}export{He as createScrollDraw,qe as useScrollDraw};
1
+ import {onMount,onCleanup}from'solid-js';var me={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)};function de(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Te(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function ke(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 ye(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ve(e,r,n){return Math.min(n,Math.max(r,e))}function z(e,r,n,o){return n===r?0:Ve((e-r)/(n-r)*o,0,1)}function Me(e,r,n,o,a){let f=Te(e.top,e.height,r,o.element)-ke(o.viewport,n),p=Te(e.top,e.height,r,a.element)-ke(a.viewport,n);return {tStart:f,tEnd:p}}function Se(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function ge(e,r,n){let o=Se(e),a=Se(r);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*n)},${Math.round(o[1]+(a[1]-o[1])*n)},${Math.round(o[2]+(a[2]-o[2])*n)})`}function De(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function ze(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?De("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&De("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ge(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 a(){let f=n==="x"?window.scrollX:window.scrollY,p=e-f,L=r-f,B=n==="x";o.innerHTML=`
2
+ <div style="position:absolute;${B?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}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;${B?`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(o),window.addEventListener("scroll",a,{passive:true}),a(),o}function Le(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,f=>{let p=parseFloat(f),L=o[a++]??p;return String(+(p+(L-p)*n).toFixed(4))})}function he(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:a=1,fade:f=false,easing:p="linear",trigger:L={},stagger:B=0,direction:I="forward",once:X=false,debug:Ce=false,axis:x="y",scrollContainer:ne,autoReverse:se=false,delay:be=0,strokeColor:P,strokeWidth:N,fillOpacity:R,waypoints:oe,velocityScale:ie=false,threshold:Fe=0,rootMargin:Pe="0px",repeat:_=0,repeatDelay:we=0,morphTo:O,clip:le,onProgress:ve,onStart:xe,onComplete:j}=r,H=le===true?"left":typeof le=="string"?le:false,ae=typeof p=="function"?p:me[p]??me.linear,Ne=de(L.start??"top bottom"),Re=de(L.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,A=Array.isArray(P)?P[0]:null,y=Array.isArray(P)?P[1]:typeof P=="string"?P:null,g=Array.isArray(N)?N[0]:null,h=Array.isArray(N)?N[1]:typeof N=="number"?N:null,b=Array.isArray(R)?R[0]:null,w=Array.isArray(R)?R[1]:typeof R=="number"?R:null;function W(t){let s=t*100;switch(H){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let G=H?[]:Array.from(e.querySelectorAll(o)),E=[],T=[],k=0,S=0,$=false,C=false,M=0,J=false,v=-1,K=-1,F=false,Q=0,q=0,U,ue=null,Y=new Set,Z=-1,Ee=performance.now();function ce(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function He(){return d?x==="x"?d.clientWidth:d.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),s,l,m;if(d){let V=d.getBoundingClientRect();s=x==="x"?t.left-V.left+d.scrollLeft:t.top-V.top+d.scrollTop,l=x==="x"?t.width:t.height,m=ce();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,m=ce();let re=Me({top:s,height:l},m,He(),Ne,Re);k=re.tStart,S=re.tEnd,Ce&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=Ge(k,S,x));}function We(t,s){if(H){let l=s==="reverse"?1-t:t;e.style.clipPath=W(l);return}G.forEach((l,m)=>{l.style.strokeDashoffset=s==="reverse"?`${E[m]*t}`:`${E[m]*(1-t)}`,f&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),A&&y?l.style.stroke=ge(A,y,t):y&&(l.style.stroke=y),g!==null&&h!==null?l.style.strokeWidth=`${g+(h-g)*t}`:h!==null&&(l.style.strokeWidth=`${h}`),b!==null&&w!==null?l.style.fillOpacity=`${b+(w-b)*t}`:w!==null&&(l.style.fillOpacity=`${w}`),O&&l.tagName.toLowerCase()==="path"&&T[m]&&l.setAttribute("d",Le(T[m],O,t));});}function Ae(){if(H){e.style.clipPath=W(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${E[s]}`,t.style.strokeDashoffset=I==="reverse"?"0":`${E[s]}`,f?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",A&&(t.style.stroke=A),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`),O&&t.tagName.toLowerCase()==="path"&&T[s]&&t.setAttribute("d",T[s]);});}if(G.forEach(t=>{ze(t);let s=ye(t);E.push(s),t.tagName.toLowerCase()==="path"?T.push(t.getAttribute("d")??""):T.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?`${s}`:"0",f&&(t.style.opacity="1"),y&&(t.style.stroke=y),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?"0":`${s}`,f?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",A&&(t.style.stroke=A),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`));}),H){if(n)return e.style.clipPath=W(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(n)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||F)return;let t=performance.now(),s=ce(),l=a;if(ie!==false){let i=t-Ee,u=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+u*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let m=se?K===-1||s>=K?"forward":"reverse":I;K=s;let re=S-k,V=true;if(H){let i=ae(z(s,k,S,l));X&&!se&&(v=Math.max(v,i),i=v),Q=i;let u=m==="reverse"?1-i:i;e.style.clipPath=W(u),ve?.(i),!C&&z(s,k,S,l)>0&&(C=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,C=false,$=false,e.style.clipPath=W(0);},we))):i<1&&!X&&($=false),M=requestAnimationFrame(ee);return}if(G.forEach((i,u)=>{let D=u*B*re,c=ae(z(s,k+D,S+D,l));X&&!se&&(v=Math.max(v,c),c=v),Q=c,i.style.strokeDashoffset=m==="reverse"?`${E[u]*c}`:`${E[u]*(1-c)}`,f&&(i.style.opacity=m==="reverse"?`${1-c}`:`${c}`),A&&y?i.style.stroke=ge(A,y,c):y&&(i.style.stroke=y),g!==null&&h!==null?i.style.strokeWidth=`${g+(h-g)*c}`:h!==null&&(i.style.strokeWidth=`${h}`),b!==null&&w!==null?i.style.fillOpacity=`${b+(w-b)*c}`:w!==null&&(i.style.fillOpacity=`${w}`),O&&i.tagName.toLowerCase()==="path"&&T[u]&&i.setAttribute("d",Le(T[u],O,c)),u===0&&ve?.(c),c<1&&(V=false);}),oe){let i=ae(z(s,k,S,l));for(let u in oe){let D=parseFloat(u);i>=D&&!Y.has(D)&&(Y.add(D),oe[u]?.());}}!C&&z(s,k,S,l)>0&&(C=true,xe?.()),V&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,C=false,$=false,Y.clear(),Ae();},we))):!V&&!X&&($=false),M=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!F?M=requestAnimationFrame(ee):cancelAnimationFrame(M);});},{root:d??null,threshold:Fe,rootMargin:Pe}),pe;function te(){clearTimeout(pe),pe=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ye(t),t.style.strokeDasharray=`${E[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>fe.observe(e),be):fe.observe(e),{destroy(){cancelAnimationFrame(M),clearTimeout(U),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(pe),ue?.remove();},replay(){v=-1,K=-1,Z=-1,C=false,$=false,q=0,F=false,Y.clear(),clearTimeout(U),Ae();},pause(){F=true,cancelAnimationFrame(M);},resume(){F&&(F=false,J&&(M=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));Q=s,v=s,F=true,cancelAnimationFrame(M),We(s,I);},getProgress(){return Q}}}function Je(e={}){let r,n;return onMount(()=>{r&&(n=he(r,e));}),onCleanup(()=>{n?.destroy();}),o=>{r=o;}}function Ke(e={}){let r,n;return onMount(()=>{r&&(n=he(r,e));}),onCleanup(()=>{n?.destroy(),n=void 0;}),{ref:o=>{r=o;},getInstance:()=>n}}export{Ke as createScrollDraw,Je as useScrollDraw};