svg-scroll-draw 1.1.0 → 1.2.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.
Files changed (44) hide show
  1. package/dist/angular/index.cjs +3 -3
  2. package/dist/angular/index.d.mts +1 -1
  3. package/dist/angular/index.d.ts +1 -1
  4. package/dist/angular/index.mjs +3 -3
  5. package/dist/astro/index.cjs +3 -3
  6. package/dist/astro/index.d.mts +1 -1
  7. package/dist/astro/index.d.ts +1 -1
  8. package/dist/astro/index.mjs +3 -3
  9. package/dist/cdn/svg-scroll-draw.global.js +3 -3
  10. package/dist/group/index.cjs +2 -2
  11. package/dist/group/index.d.mts +1 -1
  12. package/dist/group/index.d.ts +1 -1
  13. package/dist/group/index.mjs +2 -2
  14. package/dist/index.cjs +3 -3
  15. package/dist/index.d.mts +31 -2
  16. package/dist/index.d.ts +31 -2
  17. package/dist/index.mjs +3 -3
  18. package/dist/nuxt/index.cjs +3 -3
  19. package/dist/nuxt/index.d.mts +1 -1
  20. package/dist/nuxt/index.d.ts +1 -1
  21. package/dist/nuxt/index.mjs +3 -3
  22. package/dist/react/index.cjs +3 -3
  23. package/dist/react/index.d.mts +1 -1
  24. package/dist/react/index.d.ts +1 -1
  25. package/dist/react/index.mjs +3 -3
  26. package/dist/solid/index.cjs +3 -3
  27. package/dist/solid/index.d.mts +1 -1
  28. package/dist/solid/index.d.ts +1 -1
  29. package/dist/solid/index.mjs +3 -3
  30. package/dist/svelte/index.cjs +3 -3
  31. package/dist/svelte/index.d.mts +1 -1
  32. package/dist/svelte/index.d.ts +1 -1
  33. package/dist/svelte/index.mjs +3 -3
  34. package/dist/timeline/index.cjs +1 -1
  35. package/dist/timeline/index.d.mts +1 -1
  36. package/dist/timeline/index.d.ts +1 -1
  37. package/dist/timeline/index.mjs +1 -1
  38. package/dist/vue/index.cjs +3 -3
  39. package/dist/vue/index.d.mts +1 -1
  40. package/dist/vue/index.d.ts +1 -1
  41. package/dist/vue/index.mjs +3 -3
  42. package/dist/web-component/index.cjs +3 -3
  43. package/dist/web-component/index.mjs +3 -3
  44. package/package.json +6 -2
@@ -1,3 +1,3 @@
1
- 'use strict';var we={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 $e(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 Ce(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 Oe(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 Ee(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 Xe(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:Xe((e-r)/(n-r)*o,0,1)}function xe(e,r,n,o,f){let d=Ce(e.top,e.height,r,o.element)-Oe(o.viewport,n),p=Ce(e.top,e.height,r,f.element)-Oe(f.viewport,n);return {tStart:d,tEnd:p}}function Fe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function Se(e,r,n){let o=Fe(e),f=Fe(r);return !o||!f?e:`rgb(${Math.round(o[0]+(f[0]-o[0])*n)},${Math.round(o[1]+(f[1]-o[1])*n)},${Math.round(o[2]+(f[2]-o[2])*n)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ue=0;function je(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Je(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ke(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 f(){let d=n==="x"?window.scrollX:window.scrollY,p=e-d,D=r-d,X=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`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;${X?`left:${D}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${D}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",f,{passive:true}),f(),o}function He(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),f=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let p=parseFloat(d),D=o[f++]??p;return String(+(p+(D-p)*n).toFixed(4))})}function ce(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:f=1,fade:d=false,easing:p="linear",trigger:D={},stagger:X=0,direction:y="forward",once:U=false,debug:Ve=false,axis:$="y",scrollContainer:pe,autoReverse:Z=false,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:We=0,rootMargin:Ge="0px",repeat:j=0,repeatDelay:ke=0,morphTo:P,clip:de,native:ze=true,onProgress:ye,onStart:ge,onComplete:J}=r,W=de===true?"left":typeof de=="string"?de:false,re=typeof p=="function"?p:we[p]??we.linear,Te=$e(D.start??"top bottom"),Ae=$e(D.end??"bottom top"),b=typeof pe=="string"?document.querySelector(pe):pe??null,I=Array.isArray(R)?R[0]:null,E=Array.isArray(R)?R[1]:typeof R=="string"?R:null,x=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,T=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(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 v=W?[]:Array.from(e.querySelectorAll(o)),g=[],C=[],O=0,F=0,L=false,G=false,N=0,ne=false,A=-1,se=-1,z=false,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Me=performance.now();function Q(){return b?$==="x"?b.scrollLeft:b.scrollTop:$==="x"?window.scrollX:window.scrollY}function De(){return b?$==="x"?b.clientWidth:b.clientHeight:$==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),s,a,m;if(b){let w=b.getBoundingClientRect();s=$==="x"?t.left-w.left+b.scrollLeft:t.top-w.top+b.scrollTop,a=$==="x"?t.width:t.height,m=Q();}else s=$==="x"?t.left:t.top,a=$==="x"?t.width:t.height,m=Q();let q=xe({top:s,height:a},m,De(),Te,Ae);O=q.tStart,F=q.tEnd,Ve&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=Ke(O,F,$));}function qe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=s==="reverse"?1-t:t;e.style.clipPath=_(a);return}v.forEach((a,m)=>{a.style.strokeDashoffset=s==="reverse"?`${g[m]*t}`:`${g[m]*(1-t)}`,d&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),I&&E?a.style.stroke=Se(I,E,t):E&&(a.style.stroke=E),x!==null&&S!==null?a.style.strokeWidth=`${x+(S-x)*t}`:S!==null&&(a.style.strokeWidth=`${S}`),k!==null&&T!==null?a.style.fillOpacity=`${k+(T-k)*t}`:T!==null&&(a.style.fillOpacity=`${T}`),P&&a.tagName.toLowerCase()==="path"&&C[m]&&a.setAttribute("d",He(C[m],P,t));});}function Pe(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,s)=>{t.style.strokeDasharray=`${g[s]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[s]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`),P&&t.tagName.toLowerCase()==="path"&&C[s]&&t.setAttribute("d",C[s]);});}if(v.forEach(t=>{Je(t);let s=Ee(t);g.push(s),t.tagName.toLowerCase()==="path"?C.push(t.getAttribute("d")??""):C.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?`${s}`:"0",d&&(t.style.opacity="1"),E&&(t.style.stroke=E),S!==null&&(t.style.strokeWidth=`${S}`),T!==null&&(t.style.fillOpacity=`${T}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?"0":`${s}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(n)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(n)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Be(){return !(ze===false||!je()||!v.length||typeof p!="string"||!(p in Re)||W||$!=="y"||b||f!==1||X!==0||U||Z||te!==false||P||ee||j||me>0||ye||ge||J||R!=null||H!=null||V!=null||(D.start??"top bottom").trim()!=="top bottom"||(D.end??"bottom top").trim()!=="bottom top")}function _e(){let t=`svg-scroll-draw-${++Ue}`,s=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",m=`stroke-dashoffset:${s};`,q=`stroke-dashoffset:${a};`;d&&(m+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${t}{from{${m}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(w);function i(u,M){u.style.setProperty("--ssd-len",String(g[M])),u.style.strokeDasharray=`${g[M]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t);}v.forEach(i);let l=false,h=-1;function c(){if(h>=0)return h;let u=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=xe({top:u.top,height:u.height},Q(),De(),Te,Ae);return re(B(Q(),M,Y,f))}return {destroy(){v.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),w.remove();},replay(){l=false,h=-1,v.forEach(i);},pause(){l=true,v.forEach(u=>{u.style.animationPlayState="paused";});},resume(){l&&(l=false,v.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let M=Math.min(1,Math.max(0,u));h=M,l=true,v.forEach((Y,Ie)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Ie]*M}`:`${g[Ie]*(1-M)}`,d&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`);});},getProgress(){return c()}}}if(Be())return _e();Le();function ue(){if(!ne||z)return;let t=performance.now(),s=Q(),a=f;if(te!==false){let i=t-Me,l=i>0?Math.abs(s-(le<0?s:le))/i:0;a=f*Math.max(.2,1+l*(typeof te=="number"?te:1)*.04);}le=s,Me=t;let m=Z?se===-1||s>=se?"forward":"reverse":y;se=s;let q=F-O,w=true;if(W){let i=re(B(s,O,F,a));U&&!Z&&(A=Math.max(A,i),i=A),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let l=m==="reverse"?1-i:i;e.style.clipPath=_(l),ye?.(i),!G&&B(s,O,F,a)>0&&(G=true,ge?.()),i>=1&&!L?(L=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,L=false,e.style.clipPath=_(0);},ke))):i<1&&!U&&(L=false),N=requestAnimationFrame(ue);return}if(v.forEach((i,l)=>{let h=l*X*q,c=re(B(s,O+h,F+h,a));U&&!Z&&(A=Math.max(A,c),c=A),oe=c,i.style.strokeDashoffset=m==="reverse"?`${g[l]*c}`:`${g[l]*(1-c)}`,d&&(i.style.opacity=m==="reverse"?`${1-c}`:`${c}`),I&&E?i.style.stroke=Se(I,E,c):E&&(i.style.stroke=E),x!==null&&S!==null?i.style.strokeWidth=`${x+(S-x)*c}`:S!==null&&(i.style.strokeWidth=`${S}`),k!==null&&T!==null?i.style.fillOpacity=`${k+(T-k)*c}`:T!==null&&(i.style.fillOpacity=`${T}`),P&&i.tagName.toLowerCase()==="path"&&C[l]&&i.setAttribute("d",He(C[l],P,c)),l===0&&(ye?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(w=false);}),ee){let i=re(B(s,O,F,a));for(let l in ee){let h=parseFloat(l);i>=h&&!ae.has(h)&&(ae.add(h),ee[l]?.());}}!G&&B(s,O,F,a)>0&&(G=true,ge?.()),w&&!L?(L=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,L=false,ae.clear(),Pe();},ke))):!w&&!U&&(L=false),N=requestAnimationFrame(ue);}let be=new IntersectionObserver(t=>{t.forEach(s=>{ne=s.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:We,rootMargin:Ge}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{v.forEach((t,s)=>{g[s]=Ee(t),t.style.strokeDasharray=`${g[s]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),me>0?setTimeout(()=>be.observe(e),me):be.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),be.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),he?.remove();},replay(){A=-1,se=-1,le=-1,G=false,L=false,K=0,z=false,ae.clear(),clearTimeout(ie),Pe();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let s=Math.min(1,Math.max(0,t));oe=s,A=s,z=true,cancelAnimationFrame(N),qe(s,y);},getProgress(){return oe}}}function tt(e,r={}){let n=ce(e,r);return {update(o){n.destroy(),n=ce(e,o);},destroy(){n.destroy();}}}function rt(e={}){let r=null;function n(o){return r=ce(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}exports.createScrollDraw=rt;exports.scrollDraw=tt;
1
+ 'use strict';function Xe({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(o),u=0,p=[];for(let a=0;a<n;a++){let d=Math.pow(c,a);p.push(d),u+=d;}let h=[0],I=0;for(let a=0;a<n;a++)I+=p[a]/u,h.push(I);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=h[d+1]){let U=(a-h[d])/(h[d+1]-h[d]);if(d===0)return U*(2-U);let b=1-Math.pow(o,d);return b+(1-b)*(2*U-1)*(2*U-1)}return 1}}function Ue({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),c=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-c)*(2*Math.PI)/o)+1}var xe={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Xe(),elastic:Ue()};function Ee(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 Oe(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 Fe(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 $e(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 je(e,r,n){return Math.min(n,Math.max(r,e))}function X(e,r,n,o){return n===r?0:je((e-r)/(n-r)*o,0,1)}function Se(e,r,n,o,c){let u=Oe(e.top,e.height,r,o.element)-Fe(o.viewport,n),p=Oe(e.top,e.height,r,c.element)-Fe(c.viewport,n);return {tStart:u,tEnd:p}}function Ne(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 Me(e,r,n){let o=Ne(e),c=Ne(r);return !o||!c?e:`rgb(${Math.round(o[0]+(c[0]-o[0])*n)},${Math.round(o[1]+(c[1]-o[1])*n)},${Math.round(o[2]+(c[2]-o[2])*n)})`}function Re(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var He={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Je=0;function Ke(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Qe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Re("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Re("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ye(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 c(){let u=n==="x"?window.scrollX:window.scrollY,p=e-u,h=r-u,I=n==="x";o.innerHTML=`
2
+ <div style="position:absolute;${I?`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;${I?`left:${h}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${h}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",c,{passive:true}),c(),o}function We(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let p=parseFloat(u),h=o[c++]??p;return String(+(p+(h-p)*n).toFixed(4))})}function me(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:c=1,fade:u=false,easing:p="linear",trigger:h={},stagger:I=0,direction:a="forward",once:d=false,debug:U=false,axis:b="y",scrollContainer:pe,autoReverse:ee=false,delay:de=0,strokeColor:W,strokeWidth:V,fillOpacity:G,waypoints:te,velocityScale:re=false,threshold:Ve=0,rootMargin:Ge="0px",repeat:J=0,repeatDelay:ke=0,morphTo:C,clip:ye,native:ze=true,onProgress:he,onStart:ge,onComplete:K}=r,z=ye===true?"left":typeof ye=="string"?ye:false,ne=typeof p=="function"?p:xe[p]??xe.linear,Te=Ee(h.start??"top bottom"),Ae=Ee(h.end??"bottom top"),x=typeof pe=="string"?document.querySelector(pe):pe??null,O=Array.isArray(W)?W[0]:null,S=Array.isArray(W)?W[1]:typeof W=="string"?W:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,T=Array.isArray(G)?G[0]:null,A=Array.isArray(G)?G[1]:typeof G=="number"?G:null;function j(t){let s=t*100;switch(z){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 E=z?[]:Array.from(e.querySelectorAll(o)),w=[],F=[],N=0,R=0,P=false,q=false,H=0,se=false,D=-1,oe=-1,B=false,ie=0,Q=0,ae,be=null,le=new Set,ue=-1,De=performance.now();function Y(){return x?b==="x"?x.scrollLeft:x.scrollTop:b==="x"?window.scrollX:window.scrollY}function Le(){return x?b==="x"?x.clientWidth:x.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Pe(){let t=e.getBoundingClientRect(),s,l,g;if(x){let $=x.getBoundingClientRect();s=b==="x"?t.left-$.left+x.scrollLeft:t.top-$.top+x.scrollTop,l=b==="x"?t.width:t.height,g=Y();}else s=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,g=Y();let _=Se({top:s,height:l},g,Le(),Te,Ae);N=_.tStart,R=_.tEnd,U&&process.env.NODE_ENV!=="production"&&(be?.remove(),be=Ye(N,R,b));}function qe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),z){let l=s==="reverse"?1-t:t;e.style.clipPath=j(l);return}E.forEach((l,g)=>{l.style.strokeDashoffset=s==="reverse"?`${w[g]*t}`:`${w[g]*(1-t)}`,u&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),O&&S?l.style.stroke=Me(O,S,t):S&&(l.style.stroke=S),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),T!==null&&A!==null?l.style.fillOpacity=`${T+(A-T)*t}`:A!==null&&(l.style.fillOpacity=`${A}`),C&&l.tagName.toLowerCase()==="path"&&F[g]&&l.setAttribute("d",We(F[g],C,t));});}function Ie(){if(e.style.setProperty("--scroll-draw-progress","0"),z){e.style.clipPath=j(0);return}E.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${w[s]}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),C&&t.tagName.toLowerCase()==="path"&&F[s]&&t.setAttribute("d",F[s]);});}if(E.forEach(t=>{Qe(t);let s=$e(t);w.push(s),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?`${s}`:"0",u&&(t.style.opacity="1"),S&&(t.style.stroke=S),k!==null&&(t.style.strokeWidth=`${k}`),A!==null&&(t.style.fillOpacity=`${A}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?"0":`${s}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`));}),z){if(n)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Be(){return !(ze===false||!Ke()||!E.length||typeof p!="string"||!(p in He)||z||b!=="y"||x||c!==1||I!==0||d||ee||re!==false||C||te||J||de>0||he||ge||K||W!=null||V!=null||G!=null||(h.start??"top bottom").trim()!=="top bottom"||(h.end??"bottom top").trim()!=="bottom top")}function _e(){let t=`svg-scroll-draw-${++Je}`,s=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${s};`,_=`stroke-dashoffset:${l};`;u&&(g+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let $=document.createElement("style");$.setAttribute("data-svg-scroll-draw",""),$.textContent=`@keyframes ${t}{from{${g}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${He[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild($);function i(m,L){m.style.setProperty("--ssd-len",String(w[L])),m.style.strokeDasharray=`${w[L]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t);}E.forEach(i);let f=false,v=-1;function y(){if(v>=0)return v;let m=e.getBoundingClientRect(),{tStart:L,tEnd:Z}=Se({top:m.top,height:m.height},Y(),Le(),Te,Ae);return ne(X(Y(),L,Z,c))}return {destroy(){E.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),$.remove();},replay(){f=false,v=-1,E.forEach(i);},pause(){f=true,E.forEach(m=>{m.style.animationPlayState="paused";});},resume(){f&&(f=false,E.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let L=Math.min(1,Math.max(0,m));v=L,f=true,E.forEach((Z,Ce)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${w[Ce]*L}`:`${w[Ce]*(1-L)}`,u&&(Z.style.opacity=a==="reverse"?`${1-L}`:`${L}`);});},getProgress(){return y()}}}if(Be())return _e();Pe();function ce(){if(!se||B)return;let t=performance.now(),s=Y(),l=c;if(re!==false){let i=t-De,f=i>0?Math.abs(s-(ue<0?s:ue))/i:0;l=c*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=s,De=t;let g=ee?oe===-1||s>=oe?"forward":"reverse":a;oe=s;let _=R-N,$=true;if(z){let i=ne(X(s,N,R,l));d&&!ee&&(D=Math.max(D,i),i=D),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=g==="reverse"?1-i:i;e.style.clipPath=j(f),he?.(i),!q&&X(s,N,R,l)>0&&(q=true,ge?.()),i>=1&&!P?(P=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{D=-1,q=false,P=false,e.style.clipPath=j(0);},ke))):i<1&&!d&&(P=false),H=requestAnimationFrame(ce);return}if(E.forEach((i,f)=>{let v=f*I*_,y=ne(X(s,N+v,R+v,l));d&&!ee&&(D=Math.max(D,y),y=D),ie=y,i.style.strokeDashoffset=g==="reverse"?`${w[f]*y}`:`${w[f]*(1-y)}`,u&&(i.style.opacity=g==="reverse"?`${1-y}`:`${y}`),O&&S?i.style.stroke=Me(O,S,y):S&&(i.style.stroke=S),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),T!==null&&A!==null?i.style.fillOpacity=`${T+(A-T)*y}`:A!==null&&(i.style.fillOpacity=`${A}`),C&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",We(F[f],C,y)),f===0&&(he?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&($=false);}),te){let i=ne(X(s,N,R,l));for(let f in te){let v=parseFloat(f);i>=v&&!le.has(v)&&(le.add(v),te[f]?.());}}!q&&X(s,N,R,l)>0&&(q=true,ge?.()),$&&!P?(P=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{D=-1,q=false,P=false,le.clear(),Ie();},ke))):!$&&!d&&(P=false),H=requestAnimationFrame(ce);}let we=new IntersectionObserver(t=>{t.forEach(s=>{se=s.isIntersecting,se&&!B?H=requestAnimationFrame(ce):cancelAnimationFrame(H);});},{root:x??null,threshold:Ve,rootMargin:Ge}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{E.forEach((t,s)=>{w[s]=$e(t),t.style.strokeDasharray=`${w[s]}`;}),Pe();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),de>0?setTimeout(()=>we.observe(e),de):we.observe(e),{destroy(){cancelAnimationFrame(H),clearTimeout(ae),we.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),be?.remove();},replay(){D=-1,oe=-1,ue=-1,q=false,P=false,Q=0,B=false,le.clear(),clearTimeout(ae),Ie();},pause(){B=true,cancelAnimationFrame(H);},resume(){B&&(B=false,se&&(H=requestAnimationFrame(ce)));},seek(t){let s=Math.min(1,Math.max(0,t));ie=s,D=s,B=true,cancelAnimationFrame(H),qe(s,a);},getProgress(){return ie}}}function nt(e,r={}){let n=me(e,r);return {update(o){n.destroy(),n=me(e,o);},destroy(){n.destroy();}}}function st(e={}){let r=null;function n(o){return r=me(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}exports.createScrollDraw=st;exports.scrollDraw=nt;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface TriggerConfig {
3
3
  start?: string;
4
4
  end?: string;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface TriggerConfig {
3
3
  start?: string;
4
4
  end?: string;
@@ -1,3 +1,3 @@
1
- var we={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 $e(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 Ce(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 Oe(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 Ee(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 Xe(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:Xe((e-r)/(n-r)*o,0,1)}function xe(e,r,n,o,f){let d=Ce(e.top,e.height,r,o.element)-Oe(o.viewport,n),p=Ce(e.top,e.height,r,f.element)-Oe(f.viewport,n);return {tStart:d,tEnd:p}}function Fe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function Se(e,r,n){let o=Fe(e),f=Fe(r);return !o||!f?e:`rgb(${Math.round(o[0]+(f[0]-o[0])*n)},${Math.round(o[1]+(f[1]-o[1])*n)},${Math.round(o[2]+(f[2]-o[2])*n)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ue=0;function je(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Je(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ke(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 f(){let d=n==="x"?window.scrollX:window.scrollY,p=e-d,D=r-d,X=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`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;${X?`left:${D}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${D}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",f,{passive:true}),f(),o}function He(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),f=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let p=parseFloat(d),D=o[f++]??p;return String(+(p+(D-p)*n).toFixed(4))})}function ce(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:f=1,fade:d=false,easing:p="linear",trigger:D={},stagger:X=0,direction:y="forward",once:U=false,debug:Ve=false,axis:$="y",scrollContainer:pe,autoReverse:Z=false,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:We=0,rootMargin:Ge="0px",repeat:j=0,repeatDelay:ke=0,morphTo:P,clip:de,native:ze=true,onProgress:ye,onStart:ge,onComplete:J}=r,W=de===true?"left":typeof de=="string"?de:false,re=typeof p=="function"?p:we[p]??we.linear,Te=$e(D.start??"top bottom"),Ae=$e(D.end??"bottom top"),b=typeof pe=="string"?document.querySelector(pe):pe??null,I=Array.isArray(R)?R[0]:null,E=Array.isArray(R)?R[1]:typeof R=="string"?R:null,x=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,T=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(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 v=W?[]:Array.from(e.querySelectorAll(o)),g=[],C=[],O=0,F=0,L=false,G=false,N=0,ne=false,A=-1,se=-1,z=false,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Me=performance.now();function Q(){return b?$==="x"?b.scrollLeft:b.scrollTop:$==="x"?window.scrollX:window.scrollY}function De(){return b?$==="x"?b.clientWidth:b.clientHeight:$==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),s,a,m;if(b){let w=b.getBoundingClientRect();s=$==="x"?t.left-w.left+b.scrollLeft:t.top-w.top+b.scrollTop,a=$==="x"?t.width:t.height,m=Q();}else s=$==="x"?t.left:t.top,a=$==="x"?t.width:t.height,m=Q();let q=xe({top:s,height:a},m,De(),Te,Ae);O=q.tStart,F=q.tEnd,Ve&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=Ke(O,F,$));}function qe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=s==="reverse"?1-t:t;e.style.clipPath=_(a);return}v.forEach((a,m)=>{a.style.strokeDashoffset=s==="reverse"?`${g[m]*t}`:`${g[m]*(1-t)}`,d&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),I&&E?a.style.stroke=Se(I,E,t):E&&(a.style.stroke=E),x!==null&&S!==null?a.style.strokeWidth=`${x+(S-x)*t}`:S!==null&&(a.style.strokeWidth=`${S}`),k!==null&&T!==null?a.style.fillOpacity=`${k+(T-k)*t}`:T!==null&&(a.style.fillOpacity=`${T}`),P&&a.tagName.toLowerCase()==="path"&&C[m]&&a.setAttribute("d",He(C[m],P,t));});}function Pe(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,s)=>{t.style.strokeDasharray=`${g[s]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[s]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`),P&&t.tagName.toLowerCase()==="path"&&C[s]&&t.setAttribute("d",C[s]);});}if(v.forEach(t=>{Je(t);let s=Ee(t);g.push(s),t.tagName.toLowerCase()==="path"?C.push(t.getAttribute("d")??""):C.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?`${s}`:"0",d&&(t.style.opacity="1"),E&&(t.style.stroke=E),S!==null&&(t.style.strokeWidth=`${S}`),T!==null&&(t.style.fillOpacity=`${T}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?"0":`${s}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(n)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(n)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Be(){return !(ze===false||!je()||!v.length||typeof p!="string"||!(p in Re)||W||$!=="y"||b||f!==1||X!==0||U||Z||te!==false||P||ee||j||me>0||ye||ge||J||R!=null||H!=null||V!=null||(D.start??"top bottom").trim()!=="top bottom"||(D.end??"bottom top").trim()!=="bottom top")}function _e(){let t=`svg-scroll-draw-${++Ue}`,s=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",m=`stroke-dashoffset:${s};`,q=`stroke-dashoffset:${a};`;d&&(m+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${t}{from{${m}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(w);function i(u,M){u.style.setProperty("--ssd-len",String(g[M])),u.style.strokeDasharray=`${g[M]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t);}v.forEach(i);let l=false,h=-1;function c(){if(h>=0)return h;let u=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=xe({top:u.top,height:u.height},Q(),De(),Te,Ae);return re(B(Q(),M,Y,f))}return {destroy(){v.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),w.remove();},replay(){l=false,h=-1,v.forEach(i);},pause(){l=true,v.forEach(u=>{u.style.animationPlayState="paused";});},resume(){l&&(l=false,v.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let M=Math.min(1,Math.max(0,u));h=M,l=true,v.forEach((Y,Ie)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Ie]*M}`:`${g[Ie]*(1-M)}`,d&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`);});},getProgress(){return c()}}}if(Be())return _e();Le();function ue(){if(!ne||z)return;let t=performance.now(),s=Q(),a=f;if(te!==false){let i=t-Me,l=i>0?Math.abs(s-(le<0?s:le))/i:0;a=f*Math.max(.2,1+l*(typeof te=="number"?te:1)*.04);}le=s,Me=t;let m=Z?se===-1||s>=se?"forward":"reverse":y;se=s;let q=F-O,w=true;if(W){let i=re(B(s,O,F,a));U&&!Z&&(A=Math.max(A,i),i=A),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let l=m==="reverse"?1-i:i;e.style.clipPath=_(l),ye?.(i),!G&&B(s,O,F,a)>0&&(G=true,ge?.()),i>=1&&!L?(L=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,L=false,e.style.clipPath=_(0);},ke))):i<1&&!U&&(L=false),N=requestAnimationFrame(ue);return}if(v.forEach((i,l)=>{let h=l*X*q,c=re(B(s,O+h,F+h,a));U&&!Z&&(A=Math.max(A,c),c=A),oe=c,i.style.strokeDashoffset=m==="reverse"?`${g[l]*c}`:`${g[l]*(1-c)}`,d&&(i.style.opacity=m==="reverse"?`${1-c}`:`${c}`),I&&E?i.style.stroke=Se(I,E,c):E&&(i.style.stroke=E),x!==null&&S!==null?i.style.strokeWidth=`${x+(S-x)*c}`:S!==null&&(i.style.strokeWidth=`${S}`),k!==null&&T!==null?i.style.fillOpacity=`${k+(T-k)*c}`:T!==null&&(i.style.fillOpacity=`${T}`),P&&i.tagName.toLowerCase()==="path"&&C[l]&&i.setAttribute("d",He(C[l],P,c)),l===0&&(ye?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(w=false);}),ee){let i=re(B(s,O,F,a));for(let l in ee){let h=parseFloat(l);i>=h&&!ae.has(h)&&(ae.add(h),ee[l]?.());}}!G&&B(s,O,F,a)>0&&(G=true,ge?.()),w&&!L?(L=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,L=false,ae.clear(),Pe();},ke))):!w&&!U&&(L=false),N=requestAnimationFrame(ue);}let be=new IntersectionObserver(t=>{t.forEach(s=>{ne=s.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:We,rootMargin:Ge}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{v.forEach((t,s)=>{g[s]=Ee(t),t.style.strokeDasharray=`${g[s]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),me>0?setTimeout(()=>be.observe(e),me):be.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),be.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),he?.remove();},replay(){A=-1,se=-1,le=-1,G=false,L=false,K=0,z=false,ae.clear(),clearTimeout(ie),Pe();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let s=Math.min(1,Math.max(0,t));oe=s,A=s,z=true,cancelAnimationFrame(N),qe(s,y);},getProgress(){return oe}}}function tt(e,r={}){let n=ce(e,r);return {update(o){n.destroy(),n=ce(e,o);},destroy(){n.destroy();}}}function rt(e={}){let r=null;function n(o){return r=ce(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}export{rt as createScrollDraw,tt as scrollDraw};
1
+ function Xe({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(o),u=0,p=[];for(let a=0;a<n;a++){let d=Math.pow(c,a);p.push(d),u+=d;}let h=[0],I=0;for(let a=0;a<n;a++)I+=p[a]/u,h.push(I);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=h[d+1]){let U=(a-h[d])/(h[d+1]-h[d]);if(d===0)return U*(2-U);let b=1-Math.pow(o,d);return b+(1-b)*(2*U-1)*(2*U-1)}return 1}}function Ue({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),c=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-c)*(2*Math.PI)/o)+1}var xe={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Xe(),elastic:Ue()};function Ee(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 Oe(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 Fe(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 $e(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 je(e,r,n){return Math.min(n,Math.max(r,e))}function X(e,r,n,o){return n===r?0:je((e-r)/(n-r)*o,0,1)}function Se(e,r,n,o,c){let u=Oe(e.top,e.height,r,o.element)-Fe(o.viewport,n),p=Oe(e.top,e.height,r,c.element)-Fe(c.viewport,n);return {tStart:u,tEnd:p}}function Ne(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 Me(e,r,n){let o=Ne(e),c=Ne(r);return !o||!c?e:`rgb(${Math.round(o[0]+(c[0]-o[0])*n)},${Math.round(o[1]+(c[1]-o[1])*n)},${Math.round(o[2]+(c[2]-o[2])*n)})`}function Re(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var He={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Je=0;function Ke(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Qe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Re("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Re("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ye(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 c(){let u=n==="x"?window.scrollX:window.scrollY,p=e-u,h=r-u,I=n==="x";o.innerHTML=`
2
+ <div style="position:absolute;${I?`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;${I?`left:${h}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${h}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",c,{passive:true}),c(),o}function We(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let p=parseFloat(u),h=o[c++]??p;return String(+(p+(h-p)*n).toFixed(4))})}function me(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:c=1,fade:u=false,easing:p="linear",trigger:h={},stagger:I=0,direction:a="forward",once:d=false,debug:U=false,axis:b="y",scrollContainer:pe,autoReverse:ee=false,delay:de=0,strokeColor:W,strokeWidth:V,fillOpacity:G,waypoints:te,velocityScale:re=false,threshold:Ve=0,rootMargin:Ge="0px",repeat:J=0,repeatDelay:ke=0,morphTo:C,clip:ye,native:ze=true,onProgress:he,onStart:ge,onComplete:K}=r,z=ye===true?"left":typeof ye=="string"?ye:false,ne=typeof p=="function"?p:xe[p]??xe.linear,Te=Ee(h.start??"top bottom"),Ae=Ee(h.end??"bottom top"),x=typeof pe=="string"?document.querySelector(pe):pe??null,O=Array.isArray(W)?W[0]:null,S=Array.isArray(W)?W[1]:typeof W=="string"?W:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,T=Array.isArray(G)?G[0]:null,A=Array.isArray(G)?G[1]:typeof G=="number"?G:null;function j(t){let s=t*100;switch(z){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 E=z?[]:Array.from(e.querySelectorAll(o)),w=[],F=[],N=0,R=0,P=false,q=false,H=0,se=false,D=-1,oe=-1,B=false,ie=0,Q=0,ae,be=null,le=new Set,ue=-1,De=performance.now();function Y(){return x?b==="x"?x.scrollLeft:x.scrollTop:b==="x"?window.scrollX:window.scrollY}function Le(){return x?b==="x"?x.clientWidth:x.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Pe(){let t=e.getBoundingClientRect(),s,l,g;if(x){let $=x.getBoundingClientRect();s=b==="x"?t.left-$.left+x.scrollLeft:t.top-$.top+x.scrollTop,l=b==="x"?t.width:t.height,g=Y();}else s=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,g=Y();let _=Se({top:s,height:l},g,Le(),Te,Ae);N=_.tStart,R=_.tEnd,U&&process.env.NODE_ENV!=="production"&&(be?.remove(),be=Ye(N,R,b));}function qe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),z){let l=s==="reverse"?1-t:t;e.style.clipPath=j(l);return}E.forEach((l,g)=>{l.style.strokeDashoffset=s==="reverse"?`${w[g]*t}`:`${w[g]*(1-t)}`,u&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),O&&S?l.style.stroke=Me(O,S,t):S&&(l.style.stroke=S),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),T!==null&&A!==null?l.style.fillOpacity=`${T+(A-T)*t}`:A!==null&&(l.style.fillOpacity=`${A}`),C&&l.tagName.toLowerCase()==="path"&&F[g]&&l.setAttribute("d",We(F[g],C,t));});}function Ie(){if(e.style.setProperty("--scroll-draw-progress","0"),z){e.style.clipPath=j(0);return}E.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${w[s]}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),C&&t.tagName.toLowerCase()==="path"&&F[s]&&t.setAttribute("d",F[s]);});}if(E.forEach(t=>{Qe(t);let s=$e(t);w.push(s),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?`${s}`:"0",u&&(t.style.opacity="1"),S&&(t.style.stroke=S),k!==null&&(t.style.strokeWidth=`${k}`),A!==null&&(t.style.fillOpacity=`${A}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?"0":`${s}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`));}),z){if(n)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Be(){return !(ze===false||!Ke()||!E.length||typeof p!="string"||!(p in He)||z||b!=="y"||x||c!==1||I!==0||d||ee||re!==false||C||te||J||de>0||he||ge||K||W!=null||V!=null||G!=null||(h.start??"top bottom").trim()!=="top bottom"||(h.end??"bottom top").trim()!=="bottom top")}function _e(){let t=`svg-scroll-draw-${++Je}`,s=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${s};`,_=`stroke-dashoffset:${l};`;u&&(g+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let $=document.createElement("style");$.setAttribute("data-svg-scroll-draw",""),$.textContent=`@keyframes ${t}{from{${g}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${He[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild($);function i(m,L){m.style.setProperty("--ssd-len",String(w[L])),m.style.strokeDasharray=`${w[L]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t);}E.forEach(i);let f=false,v=-1;function y(){if(v>=0)return v;let m=e.getBoundingClientRect(),{tStart:L,tEnd:Z}=Se({top:m.top,height:m.height},Y(),Le(),Te,Ae);return ne(X(Y(),L,Z,c))}return {destroy(){E.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),$.remove();},replay(){f=false,v=-1,E.forEach(i);},pause(){f=true,E.forEach(m=>{m.style.animationPlayState="paused";});},resume(){f&&(f=false,E.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let L=Math.min(1,Math.max(0,m));v=L,f=true,E.forEach((Z,Ce)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${w[Ce]*L}`:`${w[Ce]*(1-L)}`,u&&(Z.style.opacity=a==="reverse"?`${1-L}`:`${L}`);});},getProgress(){return y()}}}if(Be())return _e();Pe();function ce(){if(!se||B)return;let t=performance.now(),s=Y(),l=c;if(re!==false){let i=t-De,f=i>0?Math.abs(s-(ue<0?s:ue))/i:0;l=c*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=s,De=t;let g=ee?oe===-1||s>=oe?"forward":"reverse":a;oe=s;let _=R-N,$=true;if(z){let i=ne(X(s,N,R,l));d&&!ee&&(D=Math.max(D,i),i=D),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=g==="reverse"?1-i:i;e.style.clipPath=j(f),he?.(i),!q&&X(s,N,R,l)>0&&(q=true,ge?.()),i>=1&&!P?(P=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{D=-1,q=false,P=false,e.style.clipPath=j(0);},ke))):i<1&&!d&&(P=false),H=requestAnimationFrame(ce);return}if(E.forEach((i,f)=>{let v=f*I*_,y=ne(X(s,N+v,R+v,l));d&&!ee&&(D=Math.max(D,y),y=D),ie=y,i.style.strokeDashoffset=g==="reverse"?`${w[f]*y}`:`${w[f]*(1-y)}`,u&&(i.style.opacity=g==="reverse"?`${1-y}`:`${y}`),O&&S?i.style.stroke=Me(O,S,y):S&&(i.style.stroke=S),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),T!==null&&A!==null?i.style.fillOpacity=`${T+(A-T)*y}`:A!==null&&(i.style.fillOpacity=`${A}`),C&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",We(F[f],C,y)),f===0&&(he?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&($=false);}),te){let i=ne(X(s,N,R,l));for(let f in te){let v=parseFloat(f);i>=v&&!le.has(v)&&(le.add(v),te[f]?.());}}!q&&X(s,N,R,l)>0&&(q=true,ge?.()),$&&!P?(P=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{D=-1,q=false,P=false,le.clear(),Ie();},ke))):!$&&!d&&(P=false),H=requestAnimationFrame(ce);}let we=new IntersectionObserver(t=>{t.forEach(s=>{se=s.isIntersecting,se&&!B?H=requestAnimationFrame(ce):cancelAnimationFrame(H);});},{root:x??null,threshold:Ve,rootMargin:Ge}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{E.forEach((t,s)=>{w[s]=$e(t),t.style.strokeDasharray=`${w[s]}`;}),Pe();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),de>0?setTimeout(()=>we.observe(e),de):we.observe(e),{destroy(){cancelAnimationFrame(H),clearTimeout(ae),we.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),be?.remove();},replay(){D=-1,oe=-1,ue=-1,q=false,P=false,Q=0,B=false,le.clear(),clearTimeout(ae),Ie();},pause(){B=true,cancelAnimationFrame(H);},resume(){B&&(B=false,se&&(H=requestAnimationFrame(ce)));},seek(t){let s=Math.min(1,Math.max(0,t));ie=s,D=s,B=true,cancelAnimationFrame(H),qe(s,a);},getProgress(){return ie}}}function nt(e,r={}){let n=me(e,r);return {update(o){n.destroy(),n=me(e,o);},destroy(){n.destroy();}}}function st(e={}){let r=null;function n(o){return r=me(o,e),{destroy(){r?.destroy(),r=null;}}}return {action:n,getInstance:()=>r}}export{st as createScrollDraw,nt as scrollDraw};
@@ -1 +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;
1
+ 'use strict';function U({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,t)),u=Math.sqrt(o),c=0,d=[];for(let s=0;s<r;s++){let i=Math.pow(u,s);d.push(i),c+=i;}let f=[0],b=0;for(let s=0;s<r;s++)b+=d[s]/c,f.push(b);return s=>{if(s<=0)return 0;if(s>=1)return 1;for(let i=0;i<r;i++)if(s<=f[i+1]){let w=(s-f[i])/(f[i+1]-f[i]);if(i===0)return w*(2-w);let M=1-Math.pow(o,i);return M+(1-M)*(2*w-1)*(2*w-1)}return 1}}function Z({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),o=Math.max(.1,t),u=r<=1?o/4:o/(2*Math.PI)*Math.asin(1/r);return c=>c<=0?0:c>=1?1:r*Math.pow(2,-10*c)*Math.sin((c-u)*(2*Math.PI)/o)+1}var $={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:U(),elastic:Z()};function F(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",o="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function V(e,t,r,o){switch(o){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function B(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function P(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function _(e,t,r){return Math.min(r,Math.max(t,e))}function W(e,t,r,o){return r===t?0:_((e-t)/(r-t)*o,0,1)}function X(e,t,r,o,u){let c=V(e.top,e.height,t,o.element)-B(o.viewport,r),d=V(e.top,e.height,t,u.element)-B(u.viewport,r);return {tStart:c,tEnd:d}}function ee(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let o=typeof e=="string"?document.querySelector(e):e;if(!o)return console.warn("[svg-scroll-draw/timeline] Container not found:",e),r;let u=o,{trigger:c={},speed:d=1,once:f=false,axis:b="y",tracks:s,onComplete:i}=t,w=F(c.start??"top bottom"),M=F(c.end??"bottom top"),A=s.map(n=>{let m=typeof n.easing=="function"?n.easing:$[n.easing??"linear"]??$.linear,l=Array.from(u.querySelectorAll(n.selector)),a=l.map(p=>P(p));return l.forEach((p,S)=>{p.style.strokeDasharray=`${a[S]}`,p.style.strokeDashoffset=`${a[S]}`,n.fade&&(p.style.opacity="0");}),{...n,elements:l,lengths:a,easeFn:m}}),L=0,k=0,E=false,h=false,g=0,I=false,y=-1,x=0;function q(){return b==="x"?window.scrollX:window.scrollY}function j(){return b==="x"?window.innerWidth:window.innerHeight}function z(){let n=u.getBoundingClientRect(),m=q(),l=b==="x"?n.left:n.top,a=b==="x"?n.width:n.height,p=X({top:l,height:a},m,j(),w,M);L=p.tStart,k=p.tEnd;}function C(n){u.style.setProperty("--scroll-draw-progress",String(n)),A.forEach(({elements:m,lengths:l,from:a,to:p,easeFn:S,fade:J})=>{let N=p-a,K=N>0?Math.min(1,Math.max(0,(n-a)/N)):0,R=S(K);m.forEach((O,Q)=>{O.style.strokeDashoffset=`${l[Q]*(1-R)}`,J&&(O.style.opacity=String(R));});});}function v(){if(!E||h)return;let n=W(q(),L,k,d);f&&(y=Math.max(y,n),n=y),x=n,C(n),n>=1&&!I?(I=true,i?.()):n<1&&!f&&(I=false),g=requestAnimationFrame(v);}z();let G=new IntersectionObserver(n=>{n.forEach(m=>{E=m.isIntersecting,E&&!h?g=requestAnimationFrame(v):cancelAnimationFrame(g);});},{threshold:0});G.observe(u);let D;function T(){clearTimeout(D),D=setTimeout(()=>{A.forEach(({elements:n,lengths:m})=>{n.forEach((l,a)=>{m[a]=P(l),l.style.strokeDasharray=`${m[a]}`;});}),z();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),{destroy(){cancelAnimationFrame(g),clearTimeout(D),G.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T);},replay(){y=-1,I=false,h=false,A.forEach(({elements:n,lengths:m,fade:l})=>{n.forEach((a,p)=>{a.style.strokeDashoffset=`${m[p]}`,l&&(a.style.opacity="0");});}),u.style.setProperty("--scroll-draw-progress","0");},pause(){h=true,cancelAnimationFrame(g);},resume(){h&&(h=false,E&&(g=requestAnimationFrame(v)));},seek(n){x=Math.min(1,Math.max(0,n)),y=x,h=true,cancelAnimationFrame(g),C(x);},getProgress(){return x}}}exports.scrollDrawTimeline=ee;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface ScrollDrawInstance {
3
3
  destroy: () => void;
4
4
  /** Reset and replay the animation from the beginning. */
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface ScrollDrawInstance {
3
3
  destroy: () => void;
4
4
  /** Reset and replay the animation from the beginning. */
@@ -1 +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
+ function U({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,t)),u=Math.sqrt(o),c=0,d=[];for(let s=0;s<r;s++){let i=Math.pow(u,s);d.push(i),c+=i;}let f=[0],b=0;for(let s=0;s<r;s++)b+=d[s]/c,f.push(b);return s=>{if(s<=0)return 0;if(s>=1)return 1;for(let i=0;i<r;i++)if(s<=f[i+1]){let w=(s-f[i])/(f[i+1]-f[i]);if(i===0)return w*(2-w);let M=1-Math.pow(o,i);return M+(1-M)*(2*w-1)*(2*w-1)}return 1}}function Z({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),o=Math.max(.1,t),u=r<=1?o/4:o/(2*Math.PI)*Math.asin(1/r);return c=>c<=0?0:c>=1?1:r*Math.pow(2,-10*c)*Math.sin((c-u)*(2*Math.PI)/o)+1}var $={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:U(),elastic:Z()};function F(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",o="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:o}}function V(e,t,r,o){switch(o){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function B(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function P(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(r+o)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function _(e,t,r){return Math.min(r,Math.max(t,e))}function W(e,t,r,o){return r===t?0:_((e-t)/(r-t)*o,0,1)}function X(e,t,r,o,u){let c=V(e.top,e.height,t,o.element)-B(o.viewport,r),d=V(e.top,e.height,t,u.element)-B(u.viewport,r);return {tStart:c,tEnd:d}}function ee(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let o=typeof e=="string"?document.querySelector(e):e;if(!o)return console.warn("[svg-scroll-draw/timeline] Container not found:",e),r;let u=o,{trigger:c={},speed:d=1,once:f=false,axis:b="y",tracks:s,onComplete:i}=t,w=F(c.start??"top bottom"),M=F(c.end??"bottom top"),A=s.map(n=>{let m=typeof n.easing=="function"?n.easing:$[n.easing??"linear"]??$.linear,l=Array.from(u.querySelectorAll(n.selector)),a=l.map(p=>P(p));return l.forEach((p,S)=>{p.style.strokeDasharray=`${a[S]}`,p.style.strokeDashoffset=`${a[S]}`,n.fade&&(p.style.opacity="0");}),{...n,elements:l,lengths:a,easeFn:m}}),L=0,k=0,E=false,h=false,g=0,I=false,y=-1,x=0;function q(){return b==="x"?window.scrollX:window.scrollY}function j(){return b==="x"?window.innerWidth:window.innerHeight}function z(){let n=u.getBoundingClientRect(),m=q(),l=b==="x"?n.left:n.top,a=b==="x"?n.width:n.height,p=X({top:l,height:a},m,j(),w,M);L=p.tStart,k=p.tEnd;}function C(n){u.style.setProperty("--scroll-draw-progress",String(n)),A.forEach(({elements:m,lengths:l,from:a,to:p,easeFn:S,fade:J})=>{let N=p-a,K=N>0?Math.min(1,Math.max(0,(n-a)/N)):0,R=S(K);m.forEach((O,Q)=>{O.style.strokeDashoffset=`${l[Q]*(1-R)}`,J&&(O.style.opacity=String(R));});});}function v(){if(!E||h)return;let n=W(q(),L,k,d);f&&(y=Math.max(y,n),n=y),x=n,C(n),n>=1&&!I?(I=true,i?.()):n<1&&!f&&(I=false),g=requestAnimationFrame(v);}z();let G=new IntersectionObserver(n=>{n.forEach(m=>{E=m.isIntersecting,E&&!h?g=requestAnimationFrame(v):cancelAnimationFrame(g);});},{threshold:0});G.observe(u);let D;function T(){clearTimeout(D),D=setTimeout(()=>{A.forEach(({elements:n,lengths:m})=>{n.forEach((l,a)=>{m[a]=P(l),l.style.strokeDasharray=`${m[a]}`;});}),z();},150);}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),{destroy(){cancelAnimationFrame(g),clearTimeout(D),G.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T);},replay(){y=-1,I=false,h=false,A.forEach(({elements:n,lengths:m,fade:l})=>{n.forEach((a,p)=>{a.style.strokeDashoffset=`${m[p]}`,l&&(a.style.opacity="0");});}),u.style.setProperty("--scroll-draw-progress","0");},pause(){h=true,cancelAnimationFrame(g);},resume(){h&&(h=false,E&&(g=requestAnimationFrame(v)));},seek(n){x=Math.min(1,Math.max(0,n)),y=x,h=true,cancelAnimationFrame(g),C(x);},getProgress(){return x}}}export{ee as scrollDrawTimeline};
@@ -1,3 +1,3 @@
1
- 'use strict';var vue=require('vue');var ve={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 we(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[s="top",n="bottom"]=r.split(/\s+/).filter(Boolean);return {element:s,viewport:n}}function Oe(e,r,s,n){switch(n){case "top":return e+s;case "center":return e+s+r/2;case "bottom":return e+s+r;default:return e+s}}function Fe(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 Se(e){let r=e.tagName.toLowerCase();if(r==="rect"){let s=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(s+n)}if(r==="circle"){let s=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*s}return e.getTotalLength()}function Je(e,r,s){return Math.min(s,Math.max(r,e))}function q(e,r,s,n){return s===r?0:Je((e-r)/(s-r)*n,0,1)}function $e(e,r,s,n,l){let d=Oe(e.top,e.height,r,n.element)-Fe(n.viewport,s),m=Oe(e.top,e.height,r,l.element)-Fe(l.viewport,s);return {tStart:d,tEnd:m}}function Ie(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 s=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(s)return [parseInt(s[1],16),parseInt(s[2],16),parseInt(s[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 Ee(e,r,s){let n=Ie(e),l=Ie(r);return !n||!l?e:`rgb(${Math.round(n[0]+(l[0]-n[0])*s)},${Math.round(n[1]+(l[1]-n[1])*s)},${Math.round(n[2]+(l[2]-n[2])*s)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ke=0;function Qe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ye(e){let r=e.getAttribute("stroke"),s=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):s&&s!=="none"&&s!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ze(e,r,s){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 l(){let d=s==="x"?window.scrollX:window.scrollY,m=e-d,D=r-d,U=s==="x";n.innerHTML=`
2
- <div style="position:absolute;${U?`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;${U?`left:${D}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${D}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",l,{passive:true}),l(),n}function He(e,r,s){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let m=parseFloat(d),D=n[l++]??m;return String(+(m+(D-m)*s).toFixed(4))})}function xe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:n="path, polyline, line, polygon, rect, circle",speed:l=1,fade:d=false,easing:m="linear",trigger:D={},stagger:U=0,direction:y="forward",once:X=false,debug:ze=false,axis:S="y",scrollContainer:ce,autoReverse:Z=false,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:Be=0,rootMargin:qe="0px",repeat:j=0,repeatDelay:ke=0,morphTo:L,clip:pe,native:_e=true,onProgress:de,onStart:ye,onComplete:J}=r,W=pe===true?"left":typeof pe=="string"?pe:false,re=typeof m=="function"?m:ve[m]??ve.linear,Te=we(D.start??"top bottom"),Ae=we(D.end??"bottom top"),b=typeof ce=="string"?document.querySelector(ce):ce??null,C=Array.isArray(R)?R[0]:null,$=Array.isArray(R)?R[1]:typeof R=="string"?R:null,E=Array.isArray(H)?H[0]:null,x=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,T=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let o=t*100;switch(W){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let v=W?[]:Array.from(e.querySelectorAll(n)),g=[],O=[],F=0,I=0,P=false,G=false,N=0,ne=false,A=-1,se=-1,z=false,oe=0,K=0,ie,ge=null,ae=new Set,le=-1,Me=performance.now();function Q(){return b?S==="x"?b.scrollLeft:b.scrollTop:S==="x"?window.scrollX:window.scrollY}function De(){return b?S==="x"?b.clientWidth:b.clientHeight:S==="x"?window.innerWidth:window.innerHeight}function Pe(){let t=e.getBoundingClientRect(),o,a,p;if(b){let w=b.getBoundingClientRect();o=S==="x"?t.left-w.left+b.scrollLeft:t.top-w.top+b.scrollTop,a=S==="x"?t.width:t.height,p=Q();}else o=S==="x"?t.left:t.top,a=S==="x"?t.width:t.height,p=Q();let B=$e({top:o,height:a},p,De(),Te,Ae);F=B.tStart,I=B.tEnd,ze&&process.env.NODE_ENV!=="production"&&(ge?.remove(),ge=Ze(F,I,S));}function Ue(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=o==="reverse"?1-t:t;e.style.clipPath=_(a);return}v.forEach((a,p)=>{a.style.strokeDashoffset=o==="reverse"?`${g[p]*t}`:`${g[p]*(1-t)}`,d&&(a.style.opacity=o==="reverse"?`${1-t}`:`${t}`),C&&$?a.style.stroke=Ee(C,$,t):$&&(a.style.stroke=$),E!==null&&x!==null?a.style.strokeWidth=`${E+(x-E)*t}`:x!==null&&(a.style.strokeWidth=`${x}`),k!==null&&T!==null?a.style.fillOpacity=`${k+(T-k)*t}`:T!==null&&(a.style.fillOpacity=`${T}`),L&&a.tagName.toLowerCase()==="path"&&O[p]&&a.setAttribute("d",He(O[p],L,t));});}function Le(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,o)=>{t.style.strokeDasharray=`${g[o]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[o]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),E!==null&&(t.style.strokeWidth=`${E}`),k!==null&&(t.style.fillOpacity=`${k}`),L&&t.tagName.toLowerCase()==="path"&&O[o]&&t.setAttribute("d",O[o]);});}if(v.forEach(t=>{Ye(t);let o=Se(t);g.push(o),t.tagName.toLowerCase()==="path"?O.push(t.getAttribute("d")??""):O.push(""),s?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?`${o}`:"0",d&&(t.style.opacity="1"),$&&(t.style.stroke=$),x!==null&&(t.style.strokeWidth=`${x}`),T!==null&&(t.style.fillOpacity=`${T}`),L&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",L)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?"0":`${o}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),E!==null&&(t.style.strokeWidth=`${E}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(s)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(s)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Xe(){return !(_e===false||!Qe()||!v.length||typeof m!="string"||!(m in Re)||W||S!=="y"||b||l!==1||U!==0||X||Z||te!==false||L||ee||j||me>0||de||ye||J||R!=null||H!=null||V!=null||(D.start??"top bottom").trim()!=="top bottom"||(D.end??"bottom top").trim()!=="bottom top")}function je(){let t=`svg-scroll-draw-${++Ke}`,o=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",p=`stroke-dashoffset:${o};`,B=`stroke-dashoffset:${a};`;d&&(p+=`opacity:${y==="reverse"?1:0};`,B+=`opacity:${y==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${t}{from{${p}}to{${B}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[m]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(w);function i(f,M){f.style.setProperty("--ssd-len",String(g[M])),f.style.strokeDasharray=`${g[M]}`,f.style.strokeDashoffset="",f.style.opacity="",f.style.animationPlayState="",f.classList.add(t);}v.forEach(i);let u=false,h=-1;function c(){if(h>=0)return h;let f=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=$e({top:f.top,height:f.height},Q(),De(),Te,Ae);return re(q(Q(),M,Y,l))}return {destroy(){v.forEach(f=>{f.classList.remove(t),f.style.removeProperty("--ssd-len"),f.style.animationPlayState="";}),w.remove();},replay(){u=false,h=-1,v.forEach(i);},pause(){u=true,v.forEach(f=>{f.style.animationPlayState="paused";});},resume(){u&&(u=false,v.forEach(f=>{f.style.animationPlayState="running";}));},seek(f){let M=Math.min(1,Math.max(0,f));h=M,u=true,v.forEach((Y,Ce)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Ce]*M}`:`${g[Ce]*(1-M)}`,d&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`);});},getProgress(){return c()}}}if(Xe())return je();Pe();function ue(){if(!ne||z)return;let t=performance.now(),o=Q(),a=l;if(te!==false){let i=t-Me,u=i>0?Math.abs(o-(le<0?o:le))/i:0;a=l*Math.max(.2,1+u*(typeof te=="number"?te:1)*.04);}le=o,Me=t;let p=Z?se===-1||o>=se?"forward":"reverse":y;se=o;let B=I-F,w=true;if(W){let i=re(q(o,F,I,a));X&&!Z&&(A=Math.max(A,i),i=A),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let u=p==="reverse"?1-i:i;e.style.clipPath=_(u),de?.(i),!G&&q(o,F,I,a)>0&&(G=true,ye?.()),i>=1&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,P=false,e.style.clipPath=_(0);},ke))):i<1&&!X&&(P=false),N=requestAnimationFrame(ue);return}if(v.forEach((i,u)=>{let h=u*U*B,c=re(q(o,F+h,I+h,a));X&&!Z&&(A=Math.max(A,c),c=A),oe=c,i.style.strokeDashoffset=p==="reverse"?`${g[u]*c}`:`${g[u]*(1-c)}`,d&&(i.style.opacity=p==="reverse"?`${1-c}`:`${c}`),C&&$?i.style.stroke=Ee(C,$,c):$&&(i.style.stroke=$),E!==null&&x!==null?i.style.strokeWidth=`${E+(x-E)*c}`:x!==null&&(i.style.strokeWidth=`${x}`),k!==null&&T!==null?i.style.fillOpacity=`${k+(T-k)*c}`:T!==null&&(i.style.fillOpacity=`${T}`),L&&i.tagName.toLowerCase()==="path"&&O[u]&&i.setAttribute("d",He(O[u],L,c)),u===0&&(de?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(w=false);}),ee){let i=re(q(o,F,I,a));for(let u in ee){let h=parseFloat(u);i>=h&&!ae.has(h)&&(ae.add(h),ee[u]?.());}}!G&&q(o,F,I,a)>0&&(G=true,ye?.()),w&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,P=false,ae.clear(),Le();},ke))):!w&&!X&&(P=false),N=requestAnimationFrame(ue);}let he=new IntersectionObserver(t=>{t.forEach(o=>{ne=o.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:Be,rootMargin:qe}),be;function fe(){clearTimeout(be),be=setTimeout(()=>{v.forEach((t,o)=>{g[o]=Se(t),t.style.strokeDasharray=`${g[o]}`;}),Pe();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),me>0?setTimeout(()=>he.observe(e),me):he.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),he.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(be),ge?.remove();},replay(){A=-1,se=-1,le=-1,G=false,P=false,K=0,z=false,ae.clear(),clearTimeout(ie),Le();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let o=Math.min(1,Math.max(0,t));oe=o,A=o,z=true,cancelAnimationFrame(N),Ue(o,y);},getProgress(){return oe}}}function at(e={}){let r=vue.ref(null);return vue.onMounted(()=>{if(!r.value)return;let s=xe(r.value,e);vue.onUnmounted(()=>s.destroy());}),r}var lt=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 s=vue.ref(null);return vue.onMounted(()=>{if(!s.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 l=xe(s.value,n);vue.onUnmounted(()=>l.destroy());}),()=>vue.h("div",{ref:s},r.default?.())}});exports.ScrollDraw=lt;exports.useScrollDraw=at;
1
+ 'use strict';var vue=require('vue');function Je({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),u=Math.sqrt(s),c=0,p=[];for(let a=0;a<n;a++){let d=Math.pow(u,a);p.push(d),c+=d;}let g=[0],C=0;for(let a=0;a<n;a++)C+=p[a]/c,g.push(C);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=g[d+1]){let X=(a-g[d])/(g[d+1]-g[d]);if(d===0)return X*(2-X);let b=1-Math.pow(s,d);return b+(1-b)*(2*X-1)*(2*X-1)}return 1}}function Ke({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),u=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return c=>c<=0?0:c>=1?1:n*Math.pow(2,-10*c)*Math.sin((c-u)*(2*Math.PI)/s)+1}var ve={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Je(),elastic:Ke()};function Se(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 Ie(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 Fe(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 xe(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 Qe(e,r,n){return Math.min(n,Math.max(r,e))}function U(e,r,n,s){return n===r?0:Qe((e-r)/(n-r)*s,0,1)}function Ee(e,r,n,s,u){let c=Ie(e.top,e.height,r,s.element)-Fe(s.viewport,n),p=Ie(e.top,e.height,r,u.element)-Fe(u.viewport,n);return {tStart:c,tEnd:p}}function Ne(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function $e(e,r,n){let s=Ne(e),u=Ne(r);return !s||!u?e:`rgb(${Math.round(s[0]+(u[0]-s[0])*n)},${Math.round(s[1]+(u[1]-s[1])*n)},${Math.round(s[2]+(u[2]-s[2])*n)})`}function Re(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var He={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ye=0;function Ze(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function et(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Re("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Re("Element has a fill \u2014 it may obscure the stroke animation.",e);}function tt(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function u(){let c=n==="x"?window.scrollX:window.scrollY,p=e-c,g=r-c,C=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${C?`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;${C?`left:${g}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${g}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(s),window.addEventListener("scroll",u,{passive:true}),u(),s}function We(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let p=parseFloat(c),g=s[u++]??p;return String(+(p+(g-p)*n).toFixed(4))})}function Me(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:u=1,fade:c=false,easing:p="linear",trigger:g={},stagger:C=0,direction:a="forward",once:d=false,debug:X=false,axis:b="y",scrollContainer:me,autoReverse:ee=false,delay:pe=0,strokeColor:W,strokeWidth:V,fillOpacity:B,waypoints:te,velocityScale:re=false,threshold:ze=0,rootMargin:qe="0px",repeat:J=0,repeatDelay:ke=0,morphTo:O,clip:de,native:_e=true,onProgress:ye,onStart:ge,onComplete:K}=r,G=de===true?"left":typeof de=="string"?de:false,ne=typeof p=="function"?p:ve[p]??ve.linear,Te=Se(g.start??"top bottom"),Ae=Se(g.end??"bottom top"),S=typeof me=="string"?document.querySelector(me):me??null,I=Array.isArray(W)?W[0]:null,$=Array.isArray(W)?W[1]:typeof W=="string"?W:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,T=Array.isArray(B)?B[0]:null,A=Array.isArray(B)?B[1]:typeof B=="number"?B:null;function j(t){let o=t*100;switch(G){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let x=G?[]:Array.from(e.querySelectorAll(s)),w=[],F=[],N=0,R=0,L=false,z=false,H=0,se=false,P=-1,oe=-1,q=false,ie=0,Q=0,ae,he=null,le=new Set,ue=-1,Pe=performance.now();function Y(){return S?b==="x"?S.scrollLeft:S.scrollTop:b==="x"?window.scrollX:window.scrollY}function De(){return S?b==="x"?S.clientWidth:S.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),o,l,h;if(S){let E=S.getBoundingClientRect();o=b==="x"?t.left-E.left+S.scrollLeft:t.top-E.top+S.scrollTop,l=b==="x"?t.width:t.height,h=Y();}else o=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,h=Y();let _=Ee({top:o,height:l},h,De(),Te,Ae);N=_.tStart,R=_.tEnd,X&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=tt(N,R,b));}function Ue(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),G){let l=o==="reverse"?1-t:t;e.style.clipPath=j(l);return}x.forEach((l,h)=>{l.style.strokeDashoffset=o==="reverse"?`${w[h]*t}`:`${w[h]*(1-t)}`,c&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),I&&$?l.style.stroke=$e(I,$,t):$&&(l.style.stroke=$),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),T!==null&&A!==null?l.style.fillOpacity=`${T+(A-T)*t}`:A!==null&&(l.style.fillOpacity=`${A}`),O&&l.tagName.toLowerCase()==="path"&&F[h]&&l.setAttribute("d",We(F[h],O,t));});}function Ce(){if(e.style.setProperty("--scroll-draw-progress","0"),G){e.style.clipPath=j(0);return}x.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${w[o]}`,c?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),O&&t.tagName.toLowerCase()==="path"&&F[o]&&t.setAttribute("d",F[o]);});}if(x.forEach(t=>{et(t);let o=xe(t);w.push(o),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?`${o}`:"0",c&&(t.style.opacity="1"),$&&(t.style.stroke=$),k!==null&&(t.style.strokeWidth=`${k}`),A!==null&&(t.style.fillOpacity=`${A}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?"0":`${o}`,c?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`));}),G){if(n)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Xe(){return !(_e===false||!Ze()||!x.length||typeof p!="string"||!(p in He)||G||b!=="y"||S||u!==1||C!==0||d||ee||re!==false||O||te||J||pe>0||ye||ge||K||W!=null||V!=null||B!=null||(g.start??"top bottom").trim()!=="top bottom"||(g.end??"bottom top").trim()!=="bottom top")}function je(){let t=`svg-scroll-draw-${++Ye}`,o=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",h=`stroke-dashoffset:${o};`,_=`stroke-dashoffset:${l};`;c&&(h+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let E=document.createElement("style");E.setAttribute("data-svg-scroll-draw",""),E.textContent=`@keyframes ${t}{from{${h}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${He[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(E);function i(m,D){m.style.setProperty("--ssd-len",String(w[D])),m.style.strokeDasharray=`${w[D]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t);}x.forEach(i);let f=false,v=-1;function y(){if(v>=0)return v;let m=e.getBoundingClientRect(),{tStart:D,tEnd:Z}=Ee({top:m.top,height:m.height},Y(),De(),Te,Ae);return ne(U(Y(),D,Z,u))}return {destroy(){x.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),E.remove();},replay(){f=false,v=-1,x.forEach(i);},pause(){f=true,x.forEach(m=>{m.style.animationPlayState="paused";});},resume(){f&&(f=false,x.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let D=Math.min(1,Math.max(0,m));v=D,f=true,x.forEach((Z,Oe)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${w[Oe]*D}`:`${w[Oe]*(1-D)}`,c&&(Z.style.opacity=a==="reverse"?`${1-D}`:`${D}`);});},getProgress(){return y()}}}if(Xe())return je();Le();function ce(){if(!se||q)return;let t=performance.now(),o=Y(),l=u;if(re!==false){let i=t-Pe,f=i>0?Math.abs(o-(ue<0?o:ue))/i:0;l=u*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=o,Pe=t;let h=ee?oe===-1||o>=oe?"forward":"reverse":a;oe=o;let _=R-N,E=true;if(G){let i=ne(U(o,N,R,l));d&&!ee&&(P=Math.max(P,i),i=P),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=h==="reverse"?1-i:i;e.style.clipPath=j(f),ye?.(i),!z&&U(o,N,R,l)>0&&(z=true,ge?.()),i>=1&&!L?(L=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,z=false,L=false,e.style.clipPath=j(0);},ke))):i<1&&!d&&(L=false),H=requestAnimationFrame(ce);return}if(x.forEach((i,f)=>{let v=f*C*_,y=ne(U(o,N+v,R+v,l));d&&!ee&&(P=Math.max(P,y),y=P),ie=y,i.style.strokeDashoffset=h==="reverse"?`${w[f]*y}`:`${w[f]*(1-y)}`,c&&(i.style.opacity=h==="reverse"?`${1-y}`:`${y}`),I&&$?i.style.stroke=$e(I,$,y):$&&(i.style.stroke=$),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),T!==null&&A!==null?i.style.fillOpacity=`${T+(A-T)*y}`:A!==null&&(i.style.fillOpacity=`${A}`),O&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",We(F[f],O,y)),f===0&&(ye?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(E=false);}),te){let i=ne(U(o,N,R,l));for(let f in te){let v=parseFloat(f);i>=v&&!le.has(v)&&(le.add(v),te[f]?.());}}!z&&U(o,N,R,l)>0&&(z=true,ge?.()),E&&!L?(L=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,z=false,L=false,le.clear(),Ce();},ke))):!E&&!d&&(L=false),H=requestAnimationFrame(ce);}let be=new IntersectionObserver(t=>{t.forEach(o=>{se=o.isIntersecting,se&&!q?H=requestAnimationFrame(ce):cancelAnimationFrame(H);});},{root:S??null,threshold:ze,rootMargin:qe}),we;function fe(){clearTimeout(we),we=setTimeout(()=>{x.forEach((t,o)=>{w[o]=xe(t),t.style.strokeDasharray=`${w[o]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),pe>0?setTimeout(()=>be.observe(e),pe):be.observe(e),{destroy(){cancelAnimationFrame(H),clearTimeout(ae),be.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(we),he?.remove();},replay(){P=-1,oe=-1,ue=-1,z=false,L=false,Q=0,q=false,le.clear(),clearTimeout(ae),Ce();},pause(){q=true,cancelAnimationFrame(H);},resume(){q&&(q=false,se&&(H=requestAnimationFrame(ce)));},seek(t){let o=Math.min(1,Math.max(0,t));ie=o,P=o,q=true,cancelAnimationFrame(H),Ue(o,a);},getProgress(){return ie}}}function ut(e={}){let r=vue.ref(null);return vue.onMounted(()=>{if(!r.value)return;let n=Me(r.value,e);vue.onUnmounted(()=>n.destroy());}),r}var ct=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 n=vue.ref(null);return vue.onMounted(()=>{if(!n.value)return;let s={};e.selector!=null&&(s.selector=e.selector),e.speed!=null&&(s.speed=e.speed),e.fade!=null&&(s.fade=e.fade),e.stagger!=null&&(s.stagger=e.stagger),e.easing!=null&&(s.easing=e.easing),e.direction!=null&&(s.direction=e.direction),e.trigger!=null&&(s.trigger=e.trigger),e.once!=null&&(s.once=e.once),e.debug!=null&&(s.debug=e.debug),e.onProgress!=null&&(s.onProgress=e.onProgress),e.onStart!=null&&(s.onStart=e.onStart),e.onComplete!=null&&(s.onComplete=e.onComplete);let u=Me(n.value,s);vue.onUnmounted(()=>u.destroy());}),()=>vue.h("div",{ref:n},r.default?.())}});exports.ScrollDraw=ct;exports.useScrollDraw=ut;
@@ -1,6 +1,6 @@
1
1
  import * as vue from 'vue';
2
2
 
3
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
3
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
4
4
  interface TriggerConfig {
5
5
  start?: string;
6
6
  end?: string;
@@ -1,6 +1,6 @@
1
1
  import * as vue from 'vue';
2
2
 
3
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
3
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
4
4
  interface TriggerConfig {
5
5
  start?: string;
6
6
  end?: string;
@@ -1,3 +1,3 @@
1
- import {defineComponent,ref,onMounted,onUnmounted,h}from'vue';var ve={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 we(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[s="top",n="bottom"]=r.split(/\s+/).filter(Boolean);return {element:s,viewport:n}}function Oe(e,r,s,n){switch(n){case "top":return e+s;case "center":return e+s+r/2;case "bottom":return e+s+r;default:return e+s}}function Fe(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 Se(e){let r=e.tagName.toLowerCase();if(r==="rect"){let s=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(s+n)}if(r==="circle"){let s=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*s}return e.getTotalLength()}function Je(e,r,s){return Math.min(s,Math.max(r,e))}function q(e,r,s,n){return s===r?0:Je((e-r)/(s-r)*n,0,1)}function $e(e,r,s,n,l){let d=Oe(e.top,e.height,r,n.element)-Fe(n.viewport,s),m=Oe(e.top,e.height,r,l.element)-Fe(l.viewport,s);return {tStart:d,tEnd:m}}function Ie(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 s=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(s)return [parseInt(s[1],16),parseInt(s[2],16),parseInt(s[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 Ee(e,r,s){let n=Ie(e),l=Ie(r);return !n||!l?e:`rgb(${Math.round(n[0]+(l[0]-n[0])*s)},${Math.round(n[1]+(l[1]-n[1])*s)},${Math.round(n[2]+(l[2]-n[2])*s)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ke=0;function Qe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ye(e){let r=e.getAttribute("stroke"),s=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):s&&s!=="none"&&s!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ze(e,r,s){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 l(){let d=s==="x"?window.scrollX:window.scrollY,m=e-d,D=r-d,U=s==="x";n.innerHTML=`
2
- <div style="position:absolute;${U?`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;${U?`left:${D}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${D}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",l,{passive:true}),l(),n}function He(e,r,s){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let m=parseFloat(d),D=n[l++]??m;return String(+(m+(D-m)*s).toFixed(4))})}function xe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:n="path, polyline, line, polygon, rect, circle",speed:l=1,fade:d=false,easing:m="linear",trigger:D={},stagger:U=0,direction:y="forward",once:X=false,debug:ze=false,axis:S="y",scrollContainer:ce,autoReverse:Z=false,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:Be=0,rootMargin:qe="0px",repeat:j=0,repeatDelay:ke=0,morphTo:L,clip:pe,native:_e=true,onProgress:de,onStart:ye,onComplete:J}=r,W=pe===true?"left":typeof pe=="string"?pe:false,re=typeof m=="function"?m:ve[m]??ve.linear,Te=we(D.start??"top bottom"),Ae=we(D.end??"bottom top"),b=typeof ce=="string"?document.querySelector(ce):ce??null,C=Array.isArray(R)?R[0]:null,$=Array.isArray(R)?R[1]:typeof R=="string"?R:null,E=Array.isArray(H)?H[0]:null,x=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,T=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let o=t*100;switch(W){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let v=W?[]:Array.from(e.querySelectorAll(n)),g=[],O=[],F=0,I=0,P=false,G=false,N=0,ne=false,A=-1,se=-1,z=false,oe=0,K=0,ie,ge=null,ae=new Set,le=-1,Me=performance.now();function Q(){return b?S==="x"?b.scrollLeft:b.scrollTop:S==="x"?window.scrollX:window.scrollY}function De(){return b?S==="x"?b.clientWidth:b.clientHeight:S==="x"?window.innerWidth:window.innerHeight}function Pe(){let t=e.getBoundingClientRect(),o,a,p;if(b){let w=b.getBoundingClientRect();o=S==="x"?t.left-w.left+b.scrollLeft:t.top-w.top+b.scrollTop,a=S==="x"?t.width:t.height,p=Q();}else o=S==="x"?t.left:t.top,a=S==="x"?t.width:t.height,p=Q();let B=$e({top:o,height:a},p,De(),Te,Ae);F=B.tStart,I=B.tEnd,ze&&process.env.NODE_ENV!=="production"&&(ge?.remove(),ge=Ze(F,I,S));}function Ue(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=o==="reverse"?1-t:t;e.style.clipPath=_(a);return}v.forEach((a,p)=>{a.style.strokeDashoffset=o==="reverse"?`${g[p]*t}`:`${g[p]*(1-t)}`,d&&(a.style.opacity=o==="reverse"?`${1-t}`:`${t}`),C&&$?a.style.stroke=Ee(C,$,t):$&&(a.style.stroke=$),E!==null&&x!==null?a.style.strokeWidth=`${E+(x-E)*t}`:x!==null&&(a.style.strokeWidth=`${x}`),k!==null&&T!==null?a.style.fillOpacity=`${k+(T-k)*t}`:T!==null&&(a.style.fillOpacity=`${T}`),L&&a.tagName.toLowerCase()==="path"&&O[p]&&a.setAttribute("d",He(O[p],L,t));});}function Le(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,o)=>{t.style.strokeDasharray=`${g[o]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[o]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),E!==null&&(t.style.strokeWidth=`${E}`),k!==null&&(t.style.fillOpacity=`${k}`),L&&t.tagName.toLowerCase()==="path"&&O[o]&&t.setAttribute("d",O[o]);});}if(v.forEach(t=>{Ye(t);let o=Se(t);g.push(o),t.tagName.toLowerCase()==="path"?O.push(t.getAttribute("d")??""):O.push(""),s?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?`${o}`:"0",d&&(t.style.opacity="1"),$&&(t.style.stroke=$),x!==null&&(t.style.strokeWidth=`${x}`),T!==null&&(t.style.fillOpacity=`${T}`),L&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",L)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=y==="reverse"?"0":`${o}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),E!==null&&(t.style.strokeWidth=`${E}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(s)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(s)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Xe(){return !(_e===false||!Qe()||!v.length||typeof m!="string"||!(m in Re)||W||S!=="y"||b||l!==1||U!==0||X||Z||te!==false||L||ee||j||me>0||de||ye||J||R!=null||H!=null||V!=null||(D.start??"top bottom").trim()!=="top bottom"||(D.end??"bottom top").trim()!=="bottom top")}function je(){let t=`svg-scroll-draw-${++Ke}`,o=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",p=`stroke-dashoffset:${o};`,B=`stroke-dashoffset:${a};`;d&&(p+=`opacity:${y==="reverse"?1:0};`,B+=`opacity:${y==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${t}{from{${p}}to{${B}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[m]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(w);function i(f,M){f.style.setProperty("--ssd-len",String(g[M])),f.style.strokeDasharray=`${g[M]}`,f.style.strokeDashoffset="",f.style.opacity="",f.style.animationPlayState="",f.classList.add(t);}v.forEach(i);let u=false,h=-1;function c(){if(h>=0)return h;let f=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=$e({top:f.top,height:f.height},Q(),De(),Te,Ae);return re(q(Q(),M,Y,l))}return {destroy(){v.forEach(f=>{f.classList.remove(t),f.style.removeProperty("--ssd-len"),f.style.animationPlayState="";}),w.remove();},replay(){u=false,h=-1,v.forEach(i);},pause(){u=true,v.forEach(f=>{f.style.animationPlayState="paused";});},resume(){u&&(u=false,v.forEach(f=>{f.style.animationPlayState="running";}));},seek(f){let M=Math.min(1,Math.max(0,f));h=M,u=true,v.forEach((Y,Ce)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Ce]*M}`:`${g[Ce]*(1-M)}`,d&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`);});},getProgress(){return c()}}}if(Xe())return je();Pe();function ue(){if(!ne||z)return;let t=performance.now(),o=Q(),a=l;if(te!==false){let i=t-Me,u=i>0?Math.abs(o-(le<0?o:le))/i:0;a=l*Math.max(.2,1+u*(typeof te=="number"?te:1)*.04);}le=o,Me=t;let p=Z?se===-1||o>=se?"forward":"reverse":y;se=o;let B=I-F,w=true;if(W){let i=re(q(o,F,I,a));X&&!Z&&(A=Math.max(A,i),i=A),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let u=p==="reverse"?1-i:i;e.style.clipPath=_(u),de?.(i),!G&&q(o,F,I,a)>0&&(G=true,ye?.()),i>=1&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,P=false,e.style.clipPath=_(0);},ke))):i<1&&!X&&(P=false),N=requestAnimationFrame(ue);return}if(v.forEach((i,u)=>{let h=u*U*B,c=re(q(o,F+h,I+h,a));X&&!Z&&(A=Math.max(A,c),c=A),oe=c,i.style.strokeDashoffset=p==="reverse"?`${g[u]*c}`:`${g[u]*(1-c)}`,d&&(i.style.opacity=p==="reverse"?`${1-c}`:`${c}`),C&&$?i.style.stroke=Ee(C,$,c):$&&(i.style.stroke=$),E!==null&&x!==null?i.style.strokeWidth=`${E+(x-E)*c}`:x!==null&&(i.style.strokeWidth=`${x}`),k!==null&&T!==null?i.style.fillOpacity=`${k+(T-k)*c}`:T!==null&&(i.style.fillOpacity=`${T}`),L&&i.tagName.toLowerCase()==="path"&&O[u]&&i.setAttribute("d",He(O[u],L,c)),u===0&&(de?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(w=false);}),ee){let i=re(q(o,F,I,a));for(let u in ee){let h=parseFloat(u);i>=h&&!ae.has(h)&&(ae.add(h),ee[u]?.());}}!G&&q(o,F,I,a)>0&&(G=true,ye?.()),w&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{A=-1,G=false,P=false,ae.clear(),Le();},ke))):!w&&!X&&(P=false),N=requestAnimationFrame(ue);}let he=new IntersectionObserver(t=>{t.forEach(o=>{ne=o.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:Be,rootMargin:qe}),be;function fe(){clearTimeout(be),be=setTimeout(()=>{v.forEach((t,o)=>{g[o]=Se(t),t.style.strokeDasharray=`${g[o]}`;}),Pe();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),me>0?setTimeout(()=>he.observe(e),me):he.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),he.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(be),ge?.remove();},replay(){A=-1,se=-1,le=-1,G=false,P=false,K=0,z=false,ae.clear(),clearTimeout(ie),Le();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let o=Math.min(1,Math.max(0,t));oe=o,A=o,z=true,cancelAnimationFrame(N),Ue(o,y);},getProgress(){return oe}}}function at(e={}){let r=ref(null);return onMounted(()=>{if(!r.value)return;let s=xe(r.value,e);onUnmounted(()=>s.destroy());}),r}var lt=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 s=ref(null);return onMounted(()=>{if(!s.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 l=xe(s.value,n);onUnmounted(()=>l.destroy());}),()=>h("div",{ref:s},r.default?.())}});export{lt as ScrollDraw,at as useScrollDraw};
1
+ import {defineComponent,ref,onMounted,onUnmounted,h}from'vue';function Je({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),u=Math.sqrt(s),c=0,p=[];for(let a=0;a<n;a++){let d=Math.pow(u,a);p.push(d),c+=d;}let g=[0],C=0;for(let a=0;a<n;a++)C+=p[a]/c,g.push(C);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=g[d+1]){let X=(a-g[d])/(g[d+1]-g[d]);if(d===0)return X*(2-X);let b=1-Math.pow(s,d);return b+(1-b)*(2*X-1)*(2*X-1)}return 1}}function Ke({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),u=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return c=>c<=0?0:c>=1?1:n*Math.pow(2,-10*c)*Math.sin((c-u)*(2*Math.PI)/s)+1}var ve={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Je(),elastic:Ke()};function Se(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 Ie(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 Fe(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 xe(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 Qe(e,r,n){return Math.min(n,Math.max(r,e))}function U(e,r,n,s){return n===r?0:Qe((e-r)/(n-r)*s,0,1)}function Ee(e,r,n,s,u){let c=Ie(e.top,e.height,r,s.element)-Fe(s.viewport,n),p=Ie(e.top,e.height,r,u.element)-Fe(u.viewport,n);return {tStart:c,tEnd:p}}function Ne(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function $e(e,r,n){let s=Ne(e),u=Ne(r);return !s||!u?e:`rgb(${Math.round(s[0]+(u[0]-s[0])*n)},${Math.round(s[1]+(u[1]-s[1])*n)},${Math.round(s[2]+(u[2]-s[2])*n)})`}function Re(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var He={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ye=0;function Ze(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function et(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Re("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Re("Element has a fill \u2014 it may obscure the stroke animation.",e);}function tt(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function u(){let c=n==="x"?window.scrollX:window.scrollY,p=e-c,g=r-c,C=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${C?`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;${C?`left:${g}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${g}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(s),window.addEventListener("scroll",u,{passive:true}),u(),s}function We(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let p=parseFloat(c),g=s[u++]??p;return String(+(p+(g-p)*n).toFixed(4))})}function Me(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:u=1,fade:c=false,easing:p="linear",trigger:g={},stagger:C=0,direction:a="forward",once:d=false,debug:X=false,axis:b="y",scrollContainer:me,autoReverse:ee=false,delay:pe=0,strokeColor:W,strokeWidth:V,fillOpacity:B,waypoints:te,velocityScale:re=false,threshold:ze=0,rootMargin:qe="0px",repeat:J=0,repeatDelay:ke=0,morphTo:O,clip:de,native:_e=true,onProgress:ye,onStart:ge,onComplete:K}=r,G=de===true?"left":typeof de=="string"?de:false,ne=typeof p=="function"?p:ve[p]??ve.linear,Te=Se(g.start??"top bottom"),Ae=Se(g.end??"bottom top"),S=typeof me=="string"?document.querySelector(me):me??null,I=Array.isArray(W)?W[0]:null,$=Array.isArray(W)?W[1]:typeof W=="string"?W:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,T=Array.isArray(B)?B[0]:null,A=Array.isArray(B)?B[1]:typeof B=="number"?B:null;function j(t){let o=t*100;switch(G){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let x=G?[]:Array.from(e.querySelectorAll(s)),w=[],F=[],N=0,R=0,L=false,z=false,H=0,se=false,P=-1,oe=-1,q=false,ie=0,Q=0,ae,he=null,le=new Set,ue=-1,Pe=performance.now();function Y(){return S?b==="x"?S.scrollLeft:S.scrollTop:b==="x"?window.scrollX:window.scrollY}function De(){return S?b==="x"?S.clientWidth:S.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),o,l,h;if(S){let E=S.getBoundingClientRect();o=b==="x"?t.left-E.left+S.scrollLeft:t.top-E.top+S.scrollTop,l=b==="x"?t.width:t.height,h=Y();}else o=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,h=Y();let _=Ee({top:o,height:l},h,De(),Te,Ae);N=_.tStart,R=_.tEnd,X&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=tt(N,R,b));}function Ue(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),G){let l=o==="reverse"?1-t:t;e.style.clipPath=j(l);return}x.forEach((l,h)=>{l.style.strokeDashoffset=o==="reverse"?`${w[h]*t}`:`${w[h]*(1-t)}`,c&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),I&&$?l.style.stroke=$e(I,$,t):$&&(l.style.stroke=$),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),T!==null&&A!==null?l.style.fillOpacity=`${T+(A-T)*t}`:A!==null&&(l.style.fillOpacity=`${A}`),O&&l.tagName.toLowerCase()==="path"&&F[h]&&l.setAttribute("d",We(F[h],O,t));});}function Ce(){if(e.style.setProperty("--scroll-draw-progress","0"),G){e.style.clipPath=j(0);return}x.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${w[o]}`,c?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),O&&t.tagName.toLowerCase()==="path"&&F[o]&&t.setAttribute("d",F[o]);});}if(x.forEach(t=>{et(t);let o=xe(t);w.push(o),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?`${o}`:"0",c&&(t.style.opacity="1"),$&&(t.style.stroke=$),k!==null&&(t.style.strokeWidth=`${k}`),A!==null&&(t.style.fillOpacity=`${A}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?"0":`${o}`,c?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`));}),G){if(n)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Xe(){return !(_e===false||!Ze()||!x.length||typeof p!="string"||!(p in He)||G||b!=="y"||S||u!==1||C!==0||d||ee||re!==false||O||te||J||pe>0||ye||ge||K||W!=null||V!=null||B!=null||(g.start??"top bottom").trim()!=="top bottom"||(g.end??"bottom top").trim()!=="bottom top")}function je(){let t=`svg-scroll-draw-${++Ye}`,o=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",h=`stroke-dashoffset:${o};`,_=`stroke-dashoffset:${l};`;c&&(h+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let E=document.createElement("style");E.setAttribute("data-svg-scroll-draw",""),E.textContent=`@keyframes ${t}{from{${h}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${He[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(E);function i(m,D){m.style.setProperty("--ssd-len",String(w[D])),m.style.strokeDasharray=`${w[D]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t);}x.forEach(i);let f=false,v=-1;function y(){if(v>=0)return v;let m=e.getBoundingClientRect(),{tStart:D,tEnd:Z}=Ee({top:m.top,height:m.height},Y(),De(),Te,Ae);return ne(U(Y(),D,Z,u))}return {destroy(){x.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),E.remove();},replay(){f=false,v=-1,x.forEach(i);},pause(){f=true,x.forEach(m=>{m.style.animationPlayState="paused";});},resume(){f&&(f=false,x.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let D=Math.min(1,Math.max(0,m));v=D,f=true,x.forEach((Z,Oe)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${w[Oe]*D}`:`${w[Oe]*(1-D)}`,c&&(Z.style.opacity=a==="reverse"?`${1-D}`:`${D}`);});},getProgress(){return y()}}}if(Xe())return je();Le();function ce(){if(!se||q)return;let t=performance.now(),o=Y(),l=u;if(re!==false){let i=t-Pe,f=i>0?Math.abs(o-(ue<0?o:ue))/i:0;l=u*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=o,Pe=t;let h=ee?oe===-1||o>=oe?"forward":"reverse":a;oe=o;let _=R-N,E=true;if(G){let i=ne(U(o,N,R,l));d&&!ee&&(P=Math.max(P,i),i=P),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=h==="reverse"?1-i:i;e.style.clipPath=j(f),ye?.(i),!z&&U(o,N,R,l)>0&&(z=true,ge?.()),i>=1&&!L?(L=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,z=false,L=false,e.style.clipPath=j(0);},ke))):i<1&&!d&&(L=false),H=requestAnimationFrame(ce);return}if(x.forEach((i,f)=>{let v=f*C*_,y=ne(U(o,N+v,R+v,l));d&&!ee&&(P=Math.max(P,y),y=P),ie=y,i.style.strokeDashoffset=h==="reverse"?`${w[f]*y}`:`${w[f]*(1-y)}`,c&&(i.style.opacity=h==="reverse"?`${1-y}`:`${y}`),I&&$?i.style.stroke=$e(I,$,y):$&&(i.style.stroke=$),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),T!==null&&A!==null?i.style.fillOpacity=`${T+(A-T)*y}`:A!==null&&(i.style.fillOpacity=`${A}`),O&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",We(F[f],O,y)),f===0&&(ye?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(E=false);}),te){let i=ne(U(o,N,R,l));for(let f in te){let v=parseFloat(f);i>=v&&!le.has(v)&&(le.add(v),te[f]?.());}}!z&&U(o,N,R,l)>0&&(z=true,ge?.()),E&&!L?(L=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,z=false,L=false,le.clear(),Ce();},ke))):!E&&!d&&(L=false),H=requestAnimationFrame(ce);}let be=new IntersectionObserver(t=>{t.forEach(o=>{se=o.isIntersecting,se&&!q?H=requestAnimationFrame(ce):cancelAnimationFrame(H);});},{root:S??null,threshold:ze,rootMargin:qe}),we;function fe(){clearTimeout(we),we=setTimeout(()=>{x.forEach((t,o)=>{w[o]=xe(t),t.style.strokeDasharray=`${w[o]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),pe>0?setTimeout(()=>be.observe(e),pe):be.observe(e),{destroy(){cancelAnimationFrame(H),clearTimeout(ae),be.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(we),he?.remove();},replay(){P=-1,oe=-1,ue=-1,z=false,L=false,Q=0,q=false,le.clear(),clearTimeout(ae),Ce();},pause(){q=true,cancelAnimationFrame(H);},resume(){q&&(q=false,se&&(H=requestAnimationFrame(ce)));},seek(t){let o=Math.min(1,Math.max(0,t));ie=o,P=o,q=true,cancelAnimationFrame(H),Ue(o,a);},getProgress(){return ie}}}function ut(e={}){let r=ref(null);return onMounted(()=>{if(!r.value)return;let n=Me(r.value,e);onUnmounted(()=>n.destroy());}),r}var ct=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 n=ref(null);return onMounted(()=>{if(!n.value)return;let s={};e.selector!=null&&(s.selector=e.selector),e.speed!=null&&(s.speed=e.speed),e.fade!=null&&(s.fade=e.fade),e.stagger!=null&&(s.stagger=e.stagger),e.easing!=null&&(s.easing=e.easing),e.direction!=null&&(s.direction=e.direction),e.trigger!=null&&(s.trigger=e.trigger),e.once!=null&&(s.once=e.once),e.debug!=null&&(s.debug=e.debug),e.onProgress!=null&&(s.onProgress=e.onProgress),e.onStart!=null&&(s.onStart=e.onStart),e.onComplete!=null&&(s.onComplete=e.onComplete);let u=Me(n.value,s);onUnmounted(()=>u.destroy());}),()=>h("div",{ref:n},r.default?.())}});export{ct as ScrollDraw,ut as useScrollDraw};