svg-scroll-draw 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- 'use strict';var de={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 ye(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 ge(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 We(e,r,n){return Math.min(n,Math.max(r,e))}function H(e,r,n,o){return n===r?0:We((e-r)/(n-r)*o,0,1)}function De(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 he(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 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 ze(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=`
1
+ 'use strict';var de={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 ye(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 Ae(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 Se(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 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 Re(e,r,n){return Math.min(n,Math.max(r,e))}function z(e,r,n,o){return n===r?0:Re((e-r)/(n-r)*o,0,1)}function Me(e,r,n,o,a){let f=Ae(e.top,e.height,r,o.element)-Se(o.viewport,n),p=Ae(e.top,e.height,r,a.element)-Se(a.viewport,n);return {tStart:f,tEnd:p}}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 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 he(e,r,n){let o=ke(e),a=ke(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 We(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 Ve(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
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 ne(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:Ie=false,axis:x="y",scrollContainer:se,autoReverse:oe=false,delay:be=0,strokeColor:C,strokeWidth:N,fillOpacity:R,waypoints:ie,velocityScale:le=false,threshold:Oe=0,rootMargin:Fe="0px",repeat:_=0,repeatDelay:we=0,morphTo:O,clip:ae,onProgress:ve,onStart:xe,onComplete:j}=r,W=ae===true?"left":typeof ae=="string"?ae:false,ce=typeof p=="function"?p:de[p]??de.linear,Pe=ye(L.start??"top bottom"),Ce=ye(L.end??"bottom top"),d=typeof se=="string"?document.querySelector(se):se??null,A=Array.isArray(C)?C[0]:null,y=Array.isArray(C)?C[1]:typeof C=="string"?C: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 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(o)),E=[],T=[],k=0,S=0,$=false,F=false,D=0,J=false,v=-1,K=-1,P=false,Q=0,q=0,U,ue=null,Y=new Set,Z=-1,Ee=performance.now();function fe(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function Ne(){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 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,m=fe();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,m=fe();let re=De({top:s,height:l},m,Ne(),Pe,Ce);k=re.tStart,S=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=ze(k,S,x));}function Re(t,s){if(W){let l=s==="reverse"?1-t:t;e.style.clipPath=V(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=he(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(W){e.style.clipPath=V(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=>{Ve(t);let s=ge(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}`));}),W){if(n)return e.style.clipPath=V(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=V(0);}else if(n)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||P)return;let t=performance.now(),s=fe(),l=a;if(le!==false){let i=t-Ee,c=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+c*(typeof le=="number"?le:1)*.04);}Z=s,Ee=t;let m=oe?K===-1||s>=K?"forward":"reverse":I;K=s;let re=S-k,z=true;if(W){let i=ce(H(s,k,S,l));X&&!oe&&(v=Math.max(v,i),i=v),Q=i;let c=m==="reverse"?1-i:i;e.style.clipPath=V(c),ve?.(i),!F&&H(s,k,S,l)>0&&(F=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,F=false,$=false,e.style.clipPath=V(0);},we))):i<1&&!X&&($=false),D=requestAnimationFrame(ee);return}if(G.forEach((i,c)=>{let M=c*B*re,u=ce(H(s,k+M,S+M,l));X&&!oe&&(v=Math.max(v,u),u=v),Q=u,i.style.strokeDashoffset=m==="reverse"?`${E[c]*u}`:`${E[c]*(1-u)}`,f&&(i.style.opacity=m==="reverse"?`${1-u}`:`${u}`),A&&y?i.style.stroke=he(A,y,u):y&&(i.style.stroke=y),g!==null&&h!==null?i.style.strokeWidth=`${g+(h-g)*u}`:h!==null&&(i.style.strokeWidth=`${h}`),b!==null&&w!==null?i.style.fillOpacity=`${b+(w-b)*u}`:w!==null&&(i.style.fillOpacity=`${w}`),O&&i.tagName.toLowerCase()==="path"&&T[c]&&i.setAttribute("d",Le(T[c],O,u)),c===0&&ve?.(u),u<1&&(z=false);}),ie){let i=ce(H(s,k,S,l));for(let c in ie){let M=parseFloat(c);i>=M&&!Y.has(M)&&(Y.add(M),ie[c]?.());}}!F&&H(s,k,S,l)>0&&(F=true,xe?.()),z&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,F=false,$=false,Y.clear(),Ae();},we))):!z&&!X&&($=false),D=requestAnimationFrame(ee);}let pe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!P?D=requestAnimationFrame(ee):cancelAnimationFrame(D);});},{root:d??null,threshold:Oe,rootMargin:Fe}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(t),t.style.strokeDasharray=`${E[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>pe.observe(e),be):pe.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(U),pe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,K=-1,Z=-1,F=false,$=false,q=0,P=false,Y.clear(),clearTimeout(U),Ae();},pause(){P=true,cancelAnimationFrame(D);},resume(){P&&(P=false,J&&(D=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));Q=s,v=s,P=true,cancelAnimationFrame(D),Re(s,I);},getProgress(){return Q}}}function Xe(e,r={}){let n=ne(e,r);return {update(o){n.destroy(),n=ne(e,o);},destroy(){n.destroy();}}}function _e(e={}){let r=null;function n(o){return r=ne(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}exports.createScrollDraw=_e;exports.scrollDraw=Xe;
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 ne(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:Ie=false,axis:x="y",scrollContainer:se,autoReverse:oe=false,delay:be=0,strokeColor:C,strokeWidth:N,fillOpacity:H,waypoints:ie,velocityScale:le=false,threshold:Pe=0,rootMargin:Oe="0px",repeat:_=0,repeatDelay:we=0,morphTo:P,clip:ae,onProgress:ve,onStart:xe,onComplete:j}=r,R=ae===true?"left":typeof ae=="string"?ae:false,ce=typeof p=="function"?p:de[p]??de.linear,Fe=ye(L.start??"top bottom"),Ce=ye(L.end??"bottom top"),d=typeof se=="string"?document.querySelector(se):se??null,T=Array.isArray(C)?C[0]:null,y=Array.isArray(C)?C[1]:typeof C=="string"?C:null,g=Array.isArray(N)?N[0]:null,h=Array.isArray(N)?N[1]:typeof N=="number"?N:null,b=Array.isArray(H)?H[0]:null,w=Array.isArray(H)?H[1]:typeof H=="number"?H:null;function W(t){let s=t*100;switch(R){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=R?[]:Array.from(e.querySelectorAll(o)),E=[],A=[],S=0,k=0,$=false,O=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 fe(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function Ne(){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=fe();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,m=fe();let re=Me({top:s,height:l},m,Ne(),Fe,Ce);S=re.tStart,k=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=Ve(S,k,x));}function He(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),R){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}`),T&&y?l.style.stroke=he(T,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}`),P&&l.tagName.toLowerCase()==="path"&&A[m]&&l.setAttribute("d",Le(A[m],P,t));});}function Te(){if(e.style.setProperty("--scroll-draw-progress","0"),R){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="",T&&(t.style.stroke=T),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`),P&&t.tagName.toLowerCase()==="path"&&A[s]&&t.setAttribute("d",A[s]);});}if(G.forEach(t=>{We(t);let s=ge(t);E.push(s),t.tagName.toLowerCase()==="path"?A.push(t.getAttribute("d")??""):A.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}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?"0":`${s}`,f?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",T&&(t.style.stroke=T),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`));}),R){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=fe(),l=a;if(le!==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 le=="number"?le:1)*.04);}Z=s,Ee=t;let m=oe?K===-1||s>=K?"forward":"reverse":I;K=s;let re=k-S,V=true;if(R){let i=ce(z(s,S,k,l));X&&!oe&&(v=Math.max(v,i),i=v),Q=i,e.style.setProperty("--scroll-draw-progress",String(i));let u=m==="reverse"?1-i:i;e.style.clipPath=W(u),ve?.(i),!O&&z(s,S,k,l)>0&&(O=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,O=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=ce(z(s,S+D,k+D,l));X&&!oe&&(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}`),T&&y?i.style.stroke=he(T,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}`),P&&i.tagName.toLowerCase()==="path"&&A[u]&&i.setAttribute("d",Le(A[u],P,c)),u===0&&(ve?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(V=false);}),ie){let i=ce(z(s,S,k,l));for(let u in ie){let D=parseFloat(u);i>=D&&!Y.has(D)&&(Y.add(D),ie[u]?.());}}!O&&z(s,S,k,l)>0&&(O=true,xe?.()),V&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,O=false,$=false,Y.clear(),Te();},we))):!V&&!X&&($=false),M=requestAnimationFrame(ee);}let pe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!F?M=requestAnimationFrame(ee):cancelAnimationFrame(M);});},{root:d??null,threshold:Pe,rootMargin:Oe}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(t),t.style.strokeDasharray=`${E[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>pe.observe(e),be):pe.observe(e),{destroy(){cancelAnimationFrame(M),clearTimeout(U),pe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,K=-1,Z=-1,O=false,$=false,q=0,F=false,Y.clear(),clearTimeout(U),Te();},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),He(s,I);},getProgress(){return Q}}}function Xe(e,r={}){let n=ne(e,r);return {update(o){n.destroy(),n=ne(e,o);},destroy(){n.destroy();}}}function _e(e={}){let r=null;function n(o){return r=ne(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}exports.createScrollDraw=_e;exports.scrollDraw=Xe;
@@ -1,3 +1,3 @@
1
- var de={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 ye(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 ge(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 We(e,r,n){return Math.min(n,Math.max(r,e))}function H(e,r,n,o){return n===r?0:We((e-r)/(n-r)*o,0,1)}function De(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 he(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 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 ze(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=`
1
+ var de={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 ye(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 Ae(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 Se(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 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 Re(e,r,n){return Math.min(n,Math.max(r,e))}function z(e,r,n,o){return n===r?0:Re((e-r)/(n-r)*o,0,1)}function Me(e,r,n,o,a){let f=Ae(e.top,e.height,r,o.element)-Se(o.viewport,n),p=Ae(e.top,e.height,r,a.element)-Se(a.viewport,n);return {tStart:f,tEnd:p}}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 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 he(e,r,n){let o=ke(e),a=ke(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 We(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 Ve(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
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 ne(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:Ie=false,axis:x="y",scrollContainer:se,autoReverse:oe=false,delay:be=0,strokeColor:C,strokeWidth:N,fillOpacity:R,waypoints:ie,velocityScale:le=false,threshold:Oe=0,rootMargin:Fe="0px",repeat:_=0,repeatDelay:we=0,morphTo:O,clip:ae,onProgress:ve,onStart:xe,onComplete:j}=r,W=ae===true?"left":typeof ae=="string"?ae:false,ce=typeof p=="function"?p:de[p]??de.linear,Pe=ye(L.start??"top bottom"),Ce=ye(L.end??"bottom top"),d=typeof se=="string"?document.querySelector(se):se??null,A=Array.isArray(C)?C[0]:null,y=Array.isArray(C)?C[1]:typeof C=="string"?C: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 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(o)),E=[],T=[],k=0,S=0,$=false,F=false,D=0,J=false,v=-1,K=-1,P=false,Q=0,q=0,U,ue=null,Y=new Set,Z=-1,Ee=performance.now();function fe(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function Ne(){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 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,m=fe();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,m=fe();let re=De({top:s,height:l},m,Ne(),Pe,Ce);k=re.tStart,S=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=ze(k,S,x));}function Re(t,s){if(W){let l=s==="reverse"?1-t:t;e.style.clipPath=V(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=he(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(W){e.style.clipPath=V(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=>{Ve(t);let s=ge(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}`));}),W){if(n)return e.style.clipPath=V(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=V(0);}else if(n)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||P)return;let t=performance.now(),s=fe(),l=a;if(le!==false){let i=t-Ee,c=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+c*(typeof le=="number"?le:1)*.04);}Z=s,Ee=t;let m=oe?K===-1||s>=K?"forward":"reverse":I;K=s;let re=S-k,z=true;if(W){let i=ce(H(s,k,S,l));X&&!oe&&(v=Math.max(v,i),i=v),Q=i;let c=m==="reverse"?1-i:i;e.style.clipPath=V(c),ve?.(i),!F&&H(s,k,S,l)>0&&(F=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,F=false,$=false,e.style.clipPath=V(0);},we))):i<1&&!X&&($=false),D=requestAnimationFrame(ee);return}if(G.forEach((i,c)=>{let M=c*B*re,u=ce(H(s,k+M,S+M,l));X&&!oe&&(v=Math.max(v,u),u=v),Q=u,i.style.strokeDashoffset=m==="reverse"?`${E[c]*u}`:`${E[c]*(1-u)}`,f&&(i.style.opacity=m==="reverse"?`${1-u}`:`${u}`),A&&y?i.style.stroke=he(A,y,u):y&&(i.style.stroke=y),g!==null&&h!==null?i.style.strokeWidth=`${g+(h-g)*u}`:h!==null&&(i.style.strokeWidth=`${h}`),b!==null&&w!==null?i.style.fillOpacity=`${b+(w-b)*u}`:w!==null&&(i.style.fillOpacity=`${w}`),O&&i.tagName.toLowerCase()==="path"&&T[c]&&i.setAttribute("d",Le(T[c],O,u)),c===0&&ve?.(u),u<1&&(z=false);}),ie){let i=ce(H(s,k,S,l));for(let c in ie){let M=parseFloat(c);i>=M&&!Y.has(M)&&(Y.add(M),ie[c]?.());}}!F&&H(s,k,S,l)>0&&(F=true,xe?.()),z&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,F=false,$=false,Y.clear(),Ae();},we))):!z&&!X&&($=false),D=requestAnimationFrame(ee);}let pe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!P?D=requestAnimationFrame(ee):cancelAnimationFrame(D);});},{root:d??null,threshold:Oe,rootMargin:Fe}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(t),t.style.strokeDasharray=`${E[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>pe.observe(e),be):pe.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(U),pe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,K=-1,Z=-1,F=false,$=false,q=0,P=false,Y.clear(),clearTimeout(U),Ae();},pause(){P=true,cancelAnimationFrame(D);},resume(){P&&(P=false,J&&(D=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));Q=s,v=s,P=true,cancelAnimationFrame(D),Re(s,I);},getProgress(){return Q}}}function Xe(e,r={}){let n=ne(e,r);return {update(o){n.destroy(),n=ne(e,o);},destroy(){n.destroy();}}}function _e(e={}){let r=null;function n(o){return r=ne(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}export{_e as createScrollDraw,Xe as scrollDraw};
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 ne(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:Ie=false,axis:x="y",scrollContainer:se,autoReverse:oe=false,delay:be=0,strokeColor:C,strokeWidth:N,fillOpacity:H,waypoints:ie,velocityScale:le=false,threshold:Pe=0,rootMargin:Oe="0px",repeat:_=0,repeatDelay:we=0,morphTo:P,clip:ae,onProgress:ve,onStart:xe,onComplete:j}=r,R=ae===true?"left":typeof ae=="string"?ae:false,ce=typeof p=="function"?p:de[p]??de.linear,Fe=ye(L.start??"top bottom"),Ce=ye(L.end??"bottom top"),d=typeof se=="string"?document.querySelector(se):se??null,T=Array.isArray(C)?C[0]:null,y=Array.isArray(C)?C[1]:typeof C=="string"?C:null,g=Array.isArray(N)?N[0]:null,h=Array.isArray(N)?N[1]:typeof N=="number"?N:null,b=Array.isArray(H)?H[0]:null,w=Array.isArray(H)?H[1]:typeof H=="number"?H:null;function W(t){let s=t*100;switch(R){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=R?[]:Array.from(e.querySelectorAll(o)),E=[],A=[],S=0,k=0,$=false,O=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 fe(){return d?x==="x"?d.scrollLeft:d.scrollTop:x==="x"?window.scrollX:window.scrollY}function Ne(){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=fe();}else s=x==="x"?t.left:t.top,l=x==="x"?t.width:t.height,m=fe();let re=Me({top:s,height:l},m,Ne(),Fe,Ce);S=re.tStart,k=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=Ve(S,k,x));}function He(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),R){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}`),T&&y?l.style.stroke=he(T,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}`),P&&l.tagName.toLowerCase()==="path"&&A[m]&&l.setAttribute("d",Le(A[m],P,t));});}function Te(){if(e.style.setProperty("--scroll-draw-progress","0"),R){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="",T&&(t.style.stroke=T),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`),P&&t.tagName.toLowerCase()==="path"&&A[s]&&t.setAttribute("d",A[s]);});}if(G.forEach(t=>{We(t);let s=ge(t);E.push(s),t.tagName.toLowerCase()==="path"?A.push(t.getAttribute("d")??""):A.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}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?"0":`${s}`,f?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",T&&(t.style.stroke=T),g!==null&&(t.style.strokeWidth=`${g}`),b!==null&&(t.style.fillOpacity=`${b}`));}),R){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=fe(),l=a;if(le!==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 le=="number"?le:1)*.04);}Z=s,Ee=t;let m=oe?K===-1||s>=K?"forward":"reverse":I;K=s;let re=k-S,V=true;if(R){let i=ce(z(s,S,k,l));X&&!oe&&(v=Math.max(v,i),i=v),Q=i,e.style.setProperty("--scroll-draw-progress",String(i));let u=m==="reverse"?1-i:i;e.style.clipPath=W(u),ve?.(i),!O&&z(s,S,k,l)>0&&(O=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,O=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=ce(z(s,S+D,k+D,l));X&&!oe&&(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}`),T&&y?i.style.stroke=he(T,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}`),P&&i.tagName.toLowerCase()==="path"&&A[u]&&i.setAttribute("d",Le(A[u],P,c)),u===0&&(ve?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(V=false);}),ie){let i=ce(z(s,S,k,l));for(let u in ie){let D=parseFloat(u);i>=D&&!Y.has(D)&&(Y.add(D),ie[u]?.());}}!O&&z(s,S,k,l)>0&&(O=true,xe?.()),V&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{v=-1,O=false,$=false,Y.clear(),Te();},we))):!V&&!X&&($=false),M=requestAnimationFrame(ee);}let pe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!F?M=requestAnimationFrame(ee):cancelAnimationFrame(M);});},{root:d??null,threshold:Pe,rootMargin:Oe}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(t),t.style.strokeDasharray=`${E[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>pe.observe(e),be):pe.observe(e),{destroy(){cancelAnimationFrame(M),clearTimeout(U),pe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,K=-1,Z=-1,O=false,$=false,q=0,F=false,Y.clear(),clearTimeout(U),Te();},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),He(s,I);},getProgress(){return Q}}}function Xe(e,r={}){let n=ne(e,r);return {update(o){n.destroy(),n=ne(e,o);},destroy(){n.destroy();}}}function _e(e={}){let r=null;function n(o){return r=ne(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}export{_e as createScrollDraw,Xe as scrollDraw};
@@ -0,0 +1 @@
1
+ 'use strict';var S={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 A(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 N(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 q(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 M(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 U(e,r,n){return Math.min(n,Math.max(r,e))}function R(e,r,n,s){return n===r?0:U((e-r)/(n-r)*s,0,1)}function O(e,r,n,s,c){let g=N(e.top,e.height,r,s.element)-q(s.viewport,n),x=N(e.top,e.height,r,c.element)-q(c.viewport,n);return {tStart:g,tEnd:x}}function H(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;if(!s)return console.warn("[svg-scroll-draw/timeline] Container not found:",e),n;let c=s,{trigger:g={},speed:x=1,once:v=false,axis:d="y",tracks:V,onComplete:B}=r,W=A(g.start??"top bottom"),X=A(g.end??"bottom top"),E=V.map(t=>{let i=typeof t.easing=="function"?t.easing:S[t.easing??"linear"]??S.linear,a=Array.from(c.querySelectorAll(t.selector)),o=a.map(u=>M(u));return a.forEach((u,y)=>{u.style.strokeDasharray=`${o[y]}`,u.style.strokeDashoffset=`${o[y]}`,t.fade&&(u.style.opacity="0");}),{...t,elements:a,lengths:o,easeFn:i}}),$=0,D=0,b=false,m=false,l=0,h=false,p=-1,f=0;function F(){return d==="x"?window.scrollX:window.scrollY}function j(){return d==="x"?window.innerWidth:window.innerHeight}function L(){let t=c.getBoundingClientRect(),i=F(),a=d==="x"?t.left:t.top,o=d==="x"?t.width:t.height,u=O({top:a,height:o},i,j(),W,X);$=u.tStart,D=u.tEnd;}function P(t){c.style.setProperty("--scroll-draw-progress",String(t)),E.forEach(({elements:i,lengths:a,from:o,to:u,easeFn:y,fade:J})=>{let z=u-o,K=z>0?Math.min(1,Math.max(0,(t-o)/z)):0,C=y(K);i.forEach((G,Q)=>{G.style.strokeDashoffset=`${a[Q]*(1-C)}`,J&&(G.style.opacity=String(C));});});}function T(){if(!b||m)return;let t=R(F(),$,D,x);v&&(p=Math.max(p,t),t=p),f=t,P(t),t>=1&&!h?(h=true,B?.()):t<1&&!v&&(h=false),l=requestAnimationFrame(T);}L();let k=new IntersectionObserver(t=>{t.forEach(i=>{b=i.isIntersecting,b&&!m?l=requestAnimationFrame(T):cancelAnimationFrame(l);});},{threshold:0});k.observe(c);let I;function w(){clearTimeout(I),I=setTimeout(()=>{E.forEach(({elements:t,lengths:i})=>{t.forEach((a,o)=>{i[o]=M(a),a.style.strokeDasharray=`${i[o]}`;});}),L();},150);}return window.addEventListener("resize",w),window.addEventListener("orientationchange",w),{destroy(){cancelAnimationFrame(l),clearTimeout(I),k.disconnect(),window.removeEventListener("resize",w),window.removeEventListener("orientationchange",w);},replay(){p=-1,h=false,m=false,E.forEach(({elements:t,lengths:i,fade:a})=>{t.forEach((o,u)=>{o.style.strokeDashoffset=`${i[u]}`,a&&(o.style.opacity="0");});}),c.style.setProperty("--scroll-draw-progress","0");},pause(){m=true,cancelAnimationFrame(l);},resume(){m&&(m=false,b&&(l=requestAnimationFrame(T)));},seek(t){f=Math.min(1,Math.max(0,t)),p=f,m=true,cancelAnimationFrame(l),P(f);},getProgress(){return f}}}exports.scrollDrawTimeline=H;
@@ -0,0 +1,64 @@
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
2
+ interface ScrollDrawInstance {
3
+ destroy: () => void;
4
+ /** Reset and replay the animation from the beginning. */
5
+ replay: () => void;
6
+ /** Pause the animation at the current progress. */
7
+ pause: () => void;
8
+ /** Resume a paused animation. */
9
+ resume: () => void;
10
+ /** Jump to a specific progress value (0–1) and pause. */
11
+ seek: (progress: number) => void;
12
+ /** Returns current draw progress (0–1). */
13
+ getProgress: () => number;
14
+ }
15
+
16
+ interface TimelineTrack {
17
+ /** CSS selector for paths within the container to animate on this track. */
18
+ selector: string;
19
+ /** Progress value (0–1) within the overall scroll range where this track starts. */
20
+ from: number;
21
+ /** Progress value (0–1) within the overall scroll range where this track ends. */
22
+ to: number;
23
+ /** Easing for this track. Defaults to 'linear'. */
24
+ easing?: EasingName | ((t: number) => number);
25
+ /** Fade opacity in sync with this track's draw progress. */
26
+ fade?: boolean;
27
+ }
28
+ interface ScrollDrawTimelineOptions {
29
+ /** Scroll trigger window. Same syntax as scrollDraw(). */
30
+ trigger?: {
31
+ start?: string;
32
+ end?: string;
33
+ };
34
+ /** Overall speed multiplier. Default 1. */
35
+ speed?: number;
36
+ /** Lock at max progress once reached. Default false. */
37
+ once?: boolean;
38
+ /** Scroll axis. Default 'y'. */
39
+ axis?: 'x' | 'y';
40
+ /** Per-path animation tracks — each with independent start/end within the scroll range. */
41
+ tracks: TimelineTrack[];
42
+ /** Fires when all tracks have reached their full draw progress. */
43
+ onComplete?: () => void;
44
+ }
45
+ /**
46
+ * Animate multiple path groups with independent start/end windows within a
47
+ * single scroll range. Unlike `stagger` (which offsets by time), each track
48
+ * defines its own `from`/`to` slice of the 0–1 progress range.
49
+ *
50
+ * @example
51
+ * import { scrollDrawTimeline } from 'svg-scroll-draw/timeline';
52
+ *
53
+ * scrollDrawTimeline('#diagram', {
54
+ * trigger: { start: 'top 80%', end: 'bottom 20%' },
55
+ * tracks: [
56
+ * { selector: '.outline', from: 0, to: 0.5, easing: 'ease-out' },
57
+ * { selector: '.detail', from: 0.3, to: 0.8, easing: 'ease-in' },
58
+ * { selector: '.label', from: 0.7, to: 1.0, easing: 'spring' },
59
+ * ],
60
+ * });
61
+ */
62
+ declare function scrollDrawTimeline(target: string | Element, options: ScrollDrawTimelineOptions): ScrollDrawInstance;
63
+
64
+ export { type ScrollDrawTimelineOptions, type TimelineTrack, scrollDrawTimeline };
@@ -0,0 +1,64 @@
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
2
+ interface ScrollDrawInstance {
3
+ destroy: () => void;
4
+ /** Reset and replay the animation from the beginning. */
5
+ replay: () => void;
6
+ /** Pause the animation at the current progress. */
7
+ pause: () => void;
8
+ /** Resume a paused animation. */
9
+ resume: () => void;
10
+ /** Jump to a specific progress value (0–1) and pause. */
11
+ seek: (progress: number) => void;
12
+ /** Returns current draw progress (0–1). */
13
+ getProgress: () => number;
14
+ }
15
+
16
+ interface TimelineTrack {
17
+ /** CSS selector for paths within the container to animate on this track. */
18
+ selector: string;
19
+ /** Progress value (0–1) within the overall scroll range where this track starts. */
20
+ from: number;
21
+ /** Progress value (0–1) within the overall scroll range where this track ends. */
22
+ to: number;
23
+ /** Easing for this track. Defaults to 'linear'. */
24
+ easing?: EasingName | ((t: number) => number);
25
+ /** Fade opacity in sync with this track's draw progress. */
26
+ fade?: boolean;
27
+ }
28
+ interface ScrollDrawTimelineOptions {
29
+ /** Scroll trigger window. Same syntax as scrollDraw(). */
30
+ trigger?: {
31
+ start?: string;
32
+ end?: string;
33
+ };
34
+ /** Overall speed multiplier. Default 1. */
35
+ speed?: number;
36
+ /** Lock at max progress once reached. Default false. */
37
+ once?: boolean;
38
+ /** Scroll axis. Default 'y'. */
39
+ axis?: 'x' | 'y';
40
+ /** Per-path animation tracks — each with independent start/end within the scroll range. */
41
+ tracks: TimelineTrack[];
42
+ /** Fires when all tracks have reached their full draw progress. */
43
+ onComplete?: () => void;
44
+ }
45
+ /**
46
+ * Animate multiple path groups with independent start/end windows within a
47
+ * single scroll range. Unlike `stagger` (which offsets by time), each track
48
+ * defines its own `from`/`to` slice of the 0–1 progress range.
49
+ *
50
+ * @example
51
+ * import { scrollDrawTimeline } from 'svg-scroll-draw/timeline';
52
+ *
53
+ * scrollDrawTimeline('#diagram', {
54
+ * trigger: { start: 'top 80%', end: 'bottom 20%' },
55
+ * tracks: [
56
+ * { selector: '.outline', from: 0, to: 0.5, easing: 'ease-out' },
57
+ * { selector: '.detail', from: 0.3, to: 0.8, easing: 'ease-in' },
58
+ * { selector: '.label', from: 0.7, to: 1.0, easing: 'spring' },
59
+ * ],
60
+ * });
61
+ */
62
+ declare function scrollDrawTimeline(target: string | Element, options: ScrollDrawTimelineOptions): ScrollDrawInstance;
63
+
64
+ export { type ScrollDrawTimelineOptions, type TimelineTrack, scrollDrawTimeline };
@@ -0,0 +1 @@
1
+ var S={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 A(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 N(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 q(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 M(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 U(e,r,n){return Math.min(n,Math.max(r,e))}function R(e,r,n,s){return n===r?0:U((e-r)/(n-r)*s,0,1)}function O(e,r,n,s,c){let g=N(e.top,e.height,r,s.element)-q(s.viewport,n),x=N(e.top,e.height,r,c.element)-q(c.viewport,n);return {tStart:g,tEnd:x}}function H(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;if(!s)return console.warn("[svg-scroll-draw/timeline] Container not found:",e),n;let c=s,{trigger:g={},speed:x=1,once:v=false,axis:d="y",tracks:V,onComplete:B}=r,W=A(g.start??"top bottom"),X=A(g.end??"bottom top"),E=V.map(t=>{let i=typeof t.easing=="function"?t.easing:S[t.easing??"linear"]??S.linear,a=Array.from(c.querySelectorAll(t.selector)),o=a.map(u=>M(u));return a.forEach((u,y)=>{u.style.strokeDasharray=`${o[y]}`,u.style.strokeDashoffset=`${o[y]}`,t.fade&&(u.style.opacity="0");}),{...t,elements:a,lengths:o,easeFn:i}}),$=0,D=0,b=false,m=false,l=0,h=false,p=-1,f=0;function F(){return d==="x"?window.scrollX:window.scrollY}function j(){return d==="x"?window.innerWidth:window.innerHeight}function L(){let t=c.getBoundingClientRect(),i=F(),a=d==="x"?t.left:t.top,o=d==="x"?t.width:t.height,u=O({top:a,height:o},i,j(),W,X);$=u.tStart,D=u.tEnd;}function P(t){c.style.setProperty("--scroll-draw-progress",String(t)),E.forEach(({elements:i,lengths:a,from:o,to:u,easeFn:y,fade:J})=>{let z=u-o,K=z>0?Math.min(1,Math.max(0,(t-o)/z)):0,C=y(K);i.forEach((G,Q)=>{G.style.strokeDashoffset=`${a[Q]*(1-C)}`,J&&(G.style.opacity=String(C));});});}function T(){if(!b||m)return;let t=R(F(),$,D,x);v&&(p=Math.max(p,t),t=p),f=t,P(t),t>=1&&!h?(h=true,B?.()):t<1&&!v&&(h=false),l=requestAnimationFrame(T);}L();let k=new IntersectionObserver(t=>{t.forEach(i=>{b=i.isIntersecting,b&&!m?l=requestAnimationFrame(T):cancelAnimationFrame(l);});},{threshold:0});k.observe(c);let I;function w(){clearTimeout(I),I=setTimeout(()=>{E.forEach(({elements:t,lengths:i})=>{t.forEach((a,o)=>{i[o]=M(a),a.style.strokeDasharray=`${i[o]}`;});}),L();},150);}return window.addEventListener("resize",w),window.addEventListener("orientationchange",w),{destroy(){cancelAnimationFrame(l),clearTimeout(I),k.disconnect(),window.removeEventListener("resize",w),window.removeEventListener("orientationchange",w);},replay(){p=-1,h=false,m=false,E.forEach(({elements:t,lengths:i,fade:a})=>{t.forEach((o,u)=>{o.style.strokeDashoffset=`${i[u]}`,a&&(o.style.opacity="0");});}),c.style.setProperty("--scroll-draw-progress","0");},pause(){m=true,cancelAnimationFrame(l);},resume(){m&&(m=false,b&&(l=requestAnimationFrame(T)));},seek(t){f=Math.min(1,Math.max(0,t)),p=f,m=true,cancelAnimationFrame(l),P(f);},getProgress(){return f}}}export{H as scrollDrawTimeline};
@@ -1,3 +1,3 @@
1
- 'use strict';var vue=require('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 Ae(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 He(e,r,o){return Math.min(o,Math.max(r,e))}function H(e,r,o,n){return o===r?0:He((e-r)/(o-r)*n,0,1)}function De(e,r,o,n,a){let f=Ae(e.top,e.height,r,n.element)-Te(n.viewport,o),m=Ae(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 Me(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Ge(e){let r=e.getAttribute("stroke"),o=e.getAttribute("fill");!r||r==="none"?Me("Element has no stroke \u2014 path will not be visible.",e):o&&o!=="none"&&o!=="transparent"&&Me("Element has a fill \u2014 it may obscure the stroke animation.",e);}function qe(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,L=r-f,B=o==="x";n.innerHTML=`
1
+ 'use strict';var vue=require('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 Te(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 Ae(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 ze(e,r,o){return Math.min(o,Math.max(r,e))}function z(e,r,o,n){return o===r?0:ze((e-r)/(o-r)*n,0,1)}function Me(e,r,o,n,a){let f=Te(e.top,e.height,r,n.element)-Ae(n.viewport,o),m=Te(e.top,e.height,r,a.element)-Ae(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 De(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Ge(e){let r=e.getAttribute("stroke"),o=e.getAttribute("fill");!r||r==="none"?De("Element has no stroke \u2014 path will not be visible.",e):o&&o!=="none"&&o!=="transparent"&&De("Element has a fill \u2014 it may obscure the stroke animation.",e);}function qe(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,L=r-f,B=o==="x";n.innerHTML=`
2
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:${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(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),L=n[a++]??m;return String(+(m+(L-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:L={},stagger:B=0,direction:O="forward",once:X=false,debug:Fe=false,axis:x="y",scrollContainer:ne,autoReverse:oe=false,delay:be=0,strokeColor:I,strokeWidth:N,fillOpacity:R,waypoints:se,velocityScale:ie=false,threshold:Ie=0,rootMargin:Ne="0px",repeat:_=0,repeatDelay:we=0,morphTo:C,clip:le,onProgress:ve,onStart:xe,onComplete:j}=r,W=le===true?"left":typeof le=="string"?le:false,ae=typeof m=="function"?m:pe[m]??pe.linear,Re=de(L.start??"top bottom"),We=de(L.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,S=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)),E=[],A=[],T=0,k=0,$=false,P=false,D=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 Ve(){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=De({top:s,height:l},p,Ve(),Re,We);T=re.tStart,k=re.tEnd,Fe&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=qe(T,k,x));}function ze(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"?`${E[p]*t}`:`${E[p]*(1-t)}`,f&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),S&&g?l.style.stroke=ye(S,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}`),C&&l.tagName.toLowerCase()==="path"&&A[p]&&l.setAttribute("d",Le(A[p],C,t));});}function Se(){if(W){e.style.clipPath=V(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${E[s]}`,t.style.strokeDashoffset=O==="reverse"?"0":`${E[s]}`,f?t.style.opacity=O==="reverse"?"1":"0":t.style.opacity="",S&&(t.style.stroke=S),y!==null&&(t.style.strokeWidth=`${y}`),b!==null&&(t.style.fillOpacity=`${b}`),C&&t.tagName.toLowerCase()==="path"&&A[s]&&t.setAttribute("d",A[s]);});}if(G.forEach(t=>{Ge(t);let s=ge(t);E.push(s),t.tagName.toLowerCase()==="path"?A.push(t.getAttribute("d")??""):A.push(""),o?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=O==="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}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=O==="reverse"?"0":`${s}`,f?t.style.opacity=O==="reverse"?"1":"0":t.style.opacity="",S&&(t.style.stroke=S),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":O;J=s;let re=k-T,z=true;if(W){let i=ae(H(s,T,k,l));X&&!oe&&(v=Math.max(v,i),i=v),K=i;let u=p==="reverse"?1-i:i;e.style.clipPath=V(u),ve?.(i),!P&&H(s,T,k,l)>0&&(P=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,P=false,$=false,e.style.clipPath=V(0);},we))):i<1&&!X&&($=false),D=requestAnimationFrame(ee);return}if(G.forEach((i,u)=>{let M=u*B*re,c=ae(H(s,T+M,k+M,l));X&&!oe&&(v=Math.max(v,c),c=v),K=c,i.style.strokeDashoffset=p==="reverse"?`${E[u]*c}`:`${E[u]*(1-c)}`,f&&(i.style.opacity=p==="reverse"?`${1-c}`:`${c}`),S&&g?i.style.stroke=ye(S,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}`),C&&i.tagName.toLowerCase()==="path"&&A[u]&&i.setAttribute("d",Le(A[u],C,c)),u===0&&ve?.(c),c<1&&(z=false);}),se){let i=ae(H(s,T,k,l));for(let u in se){let M=parseFloat(u);i>=M&&!Y.has(M)&&(Y.add(M),se[u]?.());}}!P&&H(s,T,k,l)>0&&(P=true,xe?.()),z&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,P=false,$=false,Y.clear(),Se();},we))):!z&&!X&&($=false),D=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{U=s.isIntersecting,U&&!F?D=requestAnimationFrame(ee):cancelAnimationFrame(D);});},{root:d??null,threshold:Ie,rootMargin:Ne}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(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(D),clearTimeout(Q),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,J=-1,Z=-1,P=false,$=false,q=0,F=false,Y.clear(),clearTimeout(Q),Se();},pause(){F=true,cancelAnimationFrame(D);},resume(){F&&(F=false,U&&(D=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,v=s,F=true,cancelAnimationFrame(D),ze(s,O);},getProgress(){return K}}}function Qe(e={}){let r=vue.ref(null);return vue.onMounted(()=>{if(!r.value)return;let o=he(r.value,e);vue.onUnmounted(()=>o.destroy());}),r}var Ye=vue.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=vue.ref(null);return vue.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);vue.onUnmounted(()=>a.destroy());}),()=>vue.h("div",{ref:o},r.default?.())}});exports.ScrollDraw=Ye;exports.useScrollDraw=Qe;
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(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),L=n[a++]??m;return String(+(m+(L-m)*o).toFixed(4))})}function be(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:L={},stagger:B=0,direction:P="forward",once:X=false,debug:Fe=false,axis:x="y",scrollContainer:ne,autoReverse:oe=false,delay:he=0,strokeColor:I,strokeWidth:N,fillOpacity:R,waypoints:se,velocityScale:ie=false,threshold:Ie=0,rootMargin:Ne="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 m=="function"?m:pe[m]??pe.linear,Re=de(L.start??"top bottom"),He=de(L.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,b=Array.isArray(N)?N[1]:typeof N=="number"?N:null,h=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(n)),E=[],T=[],A=0,k=0,S=false,C=false,M=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 We(){return d?x==="x"?d.clientWidth:d.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function Se(){let t=e.getBoundingClientRect(),s,l,p;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,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,We(),Re,He);A=re.tStart,k=re.tEnd,Fe&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=qe(A,k,x));}function Ve(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),H){let l=s==="reverse"?1-t:t;e.style.clipPath=W(l);return}G.forEach((l,p)=>{l.style.strokeDashoffset=s==="reverse"?`${E[p]*t}`:`${E[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&&b!==null?l.style.strokeWidth=`${y+(b-y)*t}`:b!==null&&(l.style.strokeWidth=`${b}`),h!==null&&w!==null?l.style.fillOpacity=`${h+(w-h)*t}`:w!==null&&(l.style.fillOpacity=`${w}`),O&&l.tagName.toLowerCase()==="path"&&T[p]&&l.setAttribute("d",Le(T[p],O,t));});}function $e(){if(e.style.setProperty("--scroll-draw-progress","0"),H){e.style.clipPath=W(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${E[s]}`,t.style.strokeDashoffset=P==="reverse"?"0":`${E[s]}`,f?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",$&&(t.style.stroke=$),y!==null&&(t.style.strokeWidth=`${y}`),h!==null&&(t.style.fillOpacity=`${h}`),O&&t.tagName.toLowerCase()==="path"&&T[s]&&t.setAttribute("d",T[s]);});}if(G.forEach(t=>{Ge(t);let s=ge(t);E.push(s),t.tagName.toLowerCase()==="path"?T.push(t.getAttribute("d")??""):T.push(""),o?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=P==="reverse"?`${s}`:"0",f&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),w!==null&&(t.style.fillOpacity=`${w}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=P==="reverse"?"0":`${s}`,f?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",$&&(t.style.stroke=$),y!==null&&(t.style.strokeWidth=`${y}`),h!==null&&(t.style.fillOpacity=`${h}`));}),H){if(o)return e.style.clipPath=W(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(o)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};Se();function ee(){if(!U||F)return;let t=performance.now(),s=ce(),l=a;if(ie!==false){let i=t-Ee,c=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+c*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let p=oe?J===-1||s>=J?"forward":"reverse":P;J=s;let re=k-A,V=true;if(H){let i=ae(z(s,A,k,l));X&&!oe&&(v=Math.max(v,i),i=v),K=i,e.style.setProperty("--scroll-draw-progress",String(i));let c=p==="reverse"?1-i:i;e.style.clipPath=W(c),ve?.(i),!C&&z(s,A,k,l)>0&&(C=true,xe?.()),i>=1&&!S?(S=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,C=false,S=false,e.style.clipPath=W(0);},we))):i<1&&!X&&(S=false),M=requestAnimationFrame(ee);return}if(G.forEach((i,c)=>{let D=c*B*re,u=ae(z(s,A+D,k+D,l));X&&!oe&&(v=Math.max(v,u),u=v),K=u,i.style.strokeDashoffset=p==="reverse"?`${E[c]*u}`:`${E[c]*(1-u)}`,f&&(i.style.opacity=p==="reverse"?`${1-u}`:`${u}`),$&&g?i.style.stroke=ye($,g,u):g&&(i.style.stroke=g),y!==null&&b!==null?i.style.strokeWidth=`${y+(b-y)*u}`:b!==null&&(i.style.strokeWidth=`${b}`),h!==null&&w!==null?i.style.fillOpacity=`${h+(w-h)*u}`:w!==null&&(i.style.fillOpacity=`${w}`),O&&i.tagName.toLowerCase()==="path"&&T[c]&&i.setAttribute("d",Le(T[c],O,u)),c===0&&(ve?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(V=false);}),se){let i=ae(z(s,A,k,l));for(let c in se){let D=parseFloat(c);i>=D&&!Y.has(D)&&(Y.add(D),se[c]?.());}}!C&&z(s,A,k,l)>0&&(C=true,xe?.()),V&&!S?(S=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,C=false,S=false,Y.clear(),$e();},we))):!V&&!X&&(S=false),M=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{U=s.isIntersecting,U&&!F?M=requestAnimationFrame(ee):cancelAnimationFrame(M);});},{root:d??null,threshold:Ie,rootMargin:Ne}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(t),t.style.strokeDasharray=`${E[s]}`;}),Se();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),he>0?setTimeout(()=>fe.observe(e),he):fe.observe(e),{destroy(){cancelAnimationFrame(M),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,S=false,q=0,F=false,Y.clear(),clearTimeout(Q),$e();},pause(){F=true,cancelAnimationFrame(M);},resume(){F&&(F=false,U&&(M=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,v=s,F=true,cancelAnimationFrame(M),Ve(s,P);},getProgress(){return K}}}function Qe(e={}){let r=vue.ref(null);return vue.onMounted(()=>{if(!r.value)return;let o=be(r.value,e);vue.onUnmounted(()=>o.destroy());}),r}var Ye=vue.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=vue.ref(null);return vue.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=be(o.value,n);vue.onUnmounted(()=>a.destroy());}),()=>vue.h("div",{ref:o},r.default?.())}});exports.ScrollDraw=Ye;exports.useScrollDraw=Qe;
@@ -1,3 +1,3 @@
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 Ae(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 He(e,r,o){return Math.min(o,Math.max(r,e))}function H(e,r,o,n){return o===r?0:He((e-r)/(o-r)*n,0,1)}function De(e,r,o,n,a){let f=Ae(e.top,e.height,r,n.element)-Te(n.viewport,o),m=Ae(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 Me(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Ge(e){let r=e.getAttribute("stroke"),o=e.getAttribute("fill");!r||r==="none"?Me("Element has no stroke \u2014 path will not be visible.",e):o&&o!=="none"&&o!=="transparent"&&Me("Element has a fill \u2014 it may obscure the stroke animation.",e);}function qe(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,L=r-f,B=o==="x";n.innerHTML=`
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 Te(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 Ae(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 ze(e,r,o){return Math.min(o,Math.max(r,e))}function z(e,r,o,n){return o===r?0:ze((e-r)/(o-r)*n,0,1)}function Me(e,r,o,n,a){let f=Te(e.top,e.height,r,n.element)-Ae(n.viewport,o),m=Te(e.top,e.height,r,a.element)-Ae(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 De(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}function Ge(e){let r=e.getAttribute("stroke"),o=e.getAttribute("fill");!r||r==="none"?De("Element has no stroke \u2014 path will not be visible.",e):o&&o!=="none"&&o!=="transparent"&&De("Element has a fill \u2014 it may obscure the stroke animation.",e);}function qe(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,L=r-f,B=o==="x";n.innerHTML=`
2
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:${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(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),L=n[a++]??m;return String(+(m+(L-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:L={},stagger:B=0,direction:O="forward",once:X=false,debug:Fe=false,axis:x="y",scrollContainer:ne,autoReverse:oe=false,delay:be=0,strokeColor:I,strokeWidth:N,fillOpacity:R,waypoints:se,velocityScale:ie=false,threshold:Ie=0,rootMargin:Ne="0px",repeat:_=0,repeatDelay:we=0,morphTo:C,clip:le,onProgress:ve,onStart:xe,onComplete:j}=r,W=le===true?"left":typeof le=="string"?le:false,ae=typeof m=="function"?m:pe[m]??pe.linear,Re=de(L.start??"top bottom"),We=de(L.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,S=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)),E=[],A=[],T=0,k=0,$=false,P=false,D=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 Ve(){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=De({top:s,height:l},p,Ve(),Re,We);T=re.tStart,k=re.tEnd,Fe&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=qe(T,k,x));}function ze(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"?`${E[p]*t}`:`${E[p]*(1-t)}`,f&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),S&&g?l.style.stroke=ye(S,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}`),C&&l.tagName.toLowerCase()==="path"&&A[p]&&l.setAttribute("d",Le(A[p],C,t));});}function Se(){if(W){e.style.clipPath=V(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${E[s]}`,t.style.strokeDashoffset=O==="reverse"?"0":`${E[s]}`,f?t.style.opacity=O==="reverse"?"1":"0":t.style.opacity="",S&&(t.style.stroke=S),y!==null&&(t.style.strokeWidth=`${y}`),b!==null&&(t.style.fillOpacity=`${b}`),C&&t.tagName.toLowerCase()==="path"&&A[s]&&t.setAttribute("d",A[s]);});}if(G.forEach(t=>{Ge(t);let s=ge(t);E.push(s),t.tagName.toLowerCase()==="path"?A.push(t.getAttribute("d")??""):A.push(""),o?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=O==="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}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=O==="reverse"?"0":`${s}`,f?t.style.opacity=O==="reverse"?"1":"0":t.style.opacity="",S&&(t.style.stroke=S),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":O;J=s;let re=k-T,z=true;if(W){let i=ae(H(s,T,k,l));X&&!oe&&(v=Math.max(v,i),i=v),K=i;let u=p==="reverse"?1-i:i;e.style.clipPath=V(u),ve?.(i),!P&&H(s,T,k,l)>0&&(P=true,xe?.()),i>=1&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,P=false,$=false,e.style.clipPath=V(0);},we))):i<1&&!X&&($=false),D=requestAnimationFrame(ee);return}if(G.forEach((i,u)=>{let M=u*B*re,c=ae(H(s,T+M,k+M,l));X&&!oe&&(v=Math.max(v,c),c=v),K=c,i.style.strokeDashoffset=p==="reverse"?`${E[u]*c}`:`${E[u]*(1-c)}`,f&&(i.style.opacity=p==="reverse"?`${1-c}`:`${c}`),S&&g?i.style.stroke=ye(S,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}`),C&&i.tagName.toLowerCase()==="path"&&A[u]&&i.setAttribute("d",Le(A[u],C,c)),u===0&&ve?.(c),c<1&&(z=false);}),se){let i=ae(H(s,T,k,l));for(let u in se){let M=parseFloat(u);i>=M&&!Y.has(M)&&(Y.add(M),se[u]?.());}}!P&&H(s,T,k,l)>0&&(P=true,xe?.()),z&&!$?($=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,P=false,$=false,Y.clear(),Se();},we))):!z&&!X&&($=false),D=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{U=s.isIntersecting,U&&!F?D=requestAnimationFrame(ee):cancelAnimationFrame(D);});},{root:d??null,threshold:Ie,rootMargin:Ne}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(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(D),clearTimeout(Q),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(me),ue?.remove();},replay(){v=-1,J=-1,Z=-1,P=false,$=false,q=0,F=false,Y.clear(),clearTimeout(Q),Se();},pause(){F=true,cancelAnimationFrame(D);},resume(){F&&(F=false,U&&(D=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,v=s,F=true,cancelAnimationFrame(D),ze(s,O);},getProgress(){return K}}}function Qe(e={}){let r=ref(null);return onMounted(()=>{if(!r.value)return;let o=he(r.value,e);onUnmounted(()=>o.destroy());}),r}var Ye=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?.())}});export{Ye as ScrollDraw,Qe as useScrollDraw};
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(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),L=n[a++]??m;return String(+(m+(L-m)*o).toFixed(4))})}function be(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:L={},stagger:B=0,direction:P="forward",once:X=false,debug:Fe=false,axis:x="y",scrollContainer:ne,autoReverse:oe=false,delay:he=0,strokeColor:I,strokeWidth:N,fillOpacity:R,waypoints:se,velocityScale:ie=false,threshold:Ie=0,rootMargin:Ne="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 m=="function"?m:pe[m]??pe.linear,Re=de(L.start??"top bottom"),He=de(L.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,b=Array.isArray(N)?N[1]:typeof N=="number"?N:null,h=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(n)),E=[],T=[],A=0,k=0,S=false,C=false,M=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 We(){return d?x==="x"?d.clientWidth:d.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function Se(){let t=e.getBoundingClientRect(),s,l,p;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,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,We(),Re,He);A=re.tStart,k=re.tEnd,Fe&&process.env.NODE_ENV!=="production"&&(ue?.remove(),ue=qe(A,k,x));}function Ve(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),H){let l=s==="reverse"?1-t:t;e.style.clipPath=W(l);return}G.forEach((l,p)=>{l.style.strokeDashoffset=s==="reverse"?`${E[p]*t}`:`${E[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&&b!==null?l.style.strokeWidth=`${y+(b-y)*t}`:b!==null&&(l.style.strokeWidth=`${b}`),h!==null&&w!==null?l.style.fillOpacity=`${h+(w-h)*t}`:w!==null&&(l.style.fillOpacity=`${w}`),O&&l.tagName.toLowerCase()==="path"&&T[p]&&l.setAttribute("d",Le(T[p],O,t));});}function $e(){if(e.style.setProperty("--scroll-draw-progress","0"),H){e.style.clipPath=W(0);return}G.forEach((t,s)=>{t.style.strokeDasharray=`${E[s]}`,t.style.strokeDashoffset=P==="reverse"?"0":`${E[s]}`,f?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",$&&(t.style.stroke=$),y!==null&&(t.style.strokeWidth=`${y}`),h!==null&&(t.style.fillOpacity=`${h}`),O&&t.tagName.toLowerCase()==="path"&&T[s]&&t.setAttribute("d",T[s]);});}if(G.forEach(t=>{Ge(t);let s=ge(t);E.push(s),t.tagName.toLowerCase()==="path"?T.push(t.getAttribute("d")??""):T.push(""),o?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=P==="reverse"?`${s}`:"0",f&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),w!==null&&(t.style.fillOpacity=`${w}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=P==="reverse"?"0":`${s}`,f?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",$&&(t.style.stroke=$),y!==null&&(t.style.strokeWidth=`${y}`),h!==null&&(t.style.fillOpacity=`${h}`));}),H){if(o)return e.style.clipPath=W(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(o)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};Se();function ee(){if(!U||F)return;let t=performance.now(),s=ce(),l=a;if(ie!==false){let i=t-Ee,c=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+c*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let p=oe?J===-1||s>=J?"forward":"reverse":P;J=s;let re=k-A,V=true;if(H){let i=ae(z(s,A,k,l));X&&!oe&&(v=Math.max(v,i),i=v),K=i,e.style.setProperty("--scroll-draw-progress",String(i));let c=p==="reverse"?1-i:i;e.style.clipPath=W(c),ve?.(i),!C&&z(s,A,k,l)>0&&(C=true,xe?.()),i>=1&&!S?(S=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,C=false,S=false,e.style.clipPath=W(0);},we))):i<1&&!X&&(S=false),M=requestAnimationFrame(ee);return}if(G.forEach((i,c)=>{let D=c*B*re,u=ae(z(s,A+D,k+D,l));X&&!oe&&(v=Math.max(v,u),u=v),K=u,i.style.strokeDashoffset=p==="reverse"?`${E[c]*u}`:`${E[c]*(1-u)}`,f&&(i.style.opacity=p==="reverse"?`${1-u}`:`${u}`),$&&g?i.style.stroke=ye($,g,u):g&&(i.style.stroke=g),y!==null&&b!==null?i.style.strokeWidth=`${y+(b-y)*u}`:b!==null&&(i.style.strokeWidth=`${b}`),h!==null&&w!==null?i.style.fillOpacity=`${h+(w-h)*u}`:w!==null&&(i.style.fillOpacity=`${w}`),O&&i.tagName.toLowerCase()==="path"&&T[c]&&i.setAttribute("d",Le(T[c],O,u)),c===0&&(ve?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(V=false);}),se){let i=ae(z(s,A,k,l));for(let c in se){let D=parseFloat(c);i>=D&&!Y.has(D)&&(Y.add(D),se[c]?.());}}!C&&z(s,A,k,l)>0&&(C=true,xe?.()),V&&!S?(S=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,Q=setTimeout(()=>{v=-1,C=false,S=false,Y.clear(),$e();},we))):!V&&!X&&(S=false),M=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{U=s.isIntersecting,U&&!F?M=requestAnimationFrame(ee):cancelAnimationFrame(M);});},{root:d??null,threshold:Ie,rootMargin:Ne}),me;function te(){clearTimeout(me),me=setTimeout(()=>{G.forEach((t,s)=>{E[s]=ge(t),t.style.strokeDasharray=`${E[s]}`;}),Se();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),he>0?setTimeout(()=>fe.observe(e),he):fe.observe(e),{destroy(){cancelAnimationFrame(M),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,S=false,q=0,F=false,Y.clear(),clearTimeout(Q),$e();},pause(){F=true,cancelAnimationFrame(M);},resume(){F&&(F=false,U&&(M=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));K=s,v=s,F=true,cancelAnimationFrame(M),Ve(s,P);},getProgress(){return K}}}function Qe(e={}){let r=ref(null);return onMounted(()=>{if(!r.value)return;let o=be(r.value,e);onUnmounted(()=>o.destroy());}),r}var Ye=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=be(o.value,n);onUnmounted(()=>a.destroy());}),()=>h("div",{ref:o},r.default?.())}});export{Ye as ScrollDraw,Qe as useScrollDraw};
@@ -1,3 +1,3 @@
1
- 'use strict';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 n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",o="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function ke(e,n,r,o){switch(o){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function Te(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function ye(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function Ve(e,n,r){return Math.min(r,Math.max(n,e))}function G(e,n,r,o){return r===n?0:Ve((e-n)/(r-n)*o,0,1)}function Me(e,n,r,o,a){let c=ke(e.top,e.height,n,o.element)-Te(o.viewport,r),u=ke(e.top,e.height,n,a.element)-Te(a.viewport,r);return {tStart:c,tEnd:u}}function Se(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let 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,n,r){let o=Se(e),a=Se(n);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*r)},${Math.round(o[1]+(a[1]-o[1])*r)},${Math.round(o[2]+(a[2]-o[2])*r)})`}function De(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n);}function ze(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?De("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&De("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ge(e,n,r){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=r==="x"?window.scrollX:window.scrollY,u=e-c,y=n-c,B=r==="x";o.innerHTML=`
1
+ 'use strict';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 s=e.trim();if(/^\d+(\.\d+)?%$/.test(s))return {element:"top",viewport:s};let[r="top",o="bottom"]=s.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function Te(e,s,r,o){switch(o){case "top":return e+r;case "center":return e+r+s/2;case "bottom":return e+r+s;default:return e+r}}function ke(e,s){if(/^\d+(\.\d+)?%$/.test(e))return s*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return s/2;case "bottom":return s;default:return s}}function ye(e){let s=e.tagName.toLowerCase();if(s==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(s==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function We(e,s,r){return Math.min(r,Math.max(s,e))}function z(e,s,r,o){return r===s?0:We((e-s)/(r-s)*o,0,1)}function Me(e,s,r,o,a){let c=Te(e.top,e.height,s,o.element)-ke(o.viewport,r),u=Te(e.top,e.height,s,a.element)-ke(a.viewport,r);return {tStart:c,tEnd:u}}function Se(e){let s=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(s)return [parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16),parseInt(s[3]+s[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let 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,s,r){let o=Se(e),a=Se(s);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*r)},${Math.round(o[1]+(a[1]-o[1])*r)},${Math.round(o[2]+(a[2]-o[2])*r)})`}function Le(e,s){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,s);}function Ve(e){let s=e.getAttribute("stroke"),r=e.getAttribute("fill");!s||s==="none"?Le("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&Le("Element has a fill \u2014 it may obscure the stroke animation.",e);}function ze(e,s,r){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=r==="x"?window.scrollX:window.scrollY,u=e-c,y=s-c,B=r==="x";o.innerHTML=`
2
2
  <div style="position:absolute;${B?`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;${B?`left:${y}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${y}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,n,r){let o=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),y=o[a++]??u;return String(+(u+(y-u)*r).toFixed(4))})}function Ie(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let r=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:y={},stagger:B=0,direction:I="forward",once:X=false,debug:Fe=false,axis:E="y",scrollContainer:ne,autoReverse:se=false,delay:be=0,strokeColor:P,strokeWidth:N,fillOpacity:R,waypoints:oe,velocityScale:ie=false,threshold:Oe=0,rootMargin:Ce="0px",repeat:_=0,repeatDelay:we=0,morphTo:F,clip:le,onProgress:ve,onStart:xe,onComplete:j}=n,W=le===true?"left":typeof le=="string"?le:false,ae=typeof u=="function"?u:me[u]??me.linear,Pe=de(y.start??"top bottom"),Ne=de(y.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,k=Array.isArray(P)?P[0]:null,g=Array.isArray(P)?P[1]:typeof P=="string"?P:null,h=Array.isArray(N)?N[0]:null,b=Array.isArray(N)?N[1]:typeof N=="number"?N:null,w=Array.isArray(R)?R[0]:null,v=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 H=W?[]:Array.from(e.querySelectorAll(o)),$=[],T=[],S=0,M=0,A=false,O=false,D=0,J=false,x=-1,K=-1,C=false,Q=0,q=0,U,ce=null,Y=new Set,Z=-1,Ee=performance.now();function ue(){return d?E==="x"?d.scrollLeft:d.scrollTop:E==="x"?window.scrollX:window.scrollY}function Re(){return d?E==="x"?d.clientWidth:d.clientHeight:E==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),s,l,m;if(d){let z=d.getBoundingClientRect();s=E==="x"?t.left-z.left+d.scrollLeft:t.top-z.top+d.scrollTop,l=E==="x"?t.width:t.height,m=ue();}else s=E==="x"?t.left:t.top,l=E==="x"?t.width:t.height,m=ue();let re=Me({top:s,height:l},m,Re(),Pe,Ne);S=re.tStart,M=re.tEnd,Fe&&process.env.NODE_ENV!=="production"&&(ce?.remove(),ce=Ge(S,M,E));}function We(t,s){if(W){let l=s==="reverse"?1-t:t;e.style.clipPath=V(l);return}H.forEach((l,m)=>{l.style.strokeDashoffset=s==="reverse"?`${$[m]*t}`:`${$[m]*(1-t)}`,c&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),k&&g?l.style.stroke=ge(k,g,t):g&&(l.style.stroke=g),h!==null&&b!==null?l.style.strokeWidth=`${h+(b-h)*t}`:b!==null&&(l.style.strokeWidth=`${b}`),w!==null&&v!==null?l.style.fillOpacity=`${w+(v-w)*t}`:v!==null&&(l.style.fillOpacity=`${v}`),F&&l.tagName.toLowerCase()==="path"&&T[m]&&l.setAttribute("d",Le(T[m],F,t));});}function Ae(){if(W){e.style.clipPath=V(0);return}H.forEach((t,s)=>{t.style.strokeDasharray=`${$[s]}`,t.style.strokeDashoffset=I==="reverse"?"0":`${$[s]}`,c?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",k&&(t.style.stroke=k),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),F&&t.tagName.toLowerCase()==="path"&&T[s]&&t.setAttribute("d",T[s]);});}if(H.forEach(t=>{ze(t);let s=ye(t);$.push(s),t.tagName.toLowerCase()==="path"?T.push(t.getAttribute("d")??""):T.push(""),r?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?`${s}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),v!==null&&(t.style.fillOpacity=`${v}`),F&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",F)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?"0":`${s}`,c?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",k&&(t.style.stroke=k),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`));}),W){if(r)return e.style.clipPath=V(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=V(0);}else if(r)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||C)return;let t=performance.now(),s=ue(),l=a;if(ie!==false){let i=t-Ee,f=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+f*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let m=se?K===-1||s>=K?"forward":"reverse":I;K=s;let re=M-S,z=true;if(W){let i=ae(G(s,S,M,l));X&&!se&&(x=Math.max(x,i),i=x),Q=i;let f=m==="reverse"?1-i:i;e.style.clipPath=V(f),ve?.(i),!O&&G(s,S,M,l)>0&&(O=true,xe?.()),i>=1&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,O=false,A=false,e.style.clipPath=V(0);},we))):i<1&&!X&&(A=false),D=requestAnimationFrame(ee);return}if(H.forEach((i,f)=>{let L=f*B*re,p=ae(G(s,S+L,M+L,l));X&&!se&&(x=Math.max(x,p),p=x),Q=p,i.style.strokeDashoffset=m==="reverse"?`${$[f]*p}`:`${$[f]*(1-p)}`,c&&(i.style.opacity=m==="reverse"?`${1-p}`:`${p}`),k&&g?i.style.stroke=ge(k,g,p):g&&(i.style.stroke=g),h!==null&&b!==null?i.style.strokeWidth=`${h+(b-h)*p}`:b!==null&&(i.style.strokeWidth=`${b}`),w!==null&&v!==null?i.style.fillOpacity=`${w+(v-w)*p}`:v!==null&&(i.style.fillOpacity=`${v}`),F&&i.tagName.toLowerCase()==="path"&&T[f]&&i.setAttribute("d",Le(T[f],F,p)),f===0&&ve?.(p),p<1&&(z=false);}),oe){let i=ae(G(s,S,M,l));for(let f in oe){let L=parseFloat(f);i>=L&&!Y.has(L)&&(Y.add(L),oe[f]?.());}}!O&&G(s,S,M,l)>0&&(O=true,xe?.()),z&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,O=false,A=false,Y.clear(),Ae();},we))):!z&&!X&&(A=false),D=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!C?D=requestAnimationFrame(ee):cancelAnimationFrame(D);});},{root:d??null,threshold:Oe,rootMargin:Ce}),pe;function te(){clearTimeout(pe),pe=setTimeout(()=>{H.forEach((t,s)=>{$[s]=ye(t),t.style.strokeDasharray=`${$[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>fe.observe(e),be):fe.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(U),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(pe),ce?.remove();},replay(){x=-1,K=-1,Z=-1,O=false,A=false,q=0,C=false,Y.clear(),clearTimeout(U),Ae();},pause(){C=true,cancelAnimationFrame(D);},resume(){C&&(C=false,J&&(D=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));Q=s,x=s,C=true,cancelAnimationFrame(D),We(s,I);},getProgress(){return Q}}}var he=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}connectedCallback(){let r={},o=this.getAttribute("speed"),a=this.getAttribute("easing"),c=this.getAttribute("stagger"),u=this.getAttribute("direction"),y=this.getAttribute("selector");o&&(r.speed=parseFloat(o)),a&&(r.easing=a),c&&(r.stagger=parseFloat(c)),u&&(r.direction=u),y&&(r.selector=y),this.hasAttribute("fade")&&(r.fade=this.getAttribute("fade")!=="false"),this.instance=Ie(this,r);}disconnectedCallback(){this.instance?.destroy(),this.instance=null;}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",he);
3
+ <div style="position:absolute;${B?`left:${y}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${y}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 De(e,s,r){let o=(s.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),y=o[a++]??u;return String(+(u+(y-u)*r).toFixed(4))})}function Pe(e,s={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let r=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:y={},stagger:B=0,direction:P="forward",once:X=false,debug:Ie=false,axis:E="y",scrollContainer:se,autoReverse:ne=false,delay:be=0,strokeColor:C,strokeWidth:N,fillOpacity:H,waypoints:oe,velocityScale:ie=false,threshold:Fe=0,rootMargin:Oe="0px",repeat:_=0,repeatDelay:we=0,morphTo:I,clip:le,onProgress:ve,onStart:xe,onComplete:j}=s,R=le===true?"left":typeof le=="string"?le:false,ae=typeof u=="function"?u:me[u]??me.linear,Ce=de(y.start??"top bottom"),Ne=de(y.end??"bottom top"),d=typeof se=="string"?document.querySelector(se):se??null,T=Array.isArray(C)?C[0]:null,g=Array.isArray(C)?C[1]:typeof C=="string"?C:null,h=Array.isArray(N)?N[0]:null,b=Array.isArray(N)?N[1]:typeof N=="number"?N:null,w=Array.isArray(H)?H[0]:null,v=Array.isArray(H)?H[1]:typeof H=="number"?H:null;function W(t){let n=t*100;switch(R){case "right":return `inset(0 0 0 ${100-n}%)`;case "top":return `inset(0 0 ${100-n}% 0)`;case "bottom":return `inset(${100-n}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-n}% 0 0)`}}let G=R?[]:Array.from(e.querySelectorAll(o)),$=[],k=[],S=0,M=0,A=false,F=false,L=0,J=false,x=-1,K=-1,O=false,Q=0,q=0,U,ce=null,Y=new Set,Z=-1,Ee=performance.now();function ue(){return d?E==="x"?d.scrollLeft:d.scrollTop:E==="x"?window.scrollX:window.scrollY}function He(){return d?E==="x"?d.clientWidth:d.clientHeight:E==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),n,l,m;if(d){let V=d.getBoundingClientRect();n=E==="x"?t.left-V.left+d.scrollLeft:t.top-V.top+d.scrollTop,l=E==="x"?t.width:t.height,m=ue();}else n=E==="x"?t.left:t.top,l=E==="x"?t.width:t.height,m=ue();let re=Me({top:n,height:l},m,He(),Ce,Ne);S=re.tStart,M=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ce?.remove(),ce=ze(S,M,E));}function Re(t,n){if(e.style.setProperty("--scroll-draw-progress",String(t)),R){let l=n==="reverse"?1-t:t;e.style.clipPath=W(l);return}G.forEach((l,m)=>{l.style.strokeDashoffset=n==="reverse"?`${$[m]*t}`:`${$[m]*(1-t)}`,c&&(l.style.opacity=n==="reverse"?`${1-t}`:`${t}`),T&&g?l.style.stroke=ge(T,g,t):g&&(l.style.stroke=g),h!==null&&b!==null?l.style.strokeWidth=`${h+(b-h)*t}`:b!==null&&(l.style.strokeWidth=`${b}`),w!==null&&v!==null?l.style.fillOpacity=`${w+(v-w)*t}`:v!==null&&(l.style.fillOpacity=`${v}`),I&&l.tagName.toLowerCase()==="path"&&k[m]&&l.setAttribute("d",De(k[m],I,t));});}function Ae(){if(e.style.setProperty("--scroll-draw-progress","0"),R){e.style.clipPath=W(0);return}G.forEach((t,n)=>{t.style.strokeDasharray=`${$[n]}`,t.style.strokeDashoffset=P==="reverse"?"0":`${$[n]}`,c?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",T&&(t.style.stroke=T),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),I&&t.tagName.toLowerCase()==="path"&&k[n]&&t.setAttribute("d",k[n]);});}if(G.forEach(t=>{Ve(t);let n=ye(t);$.push(n),t.tagName.toLowerCase()==="path"?k.push(t.getAttribute("d")??""):k.push(""),r?(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=P==="reverse"?`${n}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),v!==null&&(t.style.fillOpacity=`${v}`),I&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",I)):(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=P==="reverse"?"0":`${n}`,c?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",T&&(t.style.stroke=T),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`));}),R){if(r)return e.style.clipPath=W(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(r)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||O)return;let t=performance.now(),n=ue(),l=a;if(ie!==false){let i=t-Ee,p=i>0?Math.abs(n-(Z<0?n:Z))/i:0;l=a*Math.max(.2,1+p*(typeof ie=="number"?ie:1)*.04);}Z=n,Ee=t;let m=ne?K===-1||n>=K?"forward":"reverse":P;K=n;let re=M-S,V=true;if(R){let i=ae(z(n,S,M,l));X&&!ne&&(x=Math.max(x,i),i=x),Q=i,e.style.setProperty("--scroll-draw-progress",String(i));let p=m==="reverse"?1-i:i;e.style.clipPath=W(p),ve?.(i),!F&&z(n,S,M,l)>0&&(F=true,xe?.()),i>=1&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,F=false,A=false,e.style.clipPath=W(0);},we))):i<1&&!X&&(A=false),L=requestAnimationFrame(ee);return}if(G.forEach((i,p)=>{let D=p*B*re,f=ae(z(n,S+D,M+D,l));X&&!ne&&(x=Math.max(x,f),f=x),Q=f,i.style.strokeDashoffset=m==="reverse"?`${$[p]*f}`:`${$[p]*(1-f)}`,c&&(i.style.opacity=m==="reverse"?`${1-f}`:`${f}`),T&&g?i.style.stroke=ge(T,g,f):g&&(i.style.stroke=g),h!==null&&b!==null?i.style.strokeWidth=`${h+(b-h)*f}`:b!==null&&(i.style.strokeWidth=`${b}`),w!==null&&v!==null?i.style.fillOpacity=`${w+(v-w)*f}`:v!==null&&(i.style.fillOpacity=`${v}`),I&&i.tagName.toLowerCase()==="path"&&k[p]&&i.setAttribute("d",De(k[p],I,f)),p===0&&(ve?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(V=false);}),oe){let i=ae(z(n,S,M,l));for(let p in oe){let D=parseFloat(p);i>=D&&!Y.has(D)&&(Y.add(D),oe[p]?.());}}!F&&z(n,S,M,l)>0&&(F=true,xe?.()),V&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,F=false,A=false,Y.clear(),Ae();},we))):!V&&!X&&(A=false),L=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(n=>{J=n.isIntersecting,J&&!O?L=requestAnimationFrame(ee):cancelAnimationFrame(L);});},{root:d??null,threshold:Fe,rootMargin:Oe}),pe;function te(){clearTimeout(pe),pe=setTimeout(()=>{G.forEach((t,n)=>{$[n]=ye(t),t.style.strokeDasharray=`${$[n]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>fe.observe(e),be):fe.observe(e),{destroy(){cancelAnimationFrame(L),clearTimeout(U),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(pe),ce?.remove();},replay(){x=-1,K=-1,Z=-1,F=false,A=false,q=0,O=false,Y.clear(),clearTimeout(U),Ae();},pause(){O=true,cancelAnimationFrame(L);},resume(){O&&(O=false,J&&(L=requestAnimationFrame(ee)));},seek(t){let n=Math.min(1,Math.max(0,t));Q=n,x=n,O=true,cancelAnimationFrame(L),Re(n,P);},getProgress(){return Q}}}var he=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}connectedCallback(){let r={},o=this.getAttribute("speed"),a=this.getAttribute("easing"),c=this.getAttribute("stagger"),u=this.getAttribute("direction"),y=this.getAttribute("selector");o&&(r.speed=parseFloat(o)),a&&(r.easing=a),c&&(r.stagger=parseFloat(c)),u&&(r.direction=u),y&&(r.selector=y),this.hasAttribute("fade")&&(r.fade=this.getAttribute("fade")!=="false"),this.instance=Pe(this,r);}disconnectedCallback(){this.instance?.destroy(),this.instance=null;}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",he);
@@ -1,3 +1,3 @@
1
- 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 n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",o="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function ke(e,n,r,o){switch(o){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function Te(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function ye(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function Ve(e,n,r){return Math.min(r,Math.max(n,e))}function G(e,n,r,o){return r===n?0:Ve((e-n)/(r-n)*o,0,1)}function Me(e,n,r,o,a){let c=ke(e.top,e.height,n,o.element)-Te(o.viewport,r),u=ke(e.top,e.height,n,a.element)-Te(a.viewport,r);return {tStart:c,tEnd:u}}function Se(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let 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,n,r){let o=Se(e),a=Se(n);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*r)},${Math.round(o[1]+(a[1]-o[1])*r)},${Math.round(o[2]+(a[2]-o[2])*r)})`}function De(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n);}function ze(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?De("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&De("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ge(e,n,r){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=r==="x"?window.scrollX:window.scrollY,u=e-c,y=n-c,B=r==="x";o.innerHTML=`
1
+ 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 s=e.trim();if(/^\d+(\.\d+)?%$/.test(s))return {element:"top",viewport:s};let[r="top",o="bottom"]=s.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function Te(e,s,r,o){switch(o){case "top":return e+r;case "center":return e+r+s/2;case "bottom":return e+r+s;default:return e+r}}function ke(e,s){if(/^\d+(\.\d+)?%$/.test(e))return s*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return s/2;case "bottom":return s;default:return s}}function ye(e){let s=e.tagName.toLowerCase();if(s==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(s==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function We(e,s,r){return Math.min(r,Math.max(s,e))}function z(e,s,r,o){return r===s?0:We((e-s)/(r-s)*o,0,1)}function Me(e,s,r,o,a){let c=Te(e.top,e.height,s,o.element)-ke(o.viewport,r),u=Te(e.top,e.height,s,a.element)-ke(a.viewport,r);return {tStart:c,tEnd:u}}function Se(e){let s=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(s)return [parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16),parseInt(s[3]+s[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let 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,s,r){let o=Se(e),a=Se(s);return !o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*r)},${Math.round(o[1]+(a[1]-o[1])*r)},${Math.round(o[2]+(a[2]-o[2])*r)})`}function Le(e,s){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,s);}function Ve(e){let s=e.getAttribute("stroke"),r=e.getAttribute("fill");!s||s==="none"?Le("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&Le("Element has a fill \u2014 it may obscure the stroke animation.",e);}function ze(e,s,r){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=r==="x"?window.scrollX:window.scrollY,u=e-c,y=s-c,B=r==="x";o.innerHTML=`
2
2
  <div style="position:absolute;${B?`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;${B?`left:${y}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${y}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,n,r){let o=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),y=o[a++]??u;return String(+(u+(y-u)*r).toFixed(4))})}function Ie(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let r=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:y={},stagger:B=0,direction:I="forward",once:X=false,debug:Fe=false,axis:E="y",scrollContainer:ne,autoReverse:se=false,delay:be=0,strokeColor:P,strokeWidth:N,fillOpacity:R,waypoints:oe,velocityScale:ie=false,threshold:Oe=0,rootMargin:Ce="0px",repeat:_=0,repeatDelay:we=0,morphTo:F,clip:le,onProgress:ve,onStart:xe,onComplete:j}=n,W=le===true?"left":typeof le=="string"?le:false,ae=typeof u=="function"?u:me[u]??me.linear,Pe=de(y.start??"top bottom"),Ne=de(y.end??"bottom top"),d=typeof ne=="string"?document.querySelector(ne):ne??null,k=Array.isArray(P)?P[0]:null,g=Array.isArray(P)?P[1]:typeof P=="string"?P:null,h=Array.isArray(N)?N[0]:null,b=Array.isArray(N)?N[1]:typeof N=="number"?N:null,w=Array.isArray(R)?R[0]:null,v=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 H=W?[]:Array.from(e.querySelectorAll(o)),$=[],T=[],S=0,M=0,A=false,O=false,D=0,J=false,x=-1,K=-1,C=false,Q=0,q=0,U,ce=null,Y=new Set,Z=-1,Ee=performance.now();function ue(){return d?E==="x"?d.scrollLeft:d.scrollTop:E==="x"?window.scrollX:window.scrollY}function Re(){return d?E==="x"?d.clientWidth:d.clientHeight:E==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),s,l,m;if(d){let z=d.getBoundingClientRect();s=E==="x"?t.left-z.left+d.scrollLeft:t.top-z.top+d.scrollTop,l=E==="x"?t.width:t.height,m=ue();}else s=E==="x"?t.left:t.top,l=E==="x"?t.width:t.height,m=ue();let re=Me({top:s,height:l},m,Re(),Pe,Ne);S=re.tStart,M=re.tEnd,Fe&&process.env.NODE_ENV!=="production"&&(ce?.remove(),ce=Ge(S,M,E));}function We(t,s){if(W){let l=s==="reverse"?1-t:t;e.style.clipPath=V(l);return}H.forEach((l,m)=>{l.style.strokeDashoffset=s==="reverse"?`${$[m]*t}`:`${$[m]*(1-t)}`,c&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),k&&g?l.style.stroke=ge(k,g,t):g&&(l.style.stroke=g),h!==null&&b!==null?l.style.strokeWidth=`${h+(b-h)*t}`:b!==null&&(l.style.strokeWidth=`${b}`),w!==null&&v!==null?l.style.fillOpacity=`${w+(v-w)*t}`:v!==null&&(l.style.fillOpacity=`${v}`),F&&l.tagName.toLowerCase()==="path"&&T[m]&&l.setAttribute("d",Le(T[m],F,t));});}function Ae(){if(W){e.style.clipPath=V(0);return}H.forEach((t,s)=>{t.style.strokeDasharray=`${$[s]}`,t.style.strokeDashoffset=I==="reverse"?"0":`${$[s]}`,c?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",k&&(t.style.stroke=k),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),F&&t.tagName.toLowerCase()==="path"&&T[s]&&t.setAttribute("d",T[s]);});}if(H.forEach(t=>{ze(t);let s=ye(t);$.push(s),t.tagName.toLowerCase()==="path"?T.push(t.getAttribute("d")??""):T.push(""),r?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?`${s}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),v!==null&&(t.style.fillOpacity=`${v}`),F&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",F)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=I==="reverse"?"0":`${s}`,c?t.style.opacity=I==="reverse"?"1":"0":t.style.opacity="",k&&(t.style.stroke=k),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`));}),W){if(r)return e.style.clipPath=V(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=V(0);}else if(r)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||C)return;let t=performance.now(),s=ue(),l=a;if(ie!==false){let i=t-Ee,f=i>0?Math.abs(s-(Z<0?s:Z))/i:0;l=a*Math.max(.2,1+f*(typeof ie=="number"?ie:1)*.04);}Z=s,Ee=t;let m=se?K===-1||s>=K?"forward":"reverse":I;K=s;let re=M-S,z=true;if(W){let i=ae(G(s,S,M,l));X&&!se&&(x=Math.max(x,i),i=x),Q=i;let f=m==="reverse"?1-i:i;e.style.clipPath=V(f),ve?.(i),!O&&G(s,S,M,l)>0&&(O=true,xe?.()),i>=1&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,O=false,A=false,e.style.clipPath=V(0);},we))):i<1&&!X&&(A=false),D=requestAnimationFrame(ee);return}if(H.forEach((i,f)=>{let L=f*B*re,p=ae(G(s,S+L,M+L,l));X&&!se&&(x=Math.max(x,p),p=x),Q=p,i.style.strokeDashoffset=m==="reverse"?`${$[f]*p}`:`${$[f]*(1-p)}`,c&&(i.style.opacity=m==="reverse"?`${1-p}`:`${p}`),k&&g?i.style.stroke=ge(k,g,p):g&&(i.style.stroke=g),h!==null&&b!==null?i.style.strokeWidth=`${h+(b-h)*p}`:b!==null&&(i.style.strokeWidth=`${b}`),w!==null&&v!==null?i.style.fillOpacity=`${w+(v-w)*p}`:v!==null&&(i.style.fillOpacity=`${v}`),F&&i.tagName.toLowerCase()==="path"&&T[f]&&i.setAttribute("d",Le(T[f],F,p)),f===0&&ve?.(p),p<1&&(z=false);}),oe){let i=ae(G(s,S,M,l));for(let f in oe){let L=parseFloat(f);i>=L&&!Y.has(L)&&(Y.add(L),oe[f]?.());}}!O&&G(s,S,M,l)>0&&(O=true,xe?.()),z&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,O=false,A=false,Y.clear(),Ae();},we))):!z&&!X&&(A=false),D=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(s=>{J=s.isIntersecting,J&&!C?D=requestAnimationFrame(ee):cancelAnimationFrame(D);});},{root:d??null,threshold:Oe,rootMargin:Ce}),pe;function te(){clearTimeout(pe),pe=setTimeout(()=>{H.forEach((t,s)=>{$[s]=ye(t),t.style.strokeDasharray=`${$[s]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>fe.observe(e),be):fe.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(U),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(pe),ce?.remove();},replay(){x=-1,K=-1,Z=-1,O=false,A=false,q=0,C=false,Y.clear(),clearTimeout(U),Ae();},pause(){C=true,cancelAnimationFrame(D);},resume(){C&&(C=false,J&&(D=requestAnimationFrame(ee)));},seek(t){let s=Math.min(1,Math.max(0,t));Q=s,x=s,C=true,cancelAnimationFrame(D),We(s,I);},getProgress(){return Q}}}var he=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}connectedCallback(){let r={},o=this.getAttribute("speed"),a=this.getAttribute("easing"),c=this.getAttribute("stagger"),u=this.getAttribute("direction"),y=this.getAttribute("selector");o&&(r.speed=parseFloat(o)),a&&(r.easing=a),c&&(r.stagger=parseFloat(c)),u&&(r.direction=u),y&&(r.selector=y),this.hasAttribute("fade")&&(r.fade=this.getAttribute("fade")!=="false"),this.instance=Ie(this,r);}disconnectedCallback(){this.instance?.destroy(),this.instance=null;}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",he);
3
+ <div style="position:absolute;${B?`left:${y}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${y}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 De(e,s,r){let o=(s.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let u=parseFloat(c),y=o[a++]??u;return String(+(u+(y-u)*r).toFixed(4))})}function Pe(e,s={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let r=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:y={},stagger:B=0,direction:P="forward",once:X=false,debug:Ie=false,axis:E="y",scrollContainer:se,autoReverse:ne=false,delay:be=0,strokeColor:C,strokeWidth:N,fillOpacity:H,waypoints:oe,velocityScale:ie=false,threshold:Fe=0,rootMargin:Oe="0px",repeat:_=0,repeatDelay:we=0,morphTo:I,clip:le,onProgress:ve,onStart:xe,onComplete:j}=s,R=le===true?"left":typeof le=="string"?le:false,ae=typeof u=="function"?u:me[u]??me.linear,Ce=de(y.start??"top bottom"),Ne=de(y.end??"bottom top"),d=typeof se=="string"?document.querySelector(se):se??null,T=Array.isArray(C)?C[0]:null,g=Array.isArray(C)?C[1]:typeof C=="string"?C:null,h=Array.isArray(N)?N[0]:null,b=Array.isArray(N)?N[1]:typeof N=="number"?N:null,w=Array.isArray(H)?H[0]:null,v=Array.isArray(H)?H[1]:typeof H=="number"?H:null;function W(t){let n=t*100;switch(R){case "right":return `inset(0 0 0 ${100-n}%)`;case "top":return `inset(0 0 ${100-n}% 0)`;case "bottom":return `inset(${100-n}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-n}% 0 0)`}}let G=R?[]:Array.from(e.querySelectorAll(o)),$=[],k=[],S=0,M=0,A=false,F=false,L=0,J=false,x=-1,K=-1,O=false,Q=0,q=0,U,ce=null,Y=new Set,Z=-1,Ee=performance.now();function ue(){return d?E==="x"?d.scrollLeft:d.scrollTop:E==="x"?window.scrollX:window.scrollY}function He(){return d?E==="x"?d.clientWidth:d.clientHeight:E==="x"?window.innerWidth:window.innerHeight}function $e(){let t=e.getBoundingClientRect(),n,l,m;if(d){let V=d.getBoundingClientRect();n=E==="x"?t.left-V.left+d.scrollLeft:t.top-V.top+d.scrollTop,l=E==="x"?t.width:t.height,m=ue();}else n=E==="x"?t.left:t.top,l=E==="x"?t.width:t.height,m=ue();let re=Me({top:n,height:l},m,He(),Ce,Ne);S=re.tStart,M=re.tEnd,Ie&&process.env.NODE_ENV!=="production"&&(ce?.remove(),ce=ze(S,M,E));}function Re(t,n){if(e.style.setProperty("--scroll-draw-progress",String(t)),R){let l=n==="reverse"?1-t:t;e.style.clipPath=W(l);return}G.forEach((l,m)=>{l.style.strokeDashoffset=n==="reverse"?`${$[m]*t}`:`${$[m]*(1-t)}`,c&&(l.style.opacity=n==="reverse"?`${1-t}`:`${t}`),T&&g?l.style.stroke=ge(T,g,t):g&&(l.style.stroke=g),h!==null&&b!==null?l.style.strokeWidth=`${h+(b-h)*t}`:b!==null&&(l.style.strokeWidth=`${b}`),w!==null&&v!==null?l.style.fillOpacity=`${w+(v-w)*t}`:v!==null&&(l.style.fillOpacity=`${v}`),I&&l.tagName.toLowerCase()==="path"&&k[m]&&l.setAttribute("d",De(k[m],I,t));});}function Ae(){if(e.style.setProperty("--scroll-draw-progress","0"),R){e.style.clipPath=W(0);return}G.forEach((t,n)=>{t.style.strokeDasharray=`${$[n]}`,t.style.strokeDashoffset=P==="reverse"?"0":`${$[n]}`,c?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",T&&(t.style.stroke=T),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`),I&&t.tagName.toLowerCase()==="path"&&k[n]&&t.setAttribute("d",k[n]);});}if(G.forEach(t=>{Ve(t);let n=ye(t);$.push(n),t.tagName.toLowerCase()==="path"?k.push(t.getAttribute("d")??""):k.push(""),r?(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=P==="reverse"?`${n}`:"0",c&&(t.style.opacity="1"),g&&(t.style.stroke=g),b!==null&&(t.style.strokeWidth=`${b}`),v!==null&&(t.style.fillOpacity=`${v}`),I&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",I)):(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=P==="reverse"?"0":`${n}`,c?t.style.opacity=P==="reverse"?"1":"0":t.style.opacity="",T&&(t.style.stroke=T),h!==null&&(t.style.strokeWidth=`${h}`),w!==null&&(t.style.fillOpacity=`${w}`));}),R){if(r)return e.style.clipPath=W(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(r)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};$e();function ee(){if(!J||O)return;let t=performance.now(),n=ue(),l=a;if(ie!==false){let i=t-Ee,p=i>0?Math.abs(n-(Z<0?n:Z))/i:0;l=a*Math.max(.2,1+p*(typeof ie=="number"?ie:1)*.04);}Z=n,Ee=t;let m=ne?K===-1||n>=K?"forward":"reverse":P;K=n;let re=M-S,V=true;if(R){let i=ae(z(n,S,M,l));X&&!ne&&(x=Math.max(x,i),i=x),Q=i,e.style.setProperty("--scroll-draw-progress",String(i));let p=m==="reverse"?1-i:i;e.style.clipPath=W(p),ve?.(i),!F&&z(n,S,M,l)>0&&(F=true,xe?.()),i>=1&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,F=false,A=false,e.style.clipPath=W(0);},we))):i<1&&!X&&(A=false),L=requestAnimationFrame(ee);return}if(G.forEach((i,p)=>{let D=p*B*re,f=ae(z(n,S+D,M+D,l));X&&!ne&&(x=Math.max(x,f),f=x),Q=f,i.style.strokeDashoffset=m==="reverse"?`${$[p]*f}`:`${$[p]*(1-f)}`,c&&(i.style.opacity=m==="reverse"?`${1-f}`:`${f}`),T&&g?i.style.stroke=ge(T,g,f):g&&(i.style.stroke=g),h!==null&&b!==null?i.style.strokeWidth=`${h+(b-h)*f}`:b!==null&&(i.style.strokeWidth=`${b}`),w!==null&&v!==null?i.style.fillOpacity=`${w+(v-w)*f}`:v!==null&&(i.style.fillOpacity=`${v}`),I&&i.tagName.toLowerCase()==="path"&&k[p]&&i.setAttribute("d",De(k[p],I,f)),p===0&&(ve?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(V=false);}),oe){let i=ae(z(n,S,M,l));for(let p in oe){let D=parseFloat(p);i>=D&&!Y.has(D)&&(Y.add(D),oe[p]?.());}}!F&&z(n,S,M,l)>0&&(F=true,xe?.()),V&&!A?(A=true,j?.(),q<(_==="infinite"?1/0:_??0)&&(q++,U=setTimeout(()=>{x=-1,F=false,A=false,Y.clear(),Ae();},we))):!V&&!X&&(A=false),L=requestAnimationFrame(ee);}let fe=new IntersectionObserver(t=>{t.forEach(n=>{J=n.isIntersecting,J&&!O?L=requestAnimationFrame(ee):cancelAnimationFrame(L);});},{root:d??null,threshold:Fe,rootMargin:Oe}),pe;function te(){clearTimeout(pe),pe=setTimeout(()=>{G.forEach((t,n)=>{$[n]=ye(t),t.style.strokeDasharray=`${$[n]}`;}),$e();},150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),be>0?setTimeout(()=>fe.observe(e),be):fe.observe(e),{destroy(){cancelAnimationFrame(L),clearTimeout(U),fe.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(pe),ce?.remove();},replay(){x=-1,K=-1,Z=-1,F=false,A=false,q=0,O=false,Y.clear(),clearTimeout(U),Ae();},pause(){O=true,cancelAnimationFrame(L);},resume(){O&&(O=false,J&&(L=requestAnimationFrame(ee)));},seek(t){let n=Math.min(1,Math.max(0,t));Q=n,x=n,O=true,cancelAnimationFrame(L),Re(n,P);},getProgress(){return Q}}}var he=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}connectedCallback(){let r={},o=this.getAttribute("speed"),a=this.getAttribute("easing"),c=this.getAttribute("stagger"),u=this.getAttribute("direction"),y=this.getAttribute("selector");o&&(r.speed=parseFloat(o)),a&&(r.easing=a),c&&(r.stagger=parseFloat(c)),u&&(r.direction=u),y&&(r.selector=y),this.hasAttribute("fade")&&(r.fade=this.getAttribute("fade")!=="false"),this.instance=Pe(this,r);}disconnectedCallback(){this.instance?.destroy(),this.instance=null;}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",he);