svg-scroll-draw 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/index.cjs +3 -3
- package/dist/angular/index.d.mts +16 -0
- package/dist/angular/index.d.ts +16 -0
- package/dist/angular/index.mjs +3 -3
- package/dist/astro/index.cjs +3 -3
- package/dist/astro/index.d.mts +8 -0
- package/dist/astro/index.d.ts +8 -0
- package/dist/astro/index.mjs +3 -3
- package/dist/cdn/svg-scroll-draw.global.js +3 -3
- package/dist/devtools/index.cjs +1 -1
- package/dist/devtools/index.mjs +1 -1
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +16 -0
- package/dist/group/index.d.ts +16 -0
- package/dist/group/index.mjs +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.mjs +4 -4
- package/dist/lenis/index.cjs +1 -0
- package/dist/lenis/index.d.mts +51 -0
- package/dist/lenis/index.d.ts +51 -0
- package/dist/lenis/index.mjs +1 -0
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +16 -0
- package/dist/nuxt/index.d.ts +16 -0
- package/dist/nuxt/index.mjs +3 -3
- package/dist/pin/index.cjs +1 -0
- package/dist/pin/index.d.mts +29 -0
- package/dist/pin/index.d.ts +29 -0
- package/dist/pin/index.mjs +1 -0
- package/dist/react/index.cjs +3 -3
- package/dist/react/index.d.mts +16 -0
- package/dist/react/index.d.ts +16 -0
- package/dist/react/index.mjs +3 -3
- package/dist/snap/index.cjs +1 -0
- package/dist/snap/index.d.mts +30 -0
- package/dist/snap/index.d.ts +30 -0
- package/dist/snap/index.mjs +1 -0
- package/dist/solid/index.cjs +3 -3
- package/dist/solid/index.d.mts +16 -0
- package/dist/solid/index.d.ts +16 -0
- package/dist/solid/index.mjs +3 -3
- package/dist/svelte/index.cjs +3 -3
- package/dist/svelte/index.d.mts +16 -0
- package/dist/svelte/index.d.ts +16 -0
- package/dist/svelte/index.mjs +3 -3
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.mts +16 -0
- package/dist/vue/index.d.ts +16 -0
- package/dist/vue/index.mjs +2 -2
- package/dist/web-component/index.cjs +3 -3
- package/dist/web-component/index.mjs +3 -3
- package/package.json +16 -1
package/dist/astro/index.d.ts
CHANGED
|
@@ -71,6 +71,14 @@ interface ScrollDrawOptions {
|
|
|
71
71
|
onProgress?: (alpha: number) => void;
|
|
72
72
|
onStart?: () => void;
|
|
73
73
|
onComplete?: () => void;
|
|
74
|
+
/** Fires when scroll position enters the trigger zone (scrolling forward). */
|
|
75
|
+
onEnter?: () => void;
|
|
76
|
+
/** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
|
|
77
|
+
onLeave?: () => void;
|
|
78
|
+
/** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
|
|
79
|
+
onEnterBack?: () => void;
|
|
80
|
+
/** Fires when scroll position exits the trigger zone at the start (scrolling back). */
|
|
81
|
+
onLeaveBack?: () => void;
|
|
74
82
|
/**
|
|
75
83
|
* Trigger the animation when the element enters the viewport instead of
|
|
76
84
|
* tying it to scroll position. The draw runs over `duration` milliseconds,
|
package/dist/astro/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${l?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",c,{passive:true}),c(),t}function Be(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let m=parseFloat(s),u=t[c++]??m;return String(+(m+(u-m)*r).toFixed(4))})}function qe(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,c=r?{..._e[r],...t}:t,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:m="path, polyline, line, polygon, rect, circle",speed:u=1,fade:l=false,easing:d="linear",trigger:T={},stagger:Y=0,direction:b="forward",once:re=false,debug:we=false,axis:q="y",scrollContainer:ne,autoReverse:A=false,delay:N=0,strokeColor:M,strokeWidth:B,fillOpacity:O,waypoints:$,velocityScale:D=false,threshold:H=0,rootMargin:R="0px",repeat:I=0,repeatDelay:z=0,morphTo:E,clip:U,autoplay:ce=false,duration:ie=1e3,native:pe=true,onProgress:f,onStart:P,onComplete:h}=c,x=U===true?"left":typeof U=="string"?U:false,Z=typeof d=="function"?d:le[d]??le.linear,be=me(T.start??"top bottom"),a=me(T.end??"bottom top"),p=typeof ne=="string"?document.querySelector(ne):ne??null,K=Array.isArray(M)?M[0]:null,k=Array.isArray(M)?M[1]:typeof M=="string"?M:null,G=Array.isArray(B)?B[0]:null,Q=Array.isArray(B)?B[1]:typeof B=="number"?B:null,C=Array.isArray(O)?O[0]:null,V=Array.isArray(O)?O[1]:typeof O=="number"?O:null;function ae(o){let i=o*100;switch(x){case "right":return `inset(0 0 0 ${100-i}%)`;case "top":return `inset(0 0 ${100-i}% 0)`;case "bottom":return `inset(${100-i}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-i}% 0 0)`}}let X=x?[]:Array.from(e.querySelectorAll(m)),W=[],de=[],ve=0,Ee=0,te=false,fe=false,J=0,Oe=false,ge=-1,De=-1,oe=false,Ae=0,Se=0,xe,ze=null,Te=new Set,Ie=-1,Ye=performance.now();function ke(){return p?q==="x"?p.scrollLeft:p.scrollTop:q==="x"?window.scrollX:window.scrollY}function Xe(){return p?q==="x"?p.clientWidth:p.clientHeight:q==="x"?window.innerWidth:window.innerHeight}function Je(){let o=e.getBoundingClientRect(),i,w,_;if(p){let se=p.getBoundingClientRect();i=q==="x"?o.left-se.left+p.scrollLeft:o.top-se.top+p.scrollTop,w=q==="x"?o.width:o.height,_=ke();}else i=q==="x"?o.left:o.top,w=q==="x"?o.width:o.height,_=ke();let ue=he({top:i,height:w},_,Xe(),be,a);ve=ue.tStart,Ee=ue.tEnd,we&&process.env.NODE_ENV!=="production"&&(ze?.remove(),ze=St(ve,Ee,q));}function pt(o,i){if(e.style.setProperty("--scroll-draw-progress",String(o)),x){let w=i==="reverse"?1-o:o;e.style.clipPath=ae(w);return}X.forEach((w,_)=>{w.style.strokeDashoffset=i==="reverse"?`${W[_]*o}`:`${W[_]*(1-o)}`,l&&(w.style.opacity=i==="reverse"?`${1-o}`:`${o}`),K&&k?w.style.stroke=Ce(K,k,o):k&&(w.style.stroke=k),G!==null&&Q!==null?w.style.strokeWidth=`${G+(Q-G)*o}`:Q!==null&&(w.style.strokeWidth=`${Q}`),C!==null&&V!==null?w.style.fillOpacity=`${C+(V-C)*o}`:V!==null&&(w.style.fillOpacity=`${V}`),E&&w.tagName.toLowerCase()==="path"&&de[_]&&w.setAttribute("d",Be(de[_],E,o));});}function Fe(){if(e.style.setProperty("--scroll-draw-progress","0"),x){e.style.clipPath=ae(0);return}X.forEach((o,i)=>{o.style.strokeDasharray=`${W[i]}`,o.style.strokeDashoffset=b==="reverse"?"0":`${W[i]}`,l?o.style.opacity=b==="reverse"?"1":"0":o.style.opacity="",K&&(o.style.stroke=K),G!==null&&(o.style.strokeWidth=`${G}`),C!==null&&(o.style.fillOpacity=`${C}`),E&&o.tagName.toLowerCase()==="path"&&de[i]&&o.setAttribute("d",de[i]);});}if(X.forEach(o=>{bt(o);let i=Re(o);W.push(i),o.tagName.toLowerCase()==="path"?de.push(o.getAttribute("d")??""):de.push(""),s?(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=b==="reverse"?`${i}`:"0",l&&(o.style.opacity="1"),k&&(o.style.stroke=k),Q!==null&&(o.style.strokeWidth=`${Q}`),V!==null&&(o.style.fillOpacity=`${V}`),E&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",E)):(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=b==="reverse"?"0":`${i}`,l?o.style.opacity=b==="reverse"?"1":"0":o.style.opacity="",K&&(o.style.stroke=K),G!==null&&(o.style.strokeWidth=`${G}`),C!==null&&(o.style.fillOpacity=`${C}`));}),x){if(s)return e.style.clipPath=ae(1),h?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ae(0);}else if(s)return h?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function ft(){return !(pe===false||!wt()||!X.length||typeof d!="string"||!(d in rt)||x||q!=="y"||p||u!==1||Y!==0||re||A||D!==false||E||$||I||N>0||f||P||h||M!=null||B!=null||O!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function dt(){let o=`svg-scroll-draw-${++ht}`,i=b==="reverse"?"0":"var(--ssd-len)",w=b==="reverse"?"var(--ssd-len)":"0",_=`stroke-dashoffset:${i};`,ue=`stroke-dashoffset:${w};`;l&&(_+=`opacity:${b==="reverse"?1:0};`,ue+=`opacity:${b==="reverse"?0:1};`);let se=document.createElement("style");se.setAttribute("data-svg-scroll-draw",""),se.textContent=`@keyframes ${o}{from{${_}}to{${ue}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${rt[d]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(se);function y(g,v){g.style.setProperty("--ssd-len",String(W[v])),g.style.strokeDasharray=`${W[v]}`,g.style.strokeDashoffset="",g.style.opacity="",g.style.animationPlayState="",g.classList.add(o);}X.forEach(y);let L=false,j=-1;function S(){if(j>=0)return j;let g=e.getBoundingClientRect(),{tStart:v,tEnd:F}=he({top:g.top,height:g.height},ke(),Xe(),be,a);return Z(ee(ke(),v,F,u))}return {destroy(){X.forEach(g=>{g.classList.remove(o),g.style.removeProperty("--ssd-len"),g.style.animationPlayState="";}),se.remove();},replay(){L=false,j=-1,X.forEach(y);},pause(){L=true,X.forEach(g=>{g.style.animationPlayState="paused";});},resume(){L&&(L=false,X.forEach(g=>{g.style.animationPlayState="running";}));},seek(g){let v=Math.min(1,Math.max(0,g));j=v,L=true,X.forEach((F,Me)=>{F.classList.remove(o),F.style.strokeDashoffset=b==="reverse"?`${W[Me]*v}`:`${W[Me]*(1-v)}`,l&&(F.style.opacity=b==="reverse"?`${1-v}`:`${v}`);});},getProgress(){return S()}}}if(ft())return dt();function gt(){let o=Math.max(1,ie),i=0,w=0;function _(S){let g=true;if(x){let v=Math.min(1,Math.max(0,S/o)),F=Z(v);Ae=F,e.style.setProperty("--scroll-draw-progress",String(F)),e.style.clipPath=ae(b==="reverse"?1-F:F),f?.(F),v<1&&(g=false);}else X.forEach((v,F)=>{let Me=F*Y*o,$e=Math.min(1,Math.max(0,(S-Me)/o)),ye=Z($e);v.style.strokeDashoffset=b==="reverse"?`${W[F]*ye}`:`${W[F]*(1-ye)}`,l&&(v.style.opacity=b==="reverse"?`${1-ye}`:`${ye}`),K&&k?v.style.stroke=Ce(K,k,ye):k&&(v.style.stroke=k),G!==null&&Q!==null?v.style.strokeWidth=`${G+(Q-G)*ye}`:Q!==null&&(v.style.strokeWidth=`${Q}`),C!==null&&V!==null?v.style.fillOpacity=`${C+(V-C)*ye}`:V!==null&&(v.style.fillOpacity=`${V}`),E&&v.tagName.toLowerCase()==="path"&&de[F]&&v.setAttribute("d",Be(de[F],E,ye)),F===0&&(f?.(ye),e.style.setProperty("--scroll-draw-progress",String(ye))),$e<1&&(g=false);});if($){let v=Math.min(1,Math.max(0,S/o)),F=Z(v);for(let Me in $){let $e=parseFloat(Me);F>=$e&&!Te.has($e)&&(Te.add($e),$[Me]?.());}}return g}function ue(S){if(oe)return;let g=S-i;fe||(fe=true,P?.());let v=_(g);if(v&&!te){te=true,_(o*(1+Math.max(0,X.length-1)*Y)),h?.(),Se<(I==="infinite"?1/0:I??0)&&(Se++,xe=setTimeout(()=>{i=performance.now(),fe=false,te=false,Te.clear(),Fe(),J=requestAnimationFrame(ue);},z));return}v||(J=requestAnimationFrame(ue));}function se(){cancelAnimationFrame(J),clearTimeout(xe),i=performance.now(),w=0,oe=false,fe=false,te=false,Se=0,Te.clear(),Fe(),J=requestAnimationFrame(ue);}let y=new IntersectionObserver(S=>{S.forEach(g=>{g.isIntersecting&&!(re&&te)?se():!g.isIntersecting&&!re&&!te&&(cancelAnimationFrame(J),clearTimeout(xe),i=null);});},{root:p??null,threshold:H,rootMargin:R}),L;function j(){clearTimeout(L),L=setTimeout(()=>{X.forEach((S,g)=>{W[g]=Re(S),S.style.strokeDasharray=`${W[g]}`;});},150);}return window.addEventListener("resize",j),window.addEventListener("orientationchange",j),N>0?setTimeout(()=>y.observe(e),N):y.observe(e),{destroy(){cancelAnimationFrame(J),clearTimeout(xe),y.disconnect(),window.removeEventListener("resize",j),window.removeEventListener("orientationchange",j),clearTimeout(L);},replay(){Se=0,se();},pause(){oe||(oe=true,w=performance.now()-i,cancelAnimationFrame(J));},resume(){oe&&(oe=false,i=performance.now()-w,J=requestAnimationFrame(ue));},seek(S){let g=Math.min(1,Math.max(0,S));Ae=g,oe=true,w=g*o,i=performance.now()-w,cancelAnimationFrame(J),_(w);},getProgress(){return Ae}}}if(ce)return gt();Je();function Ne(){if(!Oe||oe)return;let o=performance.now(),i=ke(),w=u;if(D!==false){let y=o-Ye,L=y>0?Math.abs(i-(Ie<0?i:Ie))/y:0;w=u*Math.max(.2,1+L*(typeof D=="number"?D:1)*.04);}Ie=i,Ye=o;let _=A?De===-1||i>=De?"forward":"reverse":b;De=i;let ue=Ee-ve,se=true;if(x){let y=Z(ee(i,ve,Ee,w));re&&!A&&(ge=Math.max(ge,y),y=ge),Ae=y,e.style.setProperty("--scroll-draw-progress",String(y));let L=_==="reverse"?1-y:y;e.style.clipPath=ae(L),f?.(y),!fe&&ee(i,ve,Ee,w)>0&&(fe=true,P?.()),y>=1&&!te?(te=true,h?.(),Se<(I==="infinite"?1/0:I??0)&&(Se++,xe=setTimeout(()=>{ge=-1,fe=false,te=false,e.style.clipPath=ae(0);},z))):y<1&&!re&&(te=false),J=requestAnimationFrame(Ne);return}if(X.forEach((y,L)=>{let j=L*Y*ue,S=Z(ee(i,ve+j,Ee+j,w));re&&!A&&(ge=Math.max(ge,S),S=ge),Ae=S,y.style.strokeDashoffset=_==="reverse"?`${W[L]*S}`:`${W[L]*(1-S)}`,l&&(y.style.opacity=_==="reverse"?`${1-S}`:`${S}`),K&&k?y.style.stroke=Ce(K,k,S):k&&(y.style.stroke=k),G!==null&&Q!==null?y.style.strokeWidth=`${G+(Q-G)*S}`:Q!==null&&(y.style.strokeWidth=`${Q}`),C!==null&&V!==null?y.style.fillOpacity=`${C+(V-C)*S}`:V!==null&&(y.style.fillOpacity=`${V}`),E&&y.tagName.toLowerCase()==="path"&&de[L]&&y.setAttribute("d",Be(de[L],E,S)),L===0&&(f?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&(se=false);}),$){let y=Z(ee(i,ve,Ee,w));for(let L in $){let j=parseFloat(L);y>=j&&!Te.has(j)&&(Te.add(j),$[L]?.());}}!fe&&ee(i,ve,Ee,w)>0&&(fe=true,P?.()),se&&!te?(te=true,h?.(),Se<(I==="infinite"?1/0:I??0)&&(Se++,xe=setTimeout(()=>{ge=-1,fe=false,te=false,Te.clear(),Fe();},z))):!se&&!re&&(te=false),J=requestAnimationFrame(Ne);}let Ve=new IntersectionObserver(o=>{o.forEach(i=>{Oe=i.isIntersecting,Oe&&!oe?J=requestAnimationFrame(Ne):cancelAnimationFrame(J);});},{root:p??null,threshold:H,rootMargin:R}),We;function He(){clearTimeout(We),We=setTimeout(()=>{X.forEach((o,i)=>{W[i]=Re(o),o.style.strokeDasharray=`${W[i]}`;}),Je();},150);}return window.addEventListener("resize",He),window.addEventListener("orientationchange",He),N>0?setTimeout(()=>Ve.observe(e),N):Ve.observe(e),{destroy(){cancelAnimationFrame(J),clearTimeout(xe),Ve.disconnect(),window.removeEventListener("resize",He),window.removeEventListener("orientationchange",He),clearTimeout(We),ze?.remove();},replay(){ge=-1,De=-1,Ie=-1,fe=false,te=false,Se=0,oe=false,Te.clear(),clearTimeout(xe),Fe();},pause(){oe=true,cancelAnimationFrame(J);},resume(){oe&&(oe=false,Oe&&(J=requestAnimationFrame(Ne)));},seek(o){let i=Math.min(1,Math.max(0,o));Ae=i,ge=i,oe=true,cancelAnimationFrame(J),pt(i,b);},getProgress(){return Ae}}}var nt=new Map;function Pe(e,n){nt.set(e,n);}function Le(e){nt.delete(e);}function vt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ot(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let c=[],s=[],m=t[2].trim();if(m)for(let u of m.split(/[\s,]+/)){let l=u.match(/^([-+]?[\d.eE]+)(.*)$/);c.push(l?parseFloat(l[1]):0),s.push(l?l[2]:"");}n.push({fn:t[1],nums:c,units:s});}return n}function Et(e,n,r){let t=ot(e),c=ot(n);return t.length===0||t.length!==c.length?r<1?e:n:t.map((s,m)=>{let u=c[m];return s.fn!==u.fn||s.nums.length!==u.nums.length?r<1?`${s.fn}(${s.nums.map((l,d)=>`${l}${s.units[d]}`).join(", ")})`:`${u.fn}(${u.nums.map((l,d)=>`${l}${u.units[d]}`).join(", ")})`:`${s.fn}(${s.nums.map((l,d)=>`${l+(u.nums[d]-l)*r}${s.units[d]}`).join(", ")})`}).join(" ")}function st(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),c=String(n);if(vt(t))return Ce(t,c,r);if(t.includes("("))return Et(t,c,r);let s=t.match(/^([-+]?[\d.]+)(.*)$/),m=c.match(/^([-+]?[\d.]+)(.*)$/);if(s&&m){let u=parseFloat(s[1]),l=parseFloat(m[1]);return `${u+(l-u)*r}${s[2]||m[2]}`}return r<1?t:c}function xt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var it={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Tt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),At=0;function Mt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function at(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:c={},easing:s="ease-out",speed:m=1,once:u=false,axis:l="y",scrollContainer:d,native:T=true,onProgress:Y,onComplete:b}=n,re=window.matchMedia("(prefers-reduced-motion: reduce)").matches,we=typeof s=="function"?s:le[s]??le["ease-out"],q=me(c.start??"top bottom"),ne=me(c.end??"bottom top"),A=typeof d=="string"?document.querySelector(d):d??null,N=Object.entries(t).map(([a,p])=>({prop:xt(a),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function M(){let a=window.getComputedStyle(e);for(let p of N)p.from===""&&(p.from=a.getPropertyValue(p.prop).trim()||"0");}function B(){for(let a of N)e.style.setProperty(a.prop,String(a.to));}if(re)return B(),b?.(),r;M();function O(){if(!T||!Mt()||typeof s!="string"||!(s in it)||l!=="y"||A||u||m!==1||Y||b||(c.start??"top bottom").trim()!=="top bottom"||(c.end??"bottom top").trim()!=="bottom top")return false;for(let a of N)if(!Tt.has(a.prop))return false;return true}function $(){let a=`ssd-a-${++At}`,p=N.map(C=>`${C.prop}:${C.from}`).join(";"),K=N.map(C=>`${C.prop}:${C.to}`).join(";"),k=document.createElement("style");k.setAttribute("data-ssd-animate",""),k.textContent=`@keyframes ${a}{from{${p}}to{${K}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${it[s]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(k),e.classList.add(a);let G=()=>l==="x"?window.scrollX:window.scrollY,Q=()=>l==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),k.remove();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(C){let V=Math.min(1,Math.max(0,C));e.classList.remove(a);for(let ae of N)e.style.setProperty(ae.prop,st(ae.from,ae.to,V));},getProgress(){let C=e.getBoundingClientRect(),V=G(),ae=Q(),{tStart:X,tEnd:W}=he({top:C.top,height:C.height},V,ae,q,ne);return we(ee(V,X,W,m))}}}if(O())return $();let D=0,H=0,R=0,I=false,z=false,E=-1,U=0,ce=false,ie=()=>A?l==="x"?A.scrollLeft:A.scrollTop:l==="x"?window.scrollX:window.scrollY,pe=()=>A?l==="x"?A.clientWidth:A.clientHeight:l==="x"?window.innerWidth:window.innerHeight;function f(){let a=e.getBoundingClientRect(),p,K;if(A){let G=A.getBoundingClientRect();p=l==="x"?a.left-G.left+A.scrollLeft:a.top-G.top+A.scrollTop,K=l==="x"?a.width:a.height;}else p=l==="x"?a.left:a.top,K=l==="x"?a.width:a.height;let k=he({top:p,height:K},ie(),pe(),q,ne);D=k.tStart,H=k.tEnd;}function P(a){e.style.setProperty("--scroll-draw-progress",String(a));for(let p of N)e.style.setProperty(p.prop,st(p.from,p.to,a));Y?.(a);}function h(){if(!I||z)return;let a=we(ee(ie(),D,H,m));u&&(E=Math.max(E,a),a=E),U=a,P(a),a>=1&&!ce?(ce=true,b?.()):a<1&&!u&&(ce=false),R=requestAnimationFrame(h);}f();{let a=we(ee(ie(),D,H,m));u&&a>0&&(E=a),U=a,P(a);}let x=new IntersectionObserver(a=>{a.forEach(p=>{I=p.isIntersecting,I&&!z?R=requestAnimationFrame(h):cancelAnimationFrame(R);});},{root:A??null}),Z;function be(){clearTimeout(Z),Z=setTimeout(f,150);}return window.addEventListener("resize",be),window.addEventListener("orientationchange",be),x.observe(e),Pe(e,{type:"animate",getProgress:()=>U,getTrigger:()=>({tStart:D,tEnd:H})}),{destroy(){cancelAnimationFrame(R),x.disconnect(),window.removeEventListener("resize",be),window.removeEventListener("orientationchange",be),clearTimeout(Z),Le(e);},replay(){E=-1,ce=false,U=0,z=false,P(0);},pause(){z=true,cancelAnimationFrame(R);},resume(){z&&(z=false,I&&(R=requestAnimationFrame(h)));},seek(a){let p=Math.min(1,Math.max(0,a));U=p,E=p,z=true,cancelAnimationFrame(R),P(p);},getProgress(){return U}}}var Ge={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function je(e,n){if(typeof window>"u")return Ge;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Ge;let t=r,{from:c=0,to:s,format:m,easing:u="ease-out",trigger:l={},once:d=true,decimals:T,onComplete:Y}=n,b=T!==void 0?f=>f.toFixed(T):m??(f=>String(Math.round(f))),re=typeof u=="function"?u:le[u]??le["ease-out"],we=me(l.start??"top 80%"),q=me(l.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=b(s),Y?.(),Ge;t.textContent=b(c);let A=0,N=0,M=0,B=false,O=false,$=-1,D=0,H=false,R=()=>window.scrollY,I=()=>window.innerHeight;function z(){let f=t.getBoundingClientRect(),P=he({top:f.top,height:f.height},R(),I(),we,q);A=P.tStart,N=P.tEnd;}function E(f){t.textContent=b(c+(s-c)*f),t.style.setProperty("--scroll-draw-progress",String(f));}function U(){if(!B||O)return;let f=re(ee(R(),A,N,1));d&&($=Math.max($,f),f=$),D=f,E(f),f>=1&&!H?(H=true,Y?.()):f<1&&!d&&(H=false),M=requestAnimationFrame(U);}z();{let f=re(ee(R(),A,N,1));d&&f>0&&($=f),D=f,E(f);}let ce=new IntersectionObserver(f=>{f.forEach(P=>{B=P.isIntersecting,B&&!O?M=requestAnimationFrame(U):cancelAnimationFrame(M);});}),ie;function pe(){clearTimeout(ie),ie=setTimeout(z,150);}return window.addEventListener("resize",pe),window.addEventListener("orientationchange",pe),ce.observe(t),Pe(t,{type:"counter",getProgress:()=>D,getTrigger:()=>({tStart:A,tEnd:N})}),{destroy(){cancelAnimationFrame(M),ce.disconnect(),window.removeEventListener("resize",pe),window.removeEventListener("orientationchange",pe),clearTimeout(ie),Le(t);},replay(){$=-1,H=false,D=0,O=false,E(0);},pause(){O=true,cancelAnimationFrame(M);},resume(){O&&(O=false,B&&(M=requestAnimationFrame(U)));},seek(f){let P=Math.min(1,Math.max(0,f));D=P,$=P,O=true,cancelAnimationFrame(M),E(P);},getProgress(){return D}}}function ut(e){let n=e.textContent??"";return e.textContent="",n.split(/(\s+)/).filter(Boolean).map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(r)?(t.textContent=r,t.style.whiteSpace="pre"):(t.textContent=r,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(r)?null:t}).filter(r=>r!==null)}function $t(e){let n=e.textContent??"";return e.textContent="",n.split("").map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=r,r===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),r===" "?null:t}).filter(r=>r!==null)}function lt(e){let n=ut(e),r=new Map;for(let s of n){let m=s.offsetTop;r.has(m)||r.set(m,[]),r.get(m).push(s);}let t=[],c=Array.from(r.keys()).sort((s,m)=>s-m);for(let s of c){let m=r.get(s),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block";for(let l of m)u.appendChild(l);t.push(u);}e.textContent="";for(let s of t)e.appendChild(s),e.appendChild(document.createTextNode(" "));return t}function Ct(e,n,r,t){if(r<=1||t===0)return e;let c=(r-1)*t,s=n*t,m=s+(1-c);return m<=s?e>=s?1:0:Math.min(1,Math.max(0,(e-s)/(m-s)))}function Pt(e,n){let r=[];if(n?.y!==void 0&&r.push(`translateY(${n.y*(1-e)}px)`),n?.x!==void 0&&r.push(`translateX(${n.x*(1-e)}px)`),n?.rotate!==void 0&&r.push(`rotate(${n.rotate*(1-e)}deg)`),n?.scale!==void 0){let t=n.scale+(1-n.scale)*e;r.push(`scale(${t})`);}return r.join(" ")||""}var ct={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function mt(e,n={}){if(typeof window>"u")return ct;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollText: element not found:",e),ct;let t=r,{split:c="words",stagger:s=.04,easing:m="ease-out",from:u={opacity:0,y:24},trigger:l={},once:d=true,onComplete:T}=n,Y=window.matchMedia("(prefers-reduced-motion: reduce)").matches,b=typeof m=="function"?m:le[m]??le["ease-out"],re=me(l.start??"top 85%"),we=me(l.end??"top 40%"),q=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let ne;c==="chars"?ne=$t(t):c==="lines"?ne=lt(t):ne=ut(t);let A=ne.length;function N(h,x){u?.opacity!==void 0&&(h.style.opacity=String(u.opacity+(1-u.opacity)*x));let Z=Pt(x,u);Z&&(h.style.transform=Z);}function M(h){t.style.setProperty("--scroll-draw-progress",String(h)),ne.forEach((x,Z)=>{let be=b(Ct(h,Z,A,s));N(x,be);});}if(Y)return M(1),T?.(),{destroy(){t.innerHTML=q,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};M(0);let B=0,O=0,$=0,D=false,H=false,R=-1,I=0,z=false,E=()=>window.scrollY,U=()=>window.innerHeight;function ce(){let h=t.getBoundingClientRect(),x=he({top:h.top,height:h.height},E(),U(),re,we);B=x.tStart,O=x.tEnd;}function ie(){if(!D||H)return;let h=ee(E(),B,O,1);d&&(R=Math.max(R,h),h=R),I=h,M(h),h>=1&&!z?(z=true,T?.()):h<1&&!d&&(z=false),$=requestAnimationFrame(ie);}ce();let pe=new IntersectionObserver(h=>{h.forEach(x=>{D=x.isIntersecting,D&&!H?$=requestAnimationFrame(ie):cancelAnimationFrame($);});}),f;function P(){clearTimeout(f),f=setTimeout(()=>{if(c==="lines"){let h=I;t.innerHTML=q,t.setAttribute("aria-label",t.textContent??""),ne=lt(t),M(h);}ce();},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),pe.observe(t),Pe(t,{type:"text",getProgress:()=>I,getTrigger:()=>({tStart:B,tEnd:O})}),{destroy(){cancelAnimationFrame($),pe.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),clearTimeout(f),t.innerHTML=q,t.removeAttribute("aria-label"),Le(t);},replay(){R=-1,z=false,I=0,H=false,M(0);},pause(){H=true,cancelAnimationFrame($);},resume(){H&&(H=false,D&&($=requestAnimationFrame(ie)));},seek(h){let x=Math.min(1,Math.max(0,h));I=x,R=x,H=true,cancelAnimationFrame($),M(x);},getProgress(){return I}}}function Lt(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let t=typeof e=="string"?document.querySelector(e):e;return t?qe(t,n):(console.warn("[svg-scroll-draw] Container not found:",e),r)}function kt(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(n=>{let r={};try{let t=n.dataset.scrollDrawOptions??n.dataset.scrollDrawoptions??"";t&&(r=JSON.parse(t));}catch{}return qe(n,r)})}function Ot(e=document){return Array.from(e.querySelectorAll("[data-scroll-animate]")).map(n=>{let r={props:{}};try{let t=n.dataset.scrollAnimateOptions??"";t&&(r=JSON.parse(t));}catch{}return at(n,r)})}function Dt(e=document){return Array.from(e.querySelectorAll("[data-scroll-counter]")).map(n=>{let r={};try{let t=n.dataset.scrollCounterOptions??"";t&&(r=JSON.parse(t));}catch{}return !r.to&&r.to!==0&&(process.env.NODE_ENV!=="production"&&console.warn('[svg-scroll-draw] initScrollCounter: element missing "to" in options JSON:',n),r.to=0),je(n,r)})}function It(e=document){return Array.from(e.querySelectorAll("[data-scroll-text]")).map(n=>{let r={};try{let t=n.dataset.scrollTextOptions??"";t&&(r=JSON.parse(t));}catch{}return mt(n,r)})}function fr(e=document){return {draw:kt(e),animate:Ot(e),counter:Dt(e),text:It(e)}}export{fr as initAll,Ot as initScrollAnimate,Dt as initScrollCounter,kt as initScrollDraw,It as initScrollText,Lt as scrollDraw};
|
|
1
|
+
function ot({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),m=Math.sqrt(t),s=0,f=[];for(let g=0;g<r;g++){let A=Math.pow(m,g);f.push(A),s+=A;}let p=[0],c=0;for(let g=0;g<r;g++)c+=f[g]/s,p.push(c);return g=>{if(g<=0)return 0;if(g>=1)return 1;for(let A=0;A<r;A++)if(g<=p[A+1]){let _=(g-p[A])/(p[A+1]-p[A]);if(A===0)return _*(2-_);let v=1-Math.pow(t,A);return v+(1-v)*(2*_-1)*(2*_-1)}return 1}}function st({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),m=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return s=>s<=0?0:s>=1?1:r*Math.pow(2,-10*s)*Math.sin((s-m)*(2*Math.PI)/t)+1}var ae={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:ot(),elastic:st()};function me(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",t="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:t}}function tt(e,n,r,t){switch(t){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function rt(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function We(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function vt(e,n,r){return Math.min(r,Math.max(n,e))}function K(e,n,r,t){return r===n?0:vt((e-n)/(r-n)*t,0,1)}function be(e,n,r,t,m){let s=tt(e.top,e.height,n,t.element)-rt(t.viewport,r),f=tt(e.top,e.height,n,m.element)-rt(m.viewport,r);return {tStart:s,tEnd:f}}function nt(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let t=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return t?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]:null}function Oe(e,n,r){let t=nt(e),m=nt(n);return !t||!m?e:`rgb(${Math.round(t[0]+(m[0]-t[0])*r)},${Math.round(t[1]+(m[1]-t[1])*r)},${Math.round(t[2]+(m[2]-t[2])*r)})`}var Xe={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};function it(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n);}var at={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Et=0;function xt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Tt(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?it("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&it("Element has a fill \u2014 it may obscure the stroke animation.",e);}function At(e,n,r){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function m(){let s=r==="x"?window.scrollX:window.scrollY,f=e-s,p=n-s,c=r==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`left:${f}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${f}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
+
<div style="position:absolute;${c?`left:${p}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${p}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",m,{passive:true}),m(),t}function Je(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),m=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let f=parseFloat(s),p=t[m++]??f;return String(+(f+(p-f)*r).toFixed(4))})}function _e(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,m=r?{...Xe[r],...t}:t,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:f="path, polyline, line, polygon, rect, circle",speed:p=1,fade:c=false,easing:g="linear",trigger:A={},stagger:_=0,direction:v="forward",once:Q=false,debug:ve=false,axis:I="y",scrollContainer:te,autoReverse:ie=false,delay:J=0,strokeColor:x,strokeWidth:N,fillOpacity:b,waypoints:S,velocityScale:q=false,threshold:G=0,rootMargin:re="0px",repeat:z=0,repeatDelay:F=0,morphTo:T,clip:j,autoplay:le=false,duration:Y=1e3,native:U=true,onProgress:d,onStart:M,onComplete:y,onEnter:k,onLeave:we,onEnterBack:Ae,onLeaveBack:Me}=m,ge=j===true?"left":typeof j=="string"?j:false,pe=typeof g=="function"?g:ae[g]??ae.linear,Ne=me(A.start??"top bottom"),Le=me(A.end??"bottom top"),V=typeof te=="string"?document.querySelector(te):te??null,i=Array.isArray(x)?x[0]:null,u=Array.isArray(x)?x[1]:typeof x=="string"?x:null,H=Array.isArray(N)?N[0]:null,P=Array.isArray(N)?N[1]:typeof N=="number"?N:null,B=Array.isArray(b)?b[0]:null,Z=Array.isArray(b)?b[1]:typeof b=="number"?b:null;function W(o){let a=o*100;switch(ge){case "right":return `inset(0 0 0 ${100-a}%)`;case "top":return `inset(0 0 ${100-a}% 0)`;case "bottom":return `inset(${100-a}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-a}% 0 0)`}}let D=ge?[]:Array.from(e.querySelectorAll(f)),C=[],ce=[],fe=0,Ee=0,ee=false,de=false,X=0,He=false,ye=-1,Re=-1,ne=false,Ce=0,Se=0,xe,Ge=null,Te=new Set,qe=-1,Ke=performance.now(),Pe=NaN;function Fe(){return V?I==="x"?V.scrollLeft:V.scrollTop:I==="x"?window.scrollX:window.scrollY}function Qe(){return V?I==="x"?V.clientWidth:V.clientHeight:I==="x"?window.innerWidth:window.innerHeight}function et(){let o=e.getBoundingClientRect(),a,w,R;if(V){let se=V.getBoundingClientRect();a=I==="x"?o.left-se.left+V.scrollLeft:o.top-se.top+V.scrollTop,w=I==="x"?o.width:o.height,R=Fe();}else a=I==="x"?o.left:o.top,w=I==="x"?o.width:o.height,R=Fe();let oe=be({top:a,height:w},R,Qe(),Ne,Le);fe=oe.tStart,Ee=oe.tEnd,ve&&process.env.NODE_ENV!=="production"&&(Ge?.remove(),Ge=At(fe,Ee,I));}function ht(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),ge){let w=a==="reverse"?1-o:o;e.style.clipPath=W(w);return}D.forEach((w,R)=>{w.style.strokeDashoffset=a==="reverse"?`${C[R]*o}`:`${C[R]*(1-o)}`,c&&(w.style.opacity=a==="reverse"?`${1-o}`:`${o}`),i&&u?w.style.stroke=Oe(i,u,o):u&&(w.style.stroke=u),H!==null&&P!==null?w.style.strokeWidth=`${H+(P-H)*o}`:P!==null&&(w.style.strokeWidth=`${P}`),B!==null&&Z!==null?w.style.fillOpacity=`${B+(Z-B)*o}`:Z!==null&&(w.style.fillOpacity=`${Z}`),T&&w.tagName.toLowerCase()==="path"&&ce[R]&&w.setAttribute("d",Je(ce[R],T,o));});}function ze(){if(e.style.setProperty("--scroll-draw-progress","0"),ge){e.style.clipPath=W(0);return}D.forEach((o,a)=>{o.style.strokeDasharray=`${C[a]}`,o.style.strokeDashoffset=v==="reverse"?"0":`${C[a]}`,c?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",i&&(o.style.stroke=i),H!==null&&(o.style.strokeWidth=`${H}`),B!==null&&(o.style.fillOpacity=`${B}`),T&&o.tagName.toLowerCase()==="path"&&ce[a]&&o.setAttribute("d",ce[a]);});}if(D.forEach(o=>{Tt(o);let a=We(o);C.push(a),o.tagName.toLowerCase()==="path"?ce.push(o.getAttribute("d")??""):ce.push(""),s?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=v==="reverse"?`${a}`:"0",c&&(o.style.opacity="1"),u&&(o.style.stroke=u),P!==null&&(o.style.strokeWidth=`${P}`),Z!==null&&(o.style.fillOpacity=`${Z}`),T&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",T)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=v==="reverse"?"0":`${a}`,c?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",i&&(o.style.stroke=i),H!==null&&(o.style.strokeWidth=`${H}`),B!==null&&(o.style.fillOpacity=`${B}`));}),ge){if(s)return e.style.clipPath=W(1),y?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=W(0);}else if(s)return y?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function bt(){return !(U===false||!xt()||!D.length||typeof g!="string"||!(g in at)||ge||I!=="y"||V||p!==1||_!==0||Q||ie||q!==false||T||S||z||J>0||d||M||y||k||we||Ae||Me||x!=null||N!=null||b!=null||(A.start??"top bottom").trim()!=="top bottom"||(A.end??"bottom top").trim()!=="bottom top")}function wt(){let o=`svg-scroll-draw-${++Et}`,a=v==="reverse"?"0":"var(--ssd-len)",w=v==="reverse"?"var(--ssd-len)":"0",R=`stroke-dashoffset:${a};`,oe=`stroke-dashoffset:${w};`;c&&(R+=`opacity:${v==="reverse"?1:0};`,oe+=`opacity:${v==="reverse"?0:1};`);let se=document.createElement("style");se.setAttribute("data-svg-scroll-draw",""),se.textContent=`@keyframes ${o}{from{${R}}to{${oe}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${at[g]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(se);function ue(l,E){l.style.setProperty("--ssd-len",String(C[E])),l.style.strokeDasharray=`${C[E]}`,l.style.strokeDashoffset="",l.style.opacity="",l.style.animationPlayState="",l.classList.add(o);}D.forEach(ue);let h=false,$=-1;function L(){if($>=0)return $;let l=e.getBoundingClientRect(),{tStart:E,tEnd:O}=be({top:l.top,height:l.height},Fe(),Qe(),Ne,Le);return pe(K(Fe(),E,O,p))}return {destroy(){D.forEach(l=>{l.classList.remove(o),l.style.removeProperty("--ssd-len"),l.style.animationPlayState="";}),se.remove();},replay(){h=false,$=-1,D.forEach(ue);},pause(){h=true,D.forEach(l=>{l.style.animationPlayState="paused";});},resume(){h&&(h=false,D.forEach(l=>{l.style.animationPlayState="running";}));},seek(l){let E=Math.min(1,Math.max(0,l));$=E,h=true,D.forEach((O,$e)=>{O.classList.remove(o),O.style.strokeDashoffset=v==="reverse"?`${C[$e]*E}`:`${C[$e]*(1-E)}`,c&&(O.style.opacity=v==="reverse"?`${1-E}`:`${E}`);});},getProgress(){return L()}}}if(bt())return wt();function St(){let o=Math.max(1,Y),a=0,w=0;function R(L){let l=true;if(ge){let E=Math.min(1,Math.max(0,L/o)),O=pe(E);Ce=O,e.style.setProperty("--scroll-draw-progress",String(O)),e.style.clipPath=W(v==="reverse"?1-O:O),d?.(O),E<1&&(l=false);}else D.forEach((E,O)=>{let $e=O*_*o,ke=Math.min(1,Math.max(0,(L-$e)/o)),he=pe(ke);E.style.strokeDashoffset=v==="reverse"?`${C[O]*he}`:`${C[O]*(1-he)}`,c&&(E.style.opacity=v==="reverse"?`${1-he}`:`${he}`),i&&u?E.style.stroke=Oe(i,u,he):u&&(E.style.stroke=u),H!==null&&P!==null?E.style.strokeWidth=`${H+(P-H)*he}`:P!==null&&(E.style.strokeWidth=`${P}`),B!==null&&Z!==null?E.style.fillOpacity=`${B+(Z-B)*he}`:Z!==null&&(E.style.fillOpacity=`${Z}`),T&&E.tagName.toLowerCase()==="path"&&ce[O]&&E.setAttribute("d",Je(ce[O],T,he)),O===0&&(d?.(he),e.style.setProperty("--scroll-draw-progress",String(he))),ke<1&&(l=false);});if(S){let E=Math.min(1,Math.max(0,L/o)),O=pe(E);for(let $e in S){let ke=parseFloat($e);O>=ke&&!Te.has(ke)&&(Te.add(ke),S[$e]?.());}}return l}function oe(L){if(ne)return;let l=L-a;de||(de=true,M?.());let E=R(l);if(E&&!ee){ee=true,R(o*(1+Math.max(0,D.length-1)*_)),y?.(),Se<(z==="infinite"?1/0:z??0)&&(Se++,xe=setTimeout(()=>{a=performance.now(),de=false,ee=false,Te.clear(),ze(),X=requestAnimationFrame(oe);},F));return}E||(X=requestAnimationFrame(oe));}function se(){cancelAnimationFrame(X),clearTimeout(xe),a=performance.now(),w=0,ne=false,de=false,ee=false,Se=0,Te.clear(),ze(),X=requestAnimationFrame(oe);}let ue=new IntersectionObserver(L=>{L.forEach(l=>{l.isIntersecting&&!(Q&&ee)?se():!l.isIntersecting&&!Q&&!ee&&(cancelAnimationFrame(X),clearTimeout(xe),a=null);});},{root:V??null,threshold:G,rootMargin:re}),h;function $(){clearTimeout(h),h=setTimeout(()=>{D.forEach((L,l)=>{C[l]=We(L),L.style.strokeDasharray=`${C[l]}`;});},150);}return window.addEventListener("resize",$),window.addEventListener("orientationchange",$),J>0?setTimeout(()=>ue.observe(e),J):ue.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(xe),ue.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),clearTimeout(h);},replay(){Se=0,se();},pause(){ne||(ne=true,w=performance.now()-a,cancelAnimationFrame(X));},resume(){ne&&(ne=false,a=performance.now()-w,X=requestAnimationFrame(oe));},seek(L){let l=Math.min(1,Math.max(0,L));Ce=l,ne=true,w=l*o,a=performance.now()-w,cancelAnimationFrame(X),R(w);},getProgress(){return Ce}}}if(le)return St();et();function Ve(){if(!He||ne)return;let o=performance.now(),a=Fe(),w=p;if(q!==false){let h=o-Ke,$=h>0?Math.abs(a-(qe<0?a:qe))/h:0;w=p*Math.max(.2,1+$*(typeof q=="number"?q:1)*.04);}qe=a,Ke=o;let R=ie?Re===-1||a>=Re?"forward":"reverse":v;Re=a;let oe=Ee-fe,se=true,ue=oe===0?0:(a-fe)/oe;if(isNaN(Pe)||(Pe<=0&&ue>0?k?.():Pe>0&&ue<=0&&Me?.(),Pe<1&&ue>=1?we?.():Pe>=1&&ue<1&&Ae?.()),Pe=ue,ge){let h=pe(K(a,fe,Ee,w));Q&&!ie&&(ye=Math.max(ye,h),h=ye),Ce=h,e.style.setProperty("--scroll-draw-progress",String(h));let $=R==="reverse"?1-h:h;e.style.clipPath=W($),d?.(h),!de&&K(a,fe,Ee,w)>0&&(de=true,M?.()),h>=1&&!ee?(ee=true,y?.(),Se<(z==="infinite"?1/0:z??0)&&(Se++,xe=setTimeout(()=>{ye=-1,de=false,ee=false,e.style.clipPath=W(0);},F))):h<1&&!Q&&(ee=false),X=requestAnimationFrame(Ve);return}if(D.forEach((h,$)=>{let L=$*_*oe,l=pe(K(a,fe+L,Ee+L,w));Q&&!ie&&(ye=Math.max(ye,l),l=ye),Ce=l,h.style.strokeDashoffset=R==="reverse"?`${C[$]*l}`:`${C[$]*(1-l)}`,c&&(h.style.opacity=R==="reverse"?`${1-l}`:`${l}`),i&&u?h.style.stroke=Oe(i,u,l):u&&(h.style.stroke=u),H!==null&&P!==null?h.style.strokeWidth=`${H+(P-H)*l}`:P!==null&&(h.style.strokeWidth=`${P}`),B!==null&&Z!==null?h.style.fillOpacity=`${B+(Z-B)*l}`:Z!==null&&(h.style.fillOpacity=`${Z}`),T&&h.tagName.toLowerCase()==="path"&&ce[$]&&h.setAttribute("d",Je(ce[$],T,l)),$===0&&(d?.(l),e.style.setProperty("--scroll-draw-progress",String(l))),l<1&&(se=false);}),S){let h=pe(K(a,fe,Ee,w));for(let $ in S){let L=parseFloat($);h>=L&&!Te.has(L)&&(Te.add(L),S[$]?.());}}!de&&K(a,fe,Ee,w)>0&&(de=true,M?.()),se&&!ee?(ee=true,y?.(),Se<(z==="infinite"?1/0:z??0)&&(Se++,xe=setTimeout(()=>{ye=-1,de=false,ee=false,Te.clear(),ze();},F))):!se&&!Q&&(ee=false),X=requestAnimationFrame(Ve);}let je=new IntersectionObserver(o=>{o.forEach(a=>{He=a.isIntersecting,He&&!ne?X=requestAnimationFrame(Ve):cancelAnimationFrame(X);});},{root:V??null,threshold:G,rootMargin:re}),Ye;function Be(){clearTimeout(Ye),Ye=setTimeout(()=>{D.forEach((o,a)=>{C[a]=We(o),o.style.strokeDasharray=`${C[a]}`;}),et();},150);}return window.addEventListener("resize",Be),window.addEventListener("orientationchange",Be),J>0?setTimeout(()=>je.observe(e),J):je.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(xe),je.disconnect(),window.removeEventListener("resize",Be),window.removeEventListener("orientationchange",Be),clearTimeout(Ye),Ge?.remove();},replay(){ye=-1,Re=-1,qe=-1,de=false,ee=false,Se=0,ne=false,Te.clear(),clearTimeout(xe),ze();},pause(){ne=true,cancelAnimationFrame(X);},resume(){ne&&(ne=false,He&&(X=requestAnimationFrame(Ve)));},seek(o){let a=Math.min(1,Math.max(0,o));Ce=a,ye=a,ne=true,cancelAnimationFrame(X),ht(a,v);},getProgress(){return Ce}}}var lt=new Map;function De(e,n){lt.set(e,n);}function Ie(e){lt.delete(e);}function Mt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ct(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let m=[],s=[],f=t[2].trim();if(f)for(let p of f.split(/[\s,]+/)){let c=p.match(/^([-+]?[\d.eE]+)(.*)$/);m.push(c?parseFloat(c[1]):0),s.push(c?c[2]:"");}n.push({fn:t[1],nums:m,units:s});}return n}function Ct(e,n,r){let t=ct(e),m=ct(n);return t.length===0||t.length!==m.length?r<1?e:n:t.map((s,f)=>{let p=m[f];return s.fn!==p.fn||s.nums.length!==p.nums.length?r<1?`${s.fn}(${s.nums.map((c,g)=>`${c}${s.units[g]}`).join(", ")})`:`${p.fn}(${p.nums.map((c,g)=>`${c}${p.units[g]}`).join(", ")})`:`${s.fn}(${s.nums.map((c,g)=>`${c+(p.nums[g]-c)*r}${s.units[g]}`).join(", ")})`}).join(" ")}function ut(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),m=String(n);if(Mt(t))return Oe(t,m,r);if(t.includes("("))return Ct(t,m,r);let s=t.match(/^([-+]?[\d.]+)(.*)$/),f=m.match(/^([-+]?[\d.]+)(.*)$/);if(s&&f){let p=parseFloat(s[1]),c=parseFloat(f[1]);return `${p+(c-p)*r}${s[2]||f[2]}`}return r<1?t:m}function $t(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var mt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Lt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Pt=0;function kt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function pt(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:m={},easing:s="ease-out",speed:f=1,once:p=false,axis:c="y",scrollContainer:g,native:A=true,onProgress:_,onComplete:v,onEnter:Q,onLeave:ve,onEnterBack:I,onLeaveBack:te}=n,ie=window.matchMedia("(prefers-reduced-motion: reduce)").matches,J=typeof s=="function"?s:ae[s]??ae["ease-out"],x=me(m.start??"top bottom"),N=me(m.end??"bottom top"),b=typeof g=="string"?document.querySelector(g):g??null,S=Object.entries(t).map(([i,u])=>({prop:$t(i),from:Array.isArray(u)?u[0]:"",to:Array.isArray(u)?u[1]:u}));function q(){let i=window.getComputedStyle(e);for(let u of S)u.from===""&&(u.from=i.getPropertyValue(u.prop).trim()||"0");}function G(){for(let i of S)e.style.setProperty(i.prop,String(i.to));}if(ie)return G(),v?.(),r;q();function re(){if(!A||!kt()||typeof s!="string"||!(s in mt)||c!=="y"||b||p||f!==1||_||v||Q||ve||I||te||(m.start??"top bottom").trim()!=="top bottom"||(m.end??"bottom top").trim()!=="bottom top")return false;for(let i of S)if(!Lt.has(i.prop))return false;return true}function z(){let i=`ssd-a-${++Pt}`,u=S.map(W=>`${W.prop}:${W.from}`).join(";"),H=S.map(W=>`${W.prop}:${W.to}`).join(";"),P=document.createElement("style");P.setAttribute("data-ssd-animate",""),P.textContent=`@keyframes ${i}{from{${u}}to{${H}}}.${i}{animation-name:${i};animation-duration:auto;animation-timing-function:${mt[s]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(P),e.classList.add(i);let B=()=>c==="x"?window.scrollX:window.scrollY,Z=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(i),P.remove();},replay(){e.classList.remove(i),e.offsetWidth,e.classList.add(i);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(W){let D=Math.min(1,Math.max(0,W));e.classList.remove(i);for(let C of S)e.style.setProperty(C.prop,ut(C.from,C.to,D));},getProgress(){let W=e.getBoundingClientRect(),D=B(),C=Z(),{tStart:ce,tEnd:fe}=be({top:W.top,height:W.height},D,C,x,N);return J(K(D,ce,fe,f))}}}if(re())return z();let F=0,T=0,j=0,le=false,Y=false,U=-1,d=0,M=false,y=NaN,k=()=>b?c==="x"?b.scrollLeft:b.scrollTop:c==="x"?window.scrollX:window.scrollY,we=()=>b?c==="x"?b.clientWidth:b.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function Ae(){let i=e.getBoundingClientRect(),u,H;if(b){let B=b.getBoundingClientRect();u=c==="x"?i.left-B.left+b.scrollLeft:i.top-B.top+b.scrollTop,H=c==="x"?i.width:i.height;}else u=c==="x"?i.left:i.top,H=c==="x"?i.width:i.height;let P=be({top:u,height:H},k(),we(),x,N);F=P.tStart,T=P.tEnd;}function Me(i){e.style.setProperty("--scroll-draw-progress",String(i));for(let u of S)e.style.setProperty(u.prop,ut(u.from,u.to,i));_?.(i);}function ge(i){if(isNaN(y)){y=i;return}y<=0&&i>0?Q?.():y>0&&i<=0&&te?.(),y<1&&i>=1?ve?.():y>=1&&i<1&&I?.(),y=i;}function pe(){if(!le||Y)return;let i=T===F?0:(k()-F)/(T-F);ge(i);let u=J(K(k(),F,T,f));p&&(U=Math.max(U,u),u=U),d=u,Me(u),u>=1&&!M?(M=true,v?.()):u<1&&!p&&(M=false),j=requestAnimationFrame(pe);}Ae();{let i=J(K(k(),F,T,f));p&&i>0&&(U=i),d=i,Me(i);}let Ne=new IntersectionObserver(i=>{i.forEach(u=>{le=u.isIntersecting,le&&!Y?j=requestAnimationFrame(pe):cancelAnimationFrame(j);});},{root:b??null}),Le;function V(){clearTimeout(Le),Le=setTimeout(Ae,150);}return window.addEventListener("resize",V),window.addEventListener("orientationchange",V),Ne.observe(e),De(e,{type:"animate",getProgress:()=>d,getTrigger:()=>({tStart:F,tEnd:T})}),{destroy(){cancelAnimationFrame(j),Ne.disconnect(),window.removeEventListener("resize",V),window.removeEventListener("orientationchange",V),clearTimeout(Le),Ie(e);},replay(){U=-1,M=false,d=0,Y=false,Me(0);},pause(){Y=true,cancelAnimationFrame(j);},resume(){Y&&(Y=false,le&&(j=requestAnimationFrame(pe)));},seek(i){let u=Math.min(1,Math.max(0,i));d=u,U=u,Y=true,cancelAnimationFrame(j),Me(u);},getProgress(){return d}}}var Ue={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ze(e,n){if(typeof window>"u")return Ue;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Ue;let t=r,{from:m=0,to:s,format:f,easing:p="ease-out",trigger:c={},once:g=true,decimals:A,onComplete:_}=n,v=A!==void 0?d=>d.toFixed(A):f??(d=>String(Math.round(d))),Q=typeof p=="function"?p:ae[p]??ae["ease-out"],ve=me(c.start??"top 80%"),I=me(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=v(s),_?.(),Ue;t.textContent=v(m);let ie=0,J=0,x=0,N=false,b=false,S=-1,q=0,G=false,re=()=>window.scrollY,z=()=>window.innerHeight;function F(){let d=t.getBoundingClientRect(),M=be({top:d.top,height:d.height},re(),z(),ve,I);ie=M.tStart,J=M.tEnd;}function T(d){t.textContent=v(m+(s-m)*d),t.style.setProperty("--scroll-draw-progress",String(d));}function j(){if(!N||b)return;let d=Q(K(re(),ie,J,1));g&&(S=Math.max(S,d),d=S),q=d,T(d),d>=1&&!G?(G=true,_?.()):d<1&&!g&&(G=false),x=requestAnimationFrame(j);}F();{let d=Q(K(re(),ie,J,1));g&&d>0&&(S=d),q=d,T(d);}let le=new IntersectionObserver(d=>{d.forEach(M=>{N=M.isIntersecting,N&&!b?x=requestAnimationFrame(j):cancelAnimationFrame(x);});}),Y;function U(){clearTimeout(Y),Y=setTimeout(F,150);}return window.addEventListener("resize",U),window.addEventListener("orientationchange",U),le.observe(t),De(t,{type:"counter",getProgress:()=>q,getTrigger:()=>({tStart:ie,tEnd:J})}),{destroy(){cancelAnimationFrame(x),le.disconnect(),window.removeEventListener("resize",U),window.removeEventListener("orientationchange",U),clearTimeout(Y),Ie(t);},replay(){S=-1,G=false,q=0,b=false,T(0);},pause(){b=true,cancelAnimationFrame(x);},resume(){b&&(b=false,N&&(x=requestAnimationFrame(j)));},seek(d){let M=Math.min(1,Math.max(0,d));q=M,S=M,b=true,cancelAnimationFrame(x),T(M);},getProgress(){return q}}}function gt(e){let n=e.textContent??"";return e.textContent="",n.split(/(\s+)/).filter(Boolean).map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(r)?(t.textContent=r,t.style.whiteSpace="pre"):(t.textContent=r,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(r)?null:t}).filter(r=>r!==null)}function Ot(e){let n=e.textContent??"";return e.textContent="",n.split("").map(r=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=r,r===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),r===" "?null:t}).filter(r=>r!==null)}function ft(e){let n=gt(e),r=new Map;for(let s of n){let f=s.offsetTop;r.has(f)||r.set(f,[]),r.get(f).push(s);}let t=[],m=Array.from(r.keys()).sort((s,f)=>s-f);for(let s of m){let f=r.get(s),p=document.createElement("span");p.setAttribute("aria-hidden","true"),p.style.display="inline-block";for(let c of f)p.appendChild(c);t.push(p);}e.textContent="";for(let s of t)e.appendChild(s),e.appendChild(document.createTextNode(" "));return t}function Dt(e,n,r,t){if(r<=1||t===0)return e;let m=(r-1)*t,s=n*t,f=s+(1-m);return f<=s?e>=s?1:0:Math.min(1,Math.max(0,(e-s)/(f-s)))}function It(e,n){let r=[];if(n?.y!==void 0&&r.push(`translateY(${n.y*(1-e)}px)`),n?.x!==void 0&&r.push(`translateX(${n.x*(1-e)}px)`),n?.rotate!==void 0&&r.push(`rotate(${n.rotate*(1-e)}deg)`),n?.scale!==void 0){let t=n.scale+(1-n.scale)*e;r.push(`scale(${t})`);}return r.join(" ")||""}var dt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function yt(e,n={}){if(typeof window>"u")return dt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollText: element not found:",e),dt;let t=r,{split:m="words",stagger:s=.04,easing:f="ease-out",from:p={opacity:0,y:24},trigger:c={},once:g=true,onComplete:A}=n,_=window.matchMedia("(prefers-reduced-motion: reduce)").matches,v=typeof f=="function"?f:ae[f]??ae["ease-out"],Q=me(c.start??"top 85%"),ve=me(c.end??"top 40%"),I=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let te;m==="chars"?te=Ot(t):m==="lines"?te=ft(t):te=gt(t);let ie=te.length;function J(y,k){p?.opacity!==void 0&&(y.style.opacity=String(p.opacity+(1-p.opacity)*k));let we=It(k,p);we&&(y.style.transform=we);}function x(y){t.style.setProperty("--scroll-draw-progress",String(y)),te.forEach((k,we)=>{let Ae=v(Dt(y,we,ie,s));J(k,Ae);});}if(_)return x(1),A?.(),{destroy(){t.innerHTML=I,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};x(0);let N=0,b=0,S=0,q=false,G=false,re=-1,z=0,F=false,T=()=>window.scrollY,j=()=>window.innerHeight;function le(){let y=t.getBoundingClientRect(),k=be({top:y.top,height:y.height},T(),j(),Q,ve);N=k.tStart,b=k.tEnd;}function Y(){if(!q||G)return;let y=K(T(),N,b,1);g&&(re=Math.max(re,y),y=re),z=y,x(y),y>=1&&!F?(F=true,A?.()):y<1&&!g&&(F=false),S=requestAnimationFrame(Y);}le();let U=new IntersectionObserver(y=>{y.forEach(k=>{q=k.isIntersecting,q&&!G?S=requestAnimationFrame(Y):cancelAnimationFrame(S);});}),d;function M(){clearTimeout(d),d=setTimeout(()=>{if(m==="lines"){let y=z;t.innerHTML=I,t.setAttribute("aria-label",t.textContent??""),te=ft(t),x(y);}le();},150);}return window.addEventListener("resize",M),window.addEventListener("orientationchange",M),U.observe(t),De(t,{type:"text",getProgress:()=>z,getTrigger:()=>({tStart:N,tEnd:b})}),{destroy(){cancelAnimationFrame(S),U.disconnect(),window.removeEventListener("resize",M),window.removeEventListener("orientationchange",M),clearTimeout(d),t.innerHTML=I,t.removeAttribute("aria-label"),Ie(t);},replay(){re=-1,F=false,z=0,G=false,x(0);},pause(){G=true,cancelAnimationFrame(S);},resume(){G&&(G=false,q&&(S=requestAnimationFrame(Y)));},seek(y){let k=Math.min(1,Math.max(0,y));z=k,re=k,G=true,cancelAnimationFrame(S),x(k);},getProgress(){return z}}}function Nt(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let t=typeof e=="string"?document.querySelector(e):e;return t?_e(t,n):(console.warn("[svg-scroll-draw] Container not found:",e),r)}function Ft(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(n=>{let r={};try{let t=n.dataset.scrollDrawOptions??n.dataset.scrollDrawoptions??"";t&&(r=JSON.parse(t));}catch{}return _e(n,r)})}function Ht(e=document){return Array.from(e.querySelectorAll("[data-scroll-animate]")).map(n=>{let r={props:{}};try{let t=n.dataset.scrollAnimateOptions??"";t&&(r=JSON.parse(t));}catch{}return pt(n,r)})}function Rt(e=document){return Array.from(e.querySelectorAll("[data-scroll-counter]")).map(n=>{let r={};try{let t=n.dataset.scrollCounterOptions??"";t&&(r=JSON.parse(t));}catch{}return !r.to&&r.to!==0&&(process.env.NODE_ENV!=="production"&&console.warn('[svg-scroll-draw] initScrollCounter: element missing "to" in options JSON:',n),r.to=0),Ze(n,r)})}function qt(e=document){return Array.from(e.querySelectorAll("[data-scroll-text]")).map(n=>{let r={};try{let t=n.dataset.scrollTextOptions??"";t&&(r=JSON.parse(t));}catch{}return yt(n,r)})}function br(e=document){return {draw:Ft(e),animate:Ht(e),counter:Rt(e),text:qt(e)}}export{br as initAll,Ht as initScrollAnimate,Rt as initScrollCounter,Ft as initScrollDraw,qt as initScrollText,Nt as scrollDraw};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var SvgScrollDraw=(()=>{var
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${l?`left:${m}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${m}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`}return document.body.appendChild(n),window.addEventListener("scroll",i,{passive:!0}),i(),n}function Ze(e,r,t){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let d=parseFloat(s),m=n[i++]??d;return String(+(d+(m-d)*t).toFixed(4))})}function He(e,r={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:t,...n}=r,i=t?{...Re[t],...n}:n,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:l=!1,easing:f="linear",trigger:T={},stagger:F=0,direction:E="forward",once:X=!1,debug:ce=!1,axis:A="y",scrollContainer:$,autoReverse:u=!1,delay:h=0,strokeColor:b,strokeWidth:N,fillOpacity:z,waypoints:_,velocityScale:B=!1,threshold:oe=0,rootMargin:U="0px",repeat:Z=0,repeatDelay:J=0,morphTo:k,clip:K,autoplay:de=!1,duration:ge=1e3,native:be=!0,onProgress:g,onStart:R,onComplete:ue}=i,ie=K===!0?"left":typeof K=="string"?K:!1,ae=typeof f=="function"?f:te[f]??te.linear,Ae=he(T.start??"top bottom"),c=he(T.end??"bottom top"),p=typeof $=="string"?document.querySelector($):$??null,G=Array.isArray(b)?b[0]:null,C=Array.isArray(b)?b[1]:typeof b=="string"?b:null,H=Array.isArray(N)?N[0]:null,j=Array.isArray(N)?N[1]:typeof N=="number"?N:null,M=Array.isArray(z)?z[0]:null,I=Array.isArray(z)?z[1]:typeof z=="number"?z:null;function ne(o){let a=o*100;switch(ie){case"right":return`inset(0 0 0 ${100-a}%)`;case"top":return`inset(0 0 ${100-a}% 0)`;case"bottom":return`inset(${100-a}% 0 0 0)`;case"center":return`circle(${o*150}% at 50% 50%)`;default:return`inset(0 ${100-a}% 0 0)`}}let V=ie?[]:Array.from(e.querySelectorAll(d)),D=[],me=[],we=0,ve=0,Y=!1,le=!1,W=0,Ce=!1,fe=-1,Le=-1,Q=!1,Te=0,ye=0,Ee,Be=null,Se=new Set,Ie=-1,et=performance.now();function ke(){return p?A==="x"?p.scrollLeft:p.scrollTop:A==="x"?window.scrollX:window.scrollY}function tt(){return p?A==="x"?p.clientWidth:p.clientHeight:A==="x"?window.innerWidth:window.innerHeight}function rt(){let o=e.getBoundingClientRect(),a,v,O;if(p){let ee=p.getBoundingClientRect();a=A==="x"?o.left-ee.left+p.scrollLeft:o.top-ee.top+p.scrollTop,v=A==="x"?o.width:o.height,O=ke()}else a=A==="x"?o.left:o.top,v=A==="x"?o.width:o.height,O=ke();let se=xe({top:a,height:v},O,tt(),Ae,c);we=se.tStart,ve=se.tEnd,ce&&process.env.NODE_ENV!=="production"&&(Be?.remove(),Be=It(we,ve,A))}function bt(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),ie){let v=a==="reverse"?1-o:o;e.style.clipPath=ne(v);return}V.forEach((v,O)=>{v.style.strokeDashoffset=a==="reverse"?`${D[O]*o}`:`${D[O]*(1-o)}`,l&&(v.style.opacity=a==="reverse"?`${1-o}`:`${o}`),G&&C?v.style.stroke=Pe(G,C,o):C&&(v.style.stroke=C),H!==null&&j!==null?v.style.strokeWidth=`${H+(j-H)*o}`:j!==null&&(v.style.strokeWidth=`${j}`),M!==null&&I!==null?v.style.fillOpacity=`${M+(I-M)*o}`:I!==null&&(v.style.fillOpacity=`${I}`),k&&v.tagName.toLowerCase()==="path"&&me[O]&&v.setAttribute("d",Ze(me[O],k,o))})}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),ie){e.style.clipPath=ne(0);return}V.forEach((o,a)=>{o.style.strokeDasharray=`${D[a]}`,o.style.strokeDashoffset=E==="reverse"?"0":`${D[a]}`,l?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",G&&(o.style.stroke=G),H!==null&&(o.style.strokeWidth=`${H}`),M!==null&&(o.style.fillOpacity=`${M}`),k&&o.tagName.toLowerCase()==="path"&&me[a]&&o.setAttribute("d",me[a])})}if(V.forEach(o=>{Lt(o);let a=Ne(o);D.push(a),o.tagName.toLowerCase()==="path"?me.push(o.getAttribute("d")??""):me.push(""),s?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=E==="reverse"?`${a}`:"0",l&&(o.style.opacity="1"),C&&(o.style.stroke=C),j!==null&&(o.style.strokeWidth=`${j}`),I!==null&&(o.style.fillOpacity=`${I}`),k&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",k)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=E==="reverse"?"0":`${a}`,l?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",G&&(o.style.stroke=G),H!==null&&(o.style.strokeWidth=`${H}`),M!==null&&(o.style.fillOpacity=`${M}`))}),ie){if(s)return e.style.clipPath=ne(1),ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0)}else if(s)return ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function wt(){return!(be===!1||!Ct()||!V.length||typeof f!="string"||!(f in lt)||ie||A!=="y"||p||m!==1||F!==0||X||u||B!==!1||k||_||Z||h>0||g||R||ue||b!=null||N!=null||z!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function vt(){let o=`svg-scroll-draw-${++kt}`,a=E==="reverse"?"0":"var(--ssd-len)",v=E==="reverse"?"var(--ssd-len)":"0",O=`stroke-dashoffset:${a};`,se=`stroke-dashoffset:${v};`;l&&(O+=`opacity:${E==="reverse"?1:0};`,se+=`opacity:${E==="reverse"?0:1};`);let ee=document.createElement("style");ee.setAttribute("data-svg-scroll-draw",""),ee.textContent=`@keyframes ${o}{from{${O}}to{${se}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${lt[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(ee);function w(y,x){y.style.setProperty("--ssd-len",String(D[x])),y.style.strokeDasharray=`${D[x]}`,y.style.strokeDashoffset="",y.style.opacity="",y.style.animationPlayState="",y.classList.add(o)}V.forEach(w);let P=!1,q=-1;function S(){if(q>=0)return q;let y=e.getBoundingClientRect(),{tStart:x,tEnd:L}=xe({top:y.top,height:y.height},ke(),tt(),Ae,c);return ae(re(ke(),x,L,m))}return{destroy(){V.forEach(y=>{y.classList.remove(o),y.style.removeProperty("--ssd-len"),y.style.animationPlayState=""}),ee.remove()},replay(){P=!1,q=-1,V.forEach(w)},pause(){P=!0,V.forEach(y=>{y.style.animationPlayState="paused"})},resume(){P&&(P=!1,V.forEach(y=>{y.style.animationPlayState="running"}))},seek(y){let x=Math.min(1,Math.max(0,y));q=x,P=!0,V.forEach((L,$e)=>{L.classList.remove(o),L.style.strokeDashoffset=E==="reverse"?`${D[$e]*x}`:`${D[$e]*(1-x)}`,l&&(L.style.opacity=E==="reverse"?`${1-x}`:`${x}`)})},getProgress(){return S()}}}if(wt())return vt();function Et(){let o=Math.max(1,ge),a=0,v=0;function O(S){let y=!0;if(ie){let x=Math.min(1,Math.max(0,S/o)),L=ae(x);Te=L,e.style.setProperty("--scroll-draw-progress",String(L)),e.style.clipPath=ne(E==="reverse"?1-L:L),g?.(L),x<1&&(y=!1)}else V.forEach((x,L)=>{let $e=L*F*o,Me=Math.min(1,Math.max(0,(S-$e)/o)),pe=ae(Me);x.style.strokeDashoffset=E==="reverse"?`${D[L]*pe}`:`${D[L]*(1-pe)}`,l&&(x.style.opacity=E==="reverse"?`${1-pe}`:`${pe}`),G&&C?x.style.stroke=Pe(G,C,pe):C&&(x.style.stroke=C),H!==null&&j!==null?x.style.strokeWidth=`${H+(j-H)*pe}`:j!==null&&(x.style.strokeWidth=`${j}`),M!==null&&I!==null?x.style.fillOpacity=`${M+(I-M)*pe}`:I!==null&&(x.style.fillOpacity=`${I}`),k&&x.tagName.toLowerCase()==="path"&&me[L]&&x.setAttribute("d",Ze(me[L],k,pe)),L===0&&(g?.(pe),e.style.setProperty("--scroll-draw-progress",String(pe))),Me<1&&(y=!1)});if(_){let x=Math.min(1,Math.max(0,S/o)),L=ae(x);for(let $e in _){let Me=parseFloat($e);L>=Me&&!Se.has(Me)&&(Se.add(Me),_[$e]?.())}}return y}function se(S){if(Q)return;let y=S-a;le||(le=!0,R?.());let x=O(y);if(x&&!Y){Y=!0,O(o*(1+Math.max(0,V.length-1)*F)),ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{a=performance.now(),le=!1,Y=!1,Se.clear(),De(),W=requestAnimationFrame(se)},J));return}x||(W=requestAnimationFrame(se))}function ee(){cancelAnimationFrame(W),clearTimeout(Ee),a=performance.now(),v=0,Q=!1,le=!1,Y=!1,ye=0,Se.clear(),De(),W=requestAnimationFrame(se)}let w=new IntersectionObserver(S=>{S.forEach(y=>{y.isIntersecting&&!(X&&Y)?ee():!y.isIntersecting&&!X&&!Y&&(cancelAnimationFrame(W),clearTimeout(Ee),a=null)})},{root:p??null,threshold:oe,rootMargin:U}),P;function q(){clearTimeout(P),P=setTimeout(()=>{V.forEach((S,y)=>{D[y]=Ne(S),S.style.strokeDasharray=`${D[y]}`})},150)}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),h>0?setTimeout(()=>w.observe(e),h):w.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),w.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(P)},replay(){ye=0,ee()},pause(){Q||(Q=!0,v=performance.now()-a,cancelAnimationFrame(W))},resume(){Q&&(Q=!1,a=performance.now()-v,W=requestAnimationFrame(se))},seek(S){let y=Math.min(1,Math.max(0,S));Te=y,Q=!0,v=y*o,a=performance.now()-v,cancelAnimationFrame(W),O(v)},getProgress(){return Te}}}if(de)return Et();rt();function Oe(){if(!Ce||Q)return;let o=performance.now(),a=ke(),v=m;if(B!==!1){let w=o-et,P=w>0?Math.abs(a-(Ie<0?a:Ie))/w:0;v=m*Math.max(.2,1+P*(typeof B=="number"?B:1)*.04)}Ie=a,et=o;let O=u?Le===-1||a>=Le?"forward":"reverse":E;Le=a;let se=ve-we,ee=!0;if(ie){let w=ae(re(a,we,ve,v));X&&!u&&(fe=Math.max(fe,w),w=fe),Te=w,e.style.setProperty("--scroll-draw-progress",String(w));let P=O==="reverse"?1-w:w;e.style.clipPath=ne(P),g?.(w),!le&&re(a,we,ve,v)>0&&(le=!0,R?.()),w>=1&&!Y?(Y=!0,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=!1,Y=!1,e.style.clipPath=ne(0)},J))):w<1&&!X&&(Y=!1),W=requestAnimationFrame(Oe);return}if(V.forEach((w,P)=>{let q=P*F*se,S=ae(re(a,we+q,ve+q,v));X&&!u&&(fe=Math.max(fe,S),S=fe),Te=S,w.style.strokeDashoffset=O==="reverse"?`${D[P]*S}`:`${D[P]*(1-S)}`,l&&(w.style.opacity=O==="reverse"?`${1-S}`:`${S}`),G&&C?w.style.stroke=Pe(G,C,S):C&&(w.style.stroke=C),H!==null&&j!==null?w.style.strokeWidth=`${H+(j-H)*S}`:j!==null&&(w.style.strokeWidth=`${j}`),M!==null&&I!==null?w.style.fillOpacity=`${M+(I-M)*S}`:I!==null&&(w.style.fillOpacity=`${I}`),k&&w.tagName.toLowerCase()==="path"&&me[P]&&w.setAttribute("d",Ze(me[P],k,S)),P===0&&(g?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&(ee=!1)}),_){let w=ae(re(a,we,ve,v));for(let P in _){let q=parseFloat(P);w>=q&&!Se.has(q)&&(Se.add(q),_[P]?.())}}!le&&re(a,we,ve,v)>0&&(le=!0,R?.()),ee&&!Y?(Y=!0,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=!1,Y=!1,Se.clear(),De()},J))):!ee&&!X&&(Y=!1),W=requestAnimationFrame(Oe)}let Ge=new IntersectionObserver(o=>{o.forEach(a=>{Ce=a.isIntersecting,Ce&&!Q?W=requestAnimationFrame(Oe):cancelAnimationFrame(W)})},{root:p??null,threshold:oe,rootMargin:U}),je;function Fe(){clearTimeout(je),je=setTimeout(()=>{V.forEach((o,a)=>{D[a]=Ne(o),o.style.strokeDasharray=`${D[a]}`}),rt()},150)}return window.addEventListener("resize",Fe),window.addEventListener("orientationchange",Fe),h>0?setTimeout(()=>Ge.observe(e),h):Ge.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),Ge.disconnect(),window.removeEventListener("resize",Fe),window.removeEventListener("orientationchange",Fe),clearTimeout(je),Be?.remove()},replay(){fe=-1,Le=-1,Ie=-1,le=!1,Y=!1,ye=0,Q=!1,Se.clear(),clearTimeout(Ee),De()},pause(){Q=!0,cancelAnimationFrame(W)},resume(){Q&&(Q=!1,Ce&&(W=requestAnimationFrame(Oe)))},seek(o){let a=Math.min(1,Math.max(0,o));Te=a,fe=a,Q=!0,cancelAnimationFrame(W),bt(a,E)},getProgress(){return Te}}}var ct=new Map;function qe(e,r){ct.set(e,r)}function ze(e){ct.delete(e)}function Dt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ut(e){let r=[],t=/([\w]+)\(([^)]*)\)/g,n;for(;(n=t.exec(e))!==null;){let i=[],s=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let l=m.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(l?parseFloat(l[1]):0),s.push(l?l[2]:"")}r.push({fn:n[1],nums:i,units:s})}return r}function Ot(e,r,t){let n=ut(e),i=ut(r);return n.length===0||n.length!==i.length?t<1?e:r:n.map((s,d)=>{let m=i[d];return s.fn!==m.fn||s.nums.length!==m.nums.length?t<1?`${s.fn}(${s.nums.map((l,f)=>`${l}${s.units[f]}`).join(", ")})`:`${m.fn}(${m.nums.map((l,f)=>`${l}${m.units[f]}`).join(", ")})`:`${s.fn}(${s.nums.map((l,f)=>`${l+(m.nums[f]-l)*t}${s.units[f]}`).join(", ")})`}).join(" ")}function mt(e,r,t){if(typeof e=="number"&&typeof r=="number")return String(e+(r-e)*t);let n=String(e),i=String(r);if(Dt(n))return Pe(n,i,t);if(n.includes("("))return Ot(n,i,t);let s=n.match(/^([-+]?[\d.]+)(.*)$/),d=i.match(/^([-+]?[\d.]+)(.*)$/);if(s&&d){let m=parseFloat(s[1]),l=parseFloat(d[1]);return`${m+(l-m)*t}${s[2]||d[2]}`}return t<1?n:i}function Ft(e){return e.replace(/([A-Z])/g,r=>`-${r.toLowerCase()}`)}var ft={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Nt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Rt=0;function Ht(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function pt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let{props:n,trigger:i={},easing:s="ease-out",speed:d=1,once:m=!1,axis:l="y",scrollContainer:f,native:T=!0,onProgress:F,onComplete:E}=r,X=window.matchMedia("(prefers-reduced-motion: reduce)").matches,ce=typeof s=="function"?s:te[s]??te["ease-out"],A=he(i.start??"top bottom"),$=he(i.end??"bottom top"),u=typeof f=="string"?document.querySelector(f):f??null,h=Object.entries(n).map(([c,p])=>({prop:Ft(c),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function b(){let c=window.getComputedStyle(e);for(let p of h)p.from===""&&(p.from=c.getPropertyValue(p.prop).trim()||"0")}function N(){for(let c of h)e.style.setProperty(c.prop,String(c.to))}if(X)return N(),E?.(),t;b();function z(){if(!T||!Ht()||typeof s!="string"||!(s in ft)||l!=="y"||u||m||d!==1||F||E||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return!1;for(let c of h)if(!Nt.has(c.prop))return!1;return!0}function _(){let c=`ssd-a-${++Rt}`,p=h.map(M=>`${M.prop}:${M.from}`).join(";"),G=h.map(M=>`${M.prop}:${M.to}`).join(";"),C=document.createElement("style");C.setAttribute("data-ssd-animate",""),C.textContent=`@keyframes ${c}{from{${p}}to{${G}}}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${ft[s]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C),e.classList.add(c);let H=()=>l==="x"?window.scrollX:window.scrollY,j=()=>l==="x"?window.innerWidth:window.innerHeight;return{destroy(){e.classList.remove(c),C.remove()},replay(){e.classList.remove(c),e.offsetWidth,e.classList.add(c)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(M){let I=Math.min(1,Math.max(0,M));e.classList.remove(c);for(let ne of h)e.style.setProperty(ne.prop,mt(ne.from,ne.to,I))},getProgress(){let M=e.getBoundingClientRect(),I=H(),ne=j(),{tStart:V,tEnd:D}=xe({top:M.top,height:M.height},I,ne,A,$);return ce(re(I,V,D,d))}}}if(z())return _();let B=0,oe=0,U=0,Z=!1,J=!1,k=-1,K=0,de=!1,ge=()=>u?l==="x"?u.scrollLeft:u.scrollTop:l==="x"?window.scrollX:window.scrollY,be=()=>u?l==="x"?u.clientWidth:u.clientHeight:l==="x"?window.innerWidth:window.innerHeight;function g(){let c=e.getBoundingClientRect(),p,G;if(u){let H=u.getBoundingClientRect();p=l==="x"?c.left-H.left+u.scrollLeft:c.top-H.top+u.scrollTop,G=l==="x"?c.width:c.height}else p=l==="x"?c.left:c.top,G=l==="x"?c.width:c.height;let C=xe({top:p,height:G},ge(),be(),A,$);B=C.tStart,oe=C.tEnd}function R(c){e.style.setProperty("--scroll-draw-progress",String(c));for(let p of h)e.style.setProperty(p.prop,mt(p.from,p.to,c));F?.(c)}function ue(){if(!Z||J)return;let c=ce(re(ge(),B,oe,d));m&&(k=Math.max(k,c),c=k),K=c,R(c),c>=1&&!de?(de=!0,E?.()):c<1&&!m&&(de=!1),U=requestAnimationFrame(ue)}g();{let c=ce(re(ge(),B,oe,d));m&&c>0&&(k=c),K=c,R(c)}let ie=new IntersectionObserver(c=>{c.forEach(p=>{Z=p.isIntersecting,Z&&!J?U=requestAnimationFrame(ue):cancelAnimationFrame(U)})},{root:u??null}),ae;function Ae(){clearTimeout(ae),ae=setTimeout(g,150)}return window.addEventListener("resize",Ae),window.addEventListener("orientationchange",Ae),ie.observe(e),qe(e,{type:"animate",getProgress:()=>K,getTrigger:()=>({tStart:B,tEnd:oe})}),{destroy(){cancelAnimationFrame(U),ie.disconnect(),window.removeEventListener("resize",Ae),window.removeEventListener("orientationchange",Ae),clearTimeout(ae),ze(e)},replay(){k=-1,de=!1,K=0,J=!1,R(0)},pause(){J=!0,cancelAnimationFrame(U)},resume(){J&&(J=!1,Z&&(U=requestAnimationFrame(ue)))},seek(c){let p=Math.min(1,Math.max(0,c));K=p,k=p,J=!0,cancelAnimationFrame(U),R(p)},getProgress(){return K}}}var Ve={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function dt(e,r){if(typeof window>"u")return Ve;let t=typeof e=="string"?document.querySelector(e):e;return t?pt(t,r):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),Ve)}function gt(e,r={}){if(typeof window>"u")return Ve;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),Ve;let{speed:n=.3,axis:i="y",easing:s="linear",trigger:d,onProgress:m}=r,l=t.getBoundingClientRect(),f=i==="x"?l.width:l.height,T=n*f;return pt(t,{props:i==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:s,native:!1,onProgress:m})}var Je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function yt(e,r){if(typeof window>"u")return Je;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Je;let n=t,{from:i=0,to:s,format:d,easing:m="ease-out",trigger:l={},once:f=!0,decimals:T,onComplete:F}=r,E=T!==void 0?g=>g.toFixed(T):d??(g=>String(Math.round(g))),X=typeof m=="function"?m:te[m]??te["ease-out"],ce=he(l.start??"top 80%"),A=he(l.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=E(s),F?.(),Je;n.textContent=E(i);let u=0,h=0,b=0,N=!1,z=!1,_=-1,B=0,oe=!1,U=()=>window.scrollY,Z=()=>window.innerHeight;function J(){let g=n.getBoundingClientRect(),R=xe({top:g.top,height:g.height},U(),Z(),ce,A);u=R.tStart,h=R.tEnd}function k(g){n.textContent=E(i+(s-i)*g),n.style.setProperty("--scroll-draw-progress",String(g))}function K(){if(!N||z)return;let g=X(re(U(),u,h,1));f&&(_=Math.max(_,g),g=_),B=g,k(g),g>=1&&!oe?(oe=!0,F?.()):g<1&&!f&&(oe=!1),b=requestAnimationFrame(K)}J();{let g=X(re(U(),u,h,1));f&&g>0&&(_=g),B=g,k(g)}let de=new IntersectionObserver(g=>{g.forEach(R=>{N=R.isIntersecting,N&&!z?b=requestAnimationFrame(K):cancelAnimationFrame(b)})}),ge;function be(){clearTimeout(ge),ge=setTimeout(J,150)}return window.addEventListener("resize",be),window.addEventListener("orientationchange",be),de.observe(n),qe(n,{type:"counter",getProgress:()=>B,getTrigger:()=>({tStart:u,tEnd:h})}),{destroy(){cancelAnimationFrame(b),de.disconnect(),window.removeEventListener("resize",be),window.removeEventListener("orientationchange",be),clearTimeout(ge),ze(n)},replay(){_=-1,oe=!1,B=0,z=!1,k(0)},pause(){z=!0,cancelAnimationFrame(b)},resume(){z&&(z=!1,N&&(b=requestAnimationFrame(K)))},seek(g){let R=Math.min(1,Math.max(0,g));B=R,_=R,z=!0,cancelAnimationFrame(b),k(R)},getProgress(){return B}}}var ht="http://www.w3.org/2000/svg",qt="cinematic-photo",Ke=e=>e<0?0:e>1?1:e;function We(e){let r=parseFloat(e);return Number.isFinite(r)?Ke(r/100):0}function zt(e){return te[e]??te.linear}var Vt={destroy:()=>{},getProgress:()=>0},_e=class{constructor(r){if(typeof document>"u"){this.mount=null;return}this.mount=typeof r.wrapper=="string"?document.querySelector(r.wrapper):r.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",r.wrapper)}loadStory(r){let t=this.mount;if(typeof window>"u"||!t)return Vt;t.style.position="relative",t.style.height=r.totalHeight,t.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",t.appendChild(n);let i=[];for(let A of r.scenes){if(A.background){let u=document.createElement("img");u.id=qt,u.src=A.background,u.alt="",u.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(u)}let $=A.animations.filter(u=>u.type==="draw");if($.length){let u=document.createElementNS(ht,"svg");u.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),u.setAttribute("preserveAspectRatio","xMidYMid meet"),u.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(u);for(let h of $){let b=document.createElementNS(ht,"path");b.id=h.target.replace(/^#/,""),b.setAttribute("d",h.d),b.setAttribute("fill","none"),b.setAttribute("stroke",h.stroke),b.setAttribute("stroke-width",String(h.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let N=h.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(N),b.style.strokeDashoffset=String(N),u.appendChild(b),i.push({kind:"draw",el:b,start:We(h.start),end:We(h.end),ease:zt(h.easing),length:N})}}for(let u of A.animations){if(u.type!=="fade")continue;let h=n.querySelector(u.target)??document.querySelector(u.target);h&&(h.style.opacity=String(u.from),i.push({kind:"fade",el:h,start:We(u.start),end:We(u.end),ease:te["ease-in-out"]??te.linear,from:u.from,to:u.to}))}}let s=0,d=()=>{let A=t.offsetHeight-window.innerHeight;return A<=0?t.getBoundingClientRect().top<=0?1:0:Ke(-t.getBoundingClientRect().top/A)},m=A=>{for(let $ of i){let u=$.end-$.start,h=u<=0?A>=$.end?1:0:Ke((A-$.start)/u),b=$.ease(h);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-b)):$.el.style.opacity=String($.from+($.to-$.from)*b)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(1),{destroy:()=>{},getProgress:()=>1};let l=0,f=!1,T=!1,F=()=>{s=d(),m(s),f&&(l=requestAnimationFrame(F))},E=()=>{f||(f=!0,l=requestAnimationFrame(F))},X=()=>{f=!1,cancelAnimationFrame(l)},ce=new IntersectionObserver(A=>{for(let $ of A)T=$.isIntersecting,T?E():X()},{threshold:0});return ce.observe(n),s=d(),m(s),{destroy(){X(),ce.disconnect()},getProgress:()=>s}}};function Wt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let n=typeof e=="string"?document.querySelector(e):e;return n?He(n,r):(console.warn("[svg-scroll-draw] Container not found:",e),t)}var Qe=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let t={},n=this.getAttribute("speed"),i=this.getAttribute("easing"),s=this.getAttribute("stagger"),d=this.getAttribute("direction"),m=this.getAttribute("selector");n&&(t.speed=parseFloat(n)),i&&(t.easing=i),s&&(t.stagger=parseFloat(s)),d&&(t.direction=d),m&&(t.selector=m),this.hasAttribute("fade")&&(t.fade=this.getAttribute("fade")!=="false"),this.instance=He(this,t)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",Qe);return Mt(_t);})();
|
|
1
|
+
"use strict";var SvgScrollDraw=(()=>{var Ke=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var Ct=(e,r)=>{for(var t in r)Ke(e,t,{get:r[t],enumerable:!0})},Lt=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of kt(r))!Pt.call(e,a)&&a!==t&&Ke(e,a,{get:()=>r[a],enumerable:!(n=Mt(r,a))||n.enumerable});return e};var It=e=>Lt(Ke({},"__esModule",{value:!0}),e);var Yt={};Ct(Yt,{Cinematic:()=>Ye,PRESETS:()=>Be,createBounce:()=>Qe,createElastic:()=>et,createSpring:()=>mt,scrollAnimate:()=>wt,scrollCounter:()=>Et,scrollDraw:()=>Xt,scrollParallax:()=>vt});function mt({tension:e=2.5,friction:r=2.2}={}){return t=>1-Math.cos(t*Math.PI*e)*Math.pow(1-t,r)}function Qe({bounces:e=3,decay:r=.5}={}){let t=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,r)),a=Math.sqrt(n),i=0,g=[];for(let p=0;p<t;p++){let T=Math.pow(a,p);g.push(T),i+=T}let f=[0],c=0;for(let p=0;p<t;p++)c+=g[p]/i,f.push(c);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let T=0;T<t;T++)if(p<=f[T+1]){let H=(p-f[T])/(f[T+1]-f[T]);if(T===0)return H*(2-H);let v=1-Math.pow(n,T);return v+(1-v)*(2*H-1)*(2*H-1)}return 1}}function et({amplitude:e=1,period:r=.4}={}){let t=Math.max(1,e),n=Math.max(.1,r),a=t<=1?n/4:n/(2*Math.PI)*Math.asin(1/t);return i=>i<=0?0:i>=1?1:t*Math.pow(2,-10*i)*Math.sin((i-a)*(2*Math.PI)/n)+1}var Q={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Qe(),elastic:et()};function he(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return{element:"top",viewport:r};let[t="top",n="bottom"]=r.split(/\s+/).filter(Boolean);return{element:t,viewport:n}}function lt(e,r,t,n){switch(n){case"top":return e+t;case"center":return e+t+r/2;case"bottom":return e+t+r;default:return e+t}}function ct(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 Ve(e){let r=e.tagName.toLowerCase();if(r==="rect"){let t=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(t+n)}if(r==="circle"){let t=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*t}return e.getTotalLength()}function Dt(e,r,t){return Math.min(t,Math.max(r,e))}function ee(e,r,t,n){return t===r?0:Dt((e-r)/(t-r)*n,0,1)}function Se(e,r,t,n,a){let i=lt(e.top,e.height,r,n.element)-ct(n.viewport,t),g=lt(e.top,e.height,r,a.element)-ct(a.viewport,t);return{tStart:i,tEnd:g}}function ut(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 t=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[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 Ce(e,r,t){let n=ut(e),a=ut(r);return!n||!a?e:`rgb(${Math.round(n[0]+(a[0]-n[0])*t)},${Math.round(n[1]+(a[1]-n[1])*t)},${Math.round(n[2]+(a[2]-n[2])*t)})`}var Be={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:!1},reveal:{easing:"ease-out",fade:!0,speed:1.2,once:!0},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:!0,speed:.75},spring:{easing:"spring",speed:1.1}};function ft(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r)}var pt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ot=0;function Ft(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Nt(e){let r=e.getAttribute("stroke"),t=e.getAttribute("fill");!r||r==="none"?ft("Element has no stroke \u2014 path will not be visible.",e):t&&t!=="none"&&t!=="transparent"&&ft("Element has a fill \u2014 it may obscure the stroke animation.",e)}function Rt(e,r,t){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function a(){let i=t==="x"?window.scrollX:window.scrollY,g=e-i,f=r-i,c=t==="x";n.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`left:${g}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${g}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:${f}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${f}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`}return document.body.appendChild(n),window.addEventListener("scroll",a,{passive:!0}),a(),n}function tt(e,r,t){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,i=>{let g=parseFloat(i),f=n[a++]??g;return String(+(g+(f-g)*t).toFixed(4))})}function We(e,r={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:t,...n}=r,a=t?{...Be[t],...n}:n,i=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:g="path, polyline, line, polygon, rect, circle",speed:f=1,fade:c=!1,easing:p="linear",trigger:T={},stagger:H=0,direction:v="forward",once:_=!1,debug:pe=!1,axis:x="y",scrollContainer:$,autoReverse:y=!1,delay:E=0,strokeColor:b,strokeWidth:F,fillOpacity:A,waypoints:C,velocityScale:te=!1,threshold:de=0,rootMargin:be="0px",repeat:ie=0,repeatDelay:Y=0,morphTo:L,clip:j,autoplay:ge=!1,duration:re=1e3,native:ne=!0,onProgress:d,onStart:q,onComplete:U,onEnter:xe,onLeave:Oe,onEnterBack:Le,onLeaveBack:Ae}=a,ue=j===!0?"left":typeof j=="string"?j:!1,ae=typeof p=="function"?p:Q[p]??Q.linear,Ie=he(T.start??"top bottom"),Me=he(T.end??"bottom top"),z=typeof $=="string"?document.querySelector($):$??null,s=Array.isArray(b)?b[0]:null,m=Array.isArray(b)?b[1]:typeof b=="string"?b:null,N=Array.isArray(F)?F[0]:null,I=Array.isArray(F)?F[1]:typeof F=="number"?F:null,V=Array.isArray(A)?A[0]:null,G=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function B(o){let l=o*100;switch(ue){case"right":return`inset(0 0 0 ${100-l}%)`;case"top":return`inset(0 0 ${100-l}% 0)`;case"bottom":return`inset(${100-l}% 0 0 0)`;case"center":return`circle(${o*150}% at 50% 50%)`;default:return`inset(0 ${100-l}% 0 0)`}}let O=ue?[]:Array.from(e.querySelectorAll(g)),M=[],oe=[],le=0,we=0,X=!1,ce=!1,W=0,Fe=!1,me=-1,Ne=-1,Z=!1,Te=0,ye=0,ve,Ue=null,Ee=new Set,Re=-1,st=performance.now(),ke=NaN;function De(){return z?x==="x"?z.scrollLeft:z.scrollTop:x==="x"?window.scrollX:window.scrollY}function it(){return z?x==="x"?z.clientWidth:z.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function at(){let o=e.getBoundingClientRect(),l,w,R;if(z){let K=z.getBoundingClientRect();l=x==="x"?o.left-K.left+z.scrollLeft:o.top-K.top+z.scrollTop,w=x==="x"?o.width:o.height,R=De()}else l=x==="x"?o.left:o.top,w=x==="x"?o.width:o.height,R=De();let J=Se({top:l,height:w},R,it(),Ie,Me);le=J.tStart,we=J.tEnd,pe&&process.env.NODE_ENV!=="production"&&(Ue?.remove(),Ue=Rt(le,we,x))}function xt(o,l){if(e.style.setProperty("--scroll-draw-progress",String(o)),ue){let w=l==="reverse"?1-o:o;e.style.clipPath=B(w);return}O.forEach((w,R)=>{w.style.strokeDashoffset=l==="reverse"?`${M[R]*o}`:`${M[R]*(1-o)}`,c&&(w.style.opacity=l==="reverse"?`${1-o}`:`${o}`),s&&m?w.style.stroke=Ce(s,m,o):m&&(w.style.stroke=m),N!==null&&I!==null?w.style.strokeWidth=`${N+(I-N)*o}`:I!==null&&(w.style.strokeWidth=`${I}`),V!==null&&G!==null?w.style.fillOpacity=`${V+(G-V)*o}`:G!==null&&(w.style.fillOpacity=`${G}`),L&&w.tagName.toLowerCase()==="path"&&oe[R]&&w.setAttribute("d",tt(oe[R],L,o))})}function He(){if(e.style.setProperty("--scroll-draw-progress","0"),ue){e.style.clipPath=B(0);return}O.forEach((o,l)=>{o.style.strokeDasharray=`${M[l]}`,o.style.strokeDashoffset=v==="reverse"?"0":`${M[l]}`,c?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`),L&&o.tagName.toLowerCase()==="path"&&oe[l]&&o.setAttribute("d",oe[l])})}if(O.forEach(o=>{Nt(o);let l=Ve(o);M.push(l),o.tagName.toLowerCase()==="path"?oe.push(o.getAttribute("d")??""):oe.push(""),i?(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=v==="reverse"?`${l}`:"0",c&&(o.style.opacity="1"),m&&(o.style.stroke=m),I!==null&&(o.style.strokeWidth=`${I}`),G!==null&&(o.style.fillOpacity=`${G}`),L&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",L)):(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=v==="reverse"?"0":`${l}`,c?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`))}),ue){if(i)return e.style.clipPath=B(1),U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=B(0)}else if(i)return U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function At(){return!(ne===!1||!Ft()||!O.length||typeof p!="string"||!(p in pt)||ue||x!=="y"||z||f!==1||H!==0||_||y||te!==!1||L||C||ie||E>0||d||q||U||xe||Oe||Le||Ae||b!=null||F!=null||A!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function Tt(){let o=`svg-scroll-draw-${++Ot}`,l=v==="reverse"?"0":"var(--ssd-len)",w=v==="reverse"?"var(--ssd-len)":"0",R=`stroke-dashoffset:${l};`,J=`stroke-dashoffset:${w};`;c&&(R+=`opacity:${v==="reverse"?1:0};`,J+=`opacity:${v==="reverse"?0:1};`);let K=document.createElement("style");K.setAttribute("data-svg-scroll-draw",""),K.textContent=`@keyframes ${o}{from{${R}}to{${J}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${pt[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(K);function se(u,S){u.style.setProperty("--ssd-len",String(M[S])),u.style.strokeDasharray=`${M[S]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(o)}O.forEach(se);let h=!1,k=-1;function P(){if(k>=0)return k;let u=e.getBoundingClientRect(),{tStart:S,tEnd:D}=Se({top:u.top,height:u.height},De(),it(),Ie,Me);return ae(ee(De(),S,D,f))}return{destroy(){O.forEach(u=>{u.classList.remove(o),u.style.removeProperty("--ssd-len"),u.style.animationPlayState=""}),K.remove()},replay(){h=!1,k=-1,O.forEach(se)},pause(){h=!0,O.forEach(u=>{u.style.animationPlayState="paused"})},resume(){h&&(h=!1,O.forEach(u=>{u.style.animationPlayState="running"}))},seek(u){let S=Math.min(1,Math.max(0,u));k=S,h=!0,O.forEach((D,$e)=>{D.classList.remove(o),D.style.strokeDashoffset=v==="reverse"?`${M[$e]*S}`:`${M[$e]*(1-S)}`,c&&(D.style.opacity=v==="reverse"?`${1-S}`:`${S}`)})},getProgress(){return P()}}}if(At())return Tt();function $t(){let o=Math.max(1,re),l=0,w=0;function R(P){let u=!0;if(ue){let S=Math.min(1,Math.max(0,P/o)),D=ae(S);Te=D,e.style.setProperty("--scroll-draw-progress",String(D)),e.style.clipPath=B(v==="reverse"?1-D:D),d?.(D),S<1&&(u=!1)}else O.forEach((S,D)=>{let $e=D*H*o,Pe=Math.min(1,Math.max(0,(P-$e)/o)),fe=ae(Pe);S.style.strokeDashoffset=v==="reverse"?`${M[D]*fe}`:`${M[D]*(1-fe)}`,c&&(S.style.opacity=v==="reverse"?`${1-fe}`:`${fe}`),s&&m?S.style.stroke=Ce(s,m,fe):m&&(S.style.stroke=m),N!==null&&I!==null?S.style.strokeWidth=`${N+(I-N)*fe}`:I!==null&&(S.style.strokeWidth=`${I}`),V!==null&&G!==null?S.style.fillOpacity=`${V+(G-V)*fe}`:G!==null&&(S.style.fillOpacity=`${G}`),L&&S.tagName.toLowerCase()==="path"&&oe[D]&&S.setAttribute("d",tt(oe[D],L,fe)),D===0&&(d?.(fe),e.style.setProperty("--scroll-draw-progress",String(fe))),Pe<1&&(u=!1)});if(C){let S=Math.min(1,Math.max(0,P/o)),D=ae(S);for(let $e in C){let Pe=parseFloat($e);D>=Pe&&!Ee.has(Pe)&&(Ee.add(Pe),C[$e]?.())}}return u}function J(P){if(Z)return;let u=P-l;ce||(ce=!0,q?.());let S=R(u);if(S&&!X){X=!0,R(o*(1+Math.max(0,O.length-1)*H)),U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{l=performance.now(),ce=!1,X=!1,Ee.clear(),He(),W=requestAnimationFrame(J)},Y));return}S||(W=requestAnimationFrame(J))}function K(){cancelAnimationFrame(W),clearTimeout(ve),l=performance.now(),w=0,Z=!1,ce=!1,X=!1,ye=0,Ee.clear(),He(),W=requestAnimationFrame(J)}let se=new IntersectionObserver(P=>{P.forEach(u=>{u.isIntersecting&&!(_&&X)?K():!u.isIntersecting&&!_&&!X&&(cancelAnimationFrame(W),clearTimeout(ve),l=null)})},{root:z??null,threshold:de,rootMargin:be}),h;function k(){clearTimeout(h),h=setTimeout(()=>{O.forEach((P,u)=>{M[u]=Ve(P),P.style.strokeDasharray=`${M[u]}`})},150)}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),E>0?setTimeout(()=>se.observe(e),E):se.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),se.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(h)},replay(){ye=0,K()},pause(){Z||(Z=!0,w=performance.now()-l,cancelAnimationFrame(W))},resume(){Z&&(Z=!1,l=performance.now()-w,W=requestAnimationFrame(J))},seek(P){let u=Math.min(1,Math.max(0,P));Te=u,Z=!0,w=u*o,l=performance.now()-w,cancelAnimationFrame(W),R(w)},getProgress(){return Te}}}if(ge)return $t();at();function qe(){if(!Fe||Z)return;let o=performance.now(),l=De(),w=f;if(te!==!1){let h=o-st,k=h>0?Math.abs(l-(Re<0?l:Re))/h:0;w=f*Math.max(.2,1+k*(typeof te=="number"?te:1)*.04)}Re=l,st=o;let R=y?Ne===-1||l>=Ne?"forward":"reverse":v;Ne=l;let J=we-le,K=!0,se=J===0?0:(l-le)/J;if(isNaN(ke)||(ke<=0&&se>0?xe?.():ke>0&&se<=0&&Ae?.(),ke<1&&se>=1?Oe?.():ke>=1&&se<1&&Le?.()),ke=se,ue){let h=ae(ee(l,le,we,w));_&&!y&&(me=Math.max(me,h),h=me),Te=h,e.style.setProperty("--scroll-draw-progress",String(h));let k=R==="reverse"?1-h:h;e.style.clipPath=B(k),d?.(h),!ce&&ee(l,le,we,w)>0&&(ce=!0,q?.()),h>=1&&!X?(X=!0,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=!1,X=!1,e.style.clipPath=B(0)},Y))):h<1&&!_&&(X=!1),W=requestAnimationFrame(qe);return}if(O.forEach((h,k)=>{let P=k*H*J,u=ae(ee(l,le+P,we+P,w));_&&!y&&(me=Math.max(me,u),u=me),Te=u,h.style.strokeDashoffset=R==="reverse"?`${M[k]*u}`:`${M[k]*(1-u)}`,c&&(h.style.opacity=R==="reverse"?`${1-u}`:`${u}`),s&&m?h.style.stroke=Ce(s,m,u):m&&(h.style.stroke=m),N!==null&&I!==null?h.style.strokeWidth=`${N+(I-N)*u}`:I!==null&&(h.style.strokeWidth=`${I}`),V!==null&&G!==null?h.style.fillOpacity=`${V+(G-V)*u}`:G!==null&&(h.style.fillOpacity=`${G}`),L&&h.tagName.toLowerCase()==="path"&&oe[k]&&h.setAttribute("d",tt(oe[k],L,u)),k===0&&(d?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(K=!1)}),C){let h=ae(ee(l,le,we,w));for(let k in C){let P=parseFloat(k);h>=P&&!Ee.has(P)&&(Ee.add(P),C[k]?.())}}!ce&&ee(l,le,we,w)>0&&(ce=!0,q?.()),K&&!X?(X=!0,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=!1,X=!1,Ee.clear(),He()},Y))):!K&&!_&&(X=!1),W=requestAnimationFrame(qe)}let Ze=new IntersectionObserver(o=>{o.forEach(l=>{Fe=l.isIntersecting,Fe&&!Z?W=requestAnimationFrame(qe):cancelAnimationFrame(W)})},{root:z??null,threshold:de,rootMargin:be}),Je;function ze(){clearTimeout(Je),Je=setTimeout(()=>{O.forEach((o,l)=>{M[l]=Ve(o),o.style.strokeDasharray=`${M[l]}`}),at()},150)}return window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze),E>0?setTimeout(()=>Ze.observe(e),E):Ze.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),Ze.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Je),Ue?.remove()},replay(){me=-1,Ne=-1,Re=-1,ce=!1,X=!1,ye=0,Z=!1,Ee.clear(),clearTimeout(ve),He()},pause(){Z=!0,cancelAnimationFrame(W)},resume(){Z&&(Z=!1,Fe&&(W=requestAnimationFrame(qe)))},seek(o){let l=Math.min(1,Math.max(0,o));Te=l,me=l,Z=!0,cancelAnimationFrame(W),xt(l,v)},getProgress(){return Te}}}var dt=new Map;function _e(e,r){dt.set(e,r)}function Ge(e){dt.delete(e)}function Ht(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function gt(e){let r=[],t=/([\w]+)\(([^)]*)\)/g,n;for(;(n=t.exec(e))!==null;){let a=[],i=[],g=n[2].trim();if(g)for(let f of g.split(/[\s,]+/)){let c=f.match(/^([-+]?[\d.eE]+)(.*)$/);a.push(c?parseFloat(c[1]):0),i.push(c?c[2]:"")}r.push({fn:n[1],nums:a,units:i})}return r}function qt(e,r,t){let n=gt(e),a=gt(r);return n.length===0||n.length!==a.length?t<1?e:r:n.map((i,g)=>{let f=a[g];return i.fn!==f.fn||i.nums.length!==f.nums.length?t<1?`${i.fn}(${i.nums.map((c,p)=>`${c}${i.units[p]}`).join(", ")})`:`${f.fn}(${f.nums.map((c,p)=>`${c}${f.units[p]}`).join(", ")})`:`${i.fn}(${i.nums.map((c,p)=>`${c+(f.nums[p]-c)*t}${i.units[p]}`).join(", ")})`}).join(" ")}function yt(e,r,t){if(typeof e=="number"&&typeof r=="number")return String(e+(r-e)*t);let n=String(e),a=String(r);if(Ht(n))return Ce(n,a,t);if(n.includes("("))return qt(n,a,t);let i=n.match(/^([-+]?[\d.]+)(.*)$/),g=a.match(/^([-+]?[\d.]+)(.*)$/);if(i&&g){let f=parseFloat(i[1]),c=parseFloat(g[1]);return`${f+(c-f)*t}${i[2]||g[2]}`}return t<1?n:a}function zt(e){return e.replace(/([A-Z])/g,r=>`-${r.toLowerCase()}`)}var ht={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Vt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Bt=0;function Wt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function bt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let{props:n,trigger:a={},easing:i="ease-out",speed:g=1,once:f=!1,axis:c="y",scrollContainer:p,native:T=!0,onProgress:H,onComplete:v,onEnter:_,onLeave:pe,onEnterBack:x,onLeaveBack:$}=r,y=window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=typeof i=="function"?i:Q[i]??Q["ease-out"],b=he(a.start??"top bottom"),F=he(a.end??"bottom top"),A=typeof p=="string"?document.querySelector(p):p??null,C=Object.entries(n).map(([s,m])=>({prop:zt(s),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function te(){let s=window.getComputedStyle(e);for(let m of C)m.from===""&&(m.from=s.getPropertyValue(m.prop).trim()||"0")}function de(){for(let s of C)e.style.setProperty(s.prop,String(s.to))}if(y)return de(),v?.(),t;te();function be(){if(!T||!Wt()||typeof i!="string"||!(i in ht)||c!=="y"||A||f||g!==1||H||v||_||pe||x||$||(a.start??"top bottom").trim()!=="top bottom"||(a.end??"bottom top").trim()!=="bottom top")return!1;for(let s of C)if(!Vt.has(s.prop))return!1;return!0}function ie(){let s=`ssd-a-${++Bt}`,m=C.map(B=>`${B.prop}:${B.from}`).join(";"),N=C.map(B=>`${B.prop}:${B.to}`).join(";"),I=document.createElement("style");I.setAttribute("data-ssd-animate",""),I.textContent=`@keyframes ${s}{from{${m}}to{${N}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${ht[i]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(I),e.classList.add(s);let V=()=>c==="x"?window.scrollX:window.scrollY,G=()=>c==="x"?window.innerWidth:window.innerHeight;return{destroy(){e.classList.remove(s),I.remove()},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(B){let O=Math.min(1,Math.max(0,B));e.classList.remove(s);for(let M of C)e.style.setProperty(M.prop,yt(M.from,M.to,O))},getProgress(){let B=e.getBoundingClientRect(),O=V(),M=G(),{tStart:oe,tEnd:le}=Se({top:B.top,height:B.height},O,M,b,F);return E(ee(O,oe,le,g))}}}if(be())return ie();let Y=0,L=0,j=0,ge=!1,re=!1,ne=-1,d=0,q=!1,U=NaN,xe=()=>A?c==="x"?A.scrollLeft:A.scrollTop:c==="x"?window.scrollX:window.scrollY,Oe=()=>A?c==="x"?A.clientWidth:A.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function Le(){let s=e.getBoundingClientRect(),m,N;if(A){let V=A.getBoundingClientRect();m=c==="x"?s.left-V.left+A.scrollLeft:s.top-V.top+A.scrollTop,N=c==="x"?s.width:s.height}else m=c==="x"?s.left:s.top,N=c==="x"?s.width:s.height;let I=Se({top:m,height:N},xe(),Oe(),b,F);Y=I.tStart,L=I.tEnd}function Ae(s){e.style.setProperty("--scroll-draw-progress",String(s));for(let m of C)e.style.setProperty(m.prop,yt(m.from,m.to,s));H?.(s)}function ue(s){if(isNaN(U)){U=s;return}U<=0&&s>0?_?.():U>0&&s<=0&&$?.(),U<1&&s>=1?pe?.():U>=1&&s<1&&x?.(),U=s}function ae(){if(!ge||re)return;let s=L===Y?0:(xe()-Y)/(L-Y);ue(s);let m=E(ee(xe(),Y,L,g));f&&(ne=Math.max(ne,m),m=ne),d=m,Ae(m),m>=1&&!q?(q=!0,v?.()):m<1&&!f&&(q=!1),j=requestAnimationFrame(ae)}Le();{let s=E(ee(xe(),Y,L,g));f&&s>0&&(ne=s),d=s,Ae(s)}let Ie=new IntersectionObserver(s=>{s.forEach(m=>{ge=m.isIntersecting,ge&&!re?j=requestAnimationFrame(ae):cancelAnimationFrame(j)})},{root:A??null}),Me;function z(){clearTimeout(Me),Me=setTimeout(Le,150)}return window.addEventListener("resize",z),window.addEventListener("orientationchange",z),Ie.observe(e),_e(e,{type:"animate",getProgress:()=>d,getTrigger:()=>({tStart:Y,tEnd:L})}),{destroy(){cancelAnimationFrame(j),Ie.disconnect(),window.removeEventListener("resize",z),window.removeEventListener("orientationchange",z),clearTimeout(Me),Ge(e)},replay(){ne=-1,q=!1,d=0,re=!1,Ae(0)},pause(){re=!0,cancelAnimationFrame(j)},resume(){re&&(re=!1,ge&&(j=requestAnimationFrame(ae)))},seek(s){let m=Math.min(1,Math.max(0,s));d=m,ne=m,re=!0,cancelAnimationFrame(j),Ae(m)},getProgress(){return d}}}var je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function wt(e,r){if(typeof window>"u")return je;let t=typeof e=="string"?document.querySelector(e):e;return t?bt(t,r):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),je)}function vt(e,r={}){if(typeof window>"u")return je;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),je;let{speed:n=.3,axis:a="y",easing:i="linear",trigger:g,onProgress:f}=r,c=t.getBoundingClientRect(),p=a==="x"?c.width:c.height,T=n*p;return bt(t,{props:a==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:g??{start:"top bottom",end:"bottom top"},easing:i,native:!1,onProgress:f})}var rt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Et(e,r){if(typeof window>"u")return rt;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),rt;let n=t,{from:a=0,to:i,format:g,easing:f="ease-out",trigger:c={},once:p=!0,decimals:T,onComplete:H}=r,v=T!==void 0?d=>d.toFixed(T):g??(d=>String(Math.round(d))),_=typeof f=="function"?f:Q[f]??Q["ease-out"],pe=he(c.start??"top 80%"),x=he(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=v(i),H?.(),rt;n.textContent=v(a);let y=0,E=0,b=0,F=!1,A=!1,C=-1,te=0,de=!1,be=()=>window.scrollY,ie=()=>window.innerHeight;function Y(){let d=n.getBoundingClientRect(),q=Se({top:d.top,height:d.height},be(),ie(),pe,x);y=q.tStart,E=q.tEnd}function L(d){n.textContent=v(a+(i-a)*d),n.style.setProperty("--scroll-draw-progress",String(d))}function j(){if(!F||A)return;let d=_(ee(be(),y,E,1));p&&(C=Math.max(C,d),d=C),te=d,L(d),d>=1&&!de?(de=!0,H?.()):d<1&&!p&&(de=!1),b=requestAnimationFrame(j)}Y();{let d=_(ee(be(),y,E,1));p&&d>0&&(C=d),te=d,L(d)}let ge=new IntersectionObserver(d=>{d.forEach(q=>{F=q.isIntersecting,F&&!A?b=requestAnimationFrame(j):cancelAnimationFrame(b)})}),re;function ne(){clearTimeout(re),re=setTimeout(Y,150)}return window.addEventListener("resize",ne),window.addEventListener("orientationchange",ne),ge.observe(n),_e(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:y,tEnd:E})}),{destroy(){cancelAnimationFrame(b),ge.disconnect(),window.removeEventListener("resize",ne),window.removeEventListener("orientationchange",ne),clearTimeout(re),Ge(n)},replay(){C=-1,de=!1,te=0,A=!1,L(0)},pause(){A=!0,cancelAnimationFrame(b)},resume(){A&&(A=!1,F&&(b=requestAnimationFrame(j)))},seek(d){let q=Math.min(1,Math.max(0,d));te=q,C=q,A=!0,cancelAnimationFrame(b),L(q)},getProgress(){return te}}}var St="http://www.w3.org/2000/svg",_t="cinematic-photo",nt=e=>e<0?0:e>1?1:e;function Xe(e){let r=parseFloat(e);return Number.isFinite(r)?nt(r/100):0}function Gt(e){return Q[e]??Q.linear}var jt={destroy:()=>{},getProgress:()=>0},Ye=class{constructor(r){if(typeof document>"u"){this.mount=null;return}this.mount=typeof r.wrapper=="string"?document.querySelector(r.wrapper):r.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",r.wrapper)}loadStory(r){let t=this.mount;if(typeof window>"u"||!t)return jt;t.style.position="relative",t.style.height=r.totalHeight,t.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",t.appendChild(n);let a=[];for(let x of r.scenes){if(x.background){let y=document.createElement("img");y.id=_t,y.src=x.background,y.alt="",y.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(y)}let $=x.animations.filter(y=>y.type==="draw");if($.length){let y=document.createElementNS(St,"svg");y.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),y.setAttribute("preserveAspectRatio","xMidYMid meet"),y.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(y);for(let E of $){let b=document.createElementNS(St,"path");b.id=E.target.replace(/^#/,""),b.setAttribute("d",E.d),b.setAttribute("fill","none"),b.setAttribute("stroke",E.stroke),b.setAttribute("stroke-width",String(E.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let F=E.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(F),b.style.strokeDashoffset=String(F),y.appendChild(b),a.push({kind:"draw",el:b,start:Xe(E.start),end:Xe(E.end),ease:Gt(E.easing),length:F})}}for(let y of x.animations){if(y.type!=="fade")continue;let E=n.querySelector(y.target)??document.querySelector(y.target);E&&(E.style.opacity=String(y.from),a.push({kind:"fade",el:E,start:Xe(y.start),end:Xe(y.end),ease:Q["ease-in-out"]??Q.linear,from:y.from,to:y.to}))}}let i=0,g=()=>{let x=t.offsetHeight-window.innerHeight;return x<=0?t.getBoundingClientRect().top<=0?1:0:nt(-t.getBoundingClientRect().top/x)},f=x=>{for(let $ of a){let y=$.end-$.start,E=y<=0?x>=$.end?1:0:nt((x-$.start)/y),b=$.ease(E);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-b)):$.el.style.opacity=String($.from+($.to-$.from)*b)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(1),{destroy:()=>{},getProgress:()=>1};let c=0,p=!1,T=!1,H=()=>{i=g(),f(i),p&&(c=requestAnimationFrame(H))},v=()=>{p||(p=!0,c=requestAnimationFrame(H))},_=()=>{p=!1,cancelAnimationFrame(c)},pe=new IntersectionObserver(x=>{for(let $ of x)T=$.isIntersecting,T?v():_()},{threshold:0});return pe.observe(n),i=g(),f(i),{destroy(){_(),pe.disconnect()},getProgress:()=>i}}};function Xt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let n=typeof e=="string"?document.querySelector(e):e;return n?We(n,r):(console.warn("[svg-scroll-draw] Container not found:",e),t)}var ot=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let t={},n=this.getAttribute("speed"),a=this.getAttribute("easing"),i=this.getAttribute("stagger"),g=this.getAttribute("direction"),f=this.getAttribute("selector");n&&(t.speed=parseFloat(n)),a&&(t.easing=a),i&&(t.stagger=parseFloat(i)),g&&(t.direction=g),f&&(t.selector=f),this.hasAttribute("fade")&&(t.fade=this.getAttribute("fade")!=="false"),this.instance=We(this,t)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",ot);return It(Yt);})();
|
package/dist/devtools/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function $(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function M(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function k(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){$(),k(),b=requestAnimationFrame(h);}function E(){process.env.NODE_ENV!=="production"&&(p||(p=true,L(),M(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),w());},window.addEventListener("keydown",m)));}function T(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function w(){p?T():E();}function H(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var _={enable:E,disable:T,toggle:w,highlight:H};exports.devtools=_;
|
|
1
|
+
'use strict';var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c",pin:"#f43f5e",snap:"#22d3ee"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function $(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function M(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function k(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){$(),k(),b=requestAnimationFrame(h);}function E(){process.env.NODE_ENV!=="production"&&(p||(p=true,L(),M(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),w());},window.addEventListener("keydown",m)));}function T(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function w(){p?T():E();}function H(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var _={enable:E,disable:T,toggle:w,highlight:H};exports.devtools=_;
|
package/dist/devtools/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function $(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function M(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function k(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){$(),k(),b=requestAnimationFrame(h);}function E(){process.env.NODE_ENV!=="production"&&(p||(p=true,L(),M(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),w());},window.addEventListener("keydown",m)));}function T(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function w(){p?T():E();}function H(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var _={enable:E,disable:T,toggle:w,highlight:H};export{_ as devtools};
|
|
1
|
+
var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c",pin:"#f43f5e",snap:"#22d3ee"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function $(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function M(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function k(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){$(),k(),b=requestAnimationFrame(h);}function E(){process.env.NODE_ENV!=="production"&&(p||(p=true,L(),M(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),w());},window.addEventListener("keydown",m)));}function T(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function w(){p?T():E();}function H(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var _={enable:E,disable:T,toggle:w,highlight:H};export{_ as devtools};
|
package/dist/group/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${l?`left:${i}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${i}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",o,{passive:true}),o(),t}function _e(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),o=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let m=parseFloat(c),i=t[o++]??m;return String(+(m+(i-m)*r).toFixed(4))})}function Ge(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,o=r?{...Je[r],...t}:t,c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:m="path, polyline, line, polygon, rect, circle",speed:i=1,fade:l=false,easing:g="linear",trigger:x={},stagger:V=0,direction:E="forward",once:re=false,debug:Pe=false,axis:z="y",scrollContainer:Ee,autoReverse:L=false,delay:W=0,strokeColor:ne,strokeWidth:se,fillOpacity:oe,waypoints:ie,velocityScale:ae=false,threshold:ge=0,rootMargin:Z="0px",repeat:_=0,repeatDelay:B=0,morphTo:D,clip:J,autoplay:ve=false,duration:Me=1e3,native:ze=true,onProgress:ce,onStart:le,onComplete:K}=o,j=J===true?"left":typeof J=="string"?J:false,X=typeof g=="function"?g:xe[g]??xe.linear,ye=$e(x.start??"top bottom"),u=$e(x.end??"bottom top"),f=typeof Ee=="string"?document.querySelector(Ee):Ee??null,O=Array.isArray(ne)?ne[0]:null,S=Array.isArray(ne)?ne[1]:typeof ne=="string"?ne:null,M=Array.isArray(se)?se[0]:null,F=Array.isArray(se)?se[1]:typeof se=="number"?se:null,w=Array.isArray(oe)?oe[0]:null,A=Array.isArray(oe)?oe[1]:typeof oe=="number"?oe:null;function q(s){let a=s*100;switch(j){case "right":return `inset(0 0 0 ${100-a}%)`;case "top":return `inset(0 0 ${100-a}% 0)`;case "bottom":return `inset(${100-a}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-a}% 0 0)`}}let I=j?[]:Array.from(e.querySelectorAll(m)),T=[],Q=[],fe=0,me=0,N=false,Y=false,C=0,De=false,ee=-1,Ie=-1,R=false,he=0,ue=0,pe,We=null,de=new Set,Ce=-1,Be=performance.now();function ke(){return f?z==="x"?f.scrollLeft:f.scrollTop:z==="x"?window.scrollX:window.scrollY}function je(){return f?z==="x"?f.clientWidth:f.clientHeight:z==="x"?window.innerWidth:window.innerHeight}function Xe(){let s=e.getBoundingClientRect(),a,y,P;if(f){let H=f.getBoundingClientRect();a=z==="x"?s.left-H.left+f.scrollLeft:s.top-H.top+f.scrollTop,y=z==="x"?s.width:s.height,P=ke();}else a=z==="x"?s.left:s.top,y=z==="x"?s.width:s.height,P=ke();let G=Ae({top:a,height:y},P,je(),ye,u);fe=G.tStart,me=G.tEnd,Pe&&process.env.NODE_ENV!=="production"&&(We?.remove(),We=bt(fe,me,z));}function lt(s,a){if(e.style.setProperty("--scroll-draw-progress",String(s)),j){let y=a==="reverse"?1-s:s;e.style.clipPath=q(y);return}I.forEach((y,P)=>{y.style.strokeDashoffset=a==="reverse"?`${T[P]*s}`:`${T[P]*(1-s)}`,l&&(y.style.opacity=a==="reverse"?`${1-s}`:`${s}`),O&&S?y.style.stroke=Te(O,S,s):S&&(y.style.stroke=S),M!==null&&F!==null?y.style.strokeWidth=`${M+(F-M)*s}`:F!==null&&(y.style.strokeWidth=`${F}`),w!==null&&A!==null?y.style.fillOpacity=`${w+(A-w)*s}`:A!==null&&(y.style.fillOpacity=`${A}`),D&&y.tagName.toLowerCase()==="path"&&Q[P]&&y.setAttribute("d",_e(Q[P],D,s));});}function Oe(){if(e.style.setProperty("--scroll-draw-progress","0"),j){e.style.clipPath=q(0);return}I.forEach((s,a)=>{s.style.strokeDasharray=`${T[a]}`,s.style.strokeDashoffset=E==="reverse"?"0":`${T[a]}`,l?s.style.opacity=E==="reverse"?"1":"0":s.style.opacity="",O&&(s.style.stroke=O),M!==null&&(s.style.strokeWidth=`${M}`),w!==null&&(s.style.fillOpacity=`${w}`),D&&s.tagName.toLowerCase()==="path"&&Q[a]&&s.setAttribute("d",Q[a]);});}if(I.forEach(s=>{ht(s);let a=Re(s);T.push(a),s.tagName.toLowerCase()==="path"?Q.push(s.getAttribute("d")??""):Q.push(""),c?(s.style.strokeDasharray=`${a}`,s.style.strokeDashoffset=E==="reverse"?`${a}`:"0",l&&(s.style.opacity="1"),S&&(s.style.stroke=S),F!==null&&(s.style.strokeWidth=`${F}`),A!==null&&(s.style.fillOpacity=`${A}`),D&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",D)):(s.style.strokeDasharray=`${a}`,s.style.strokeDashoffset=E==="reverse"?"0":`${a}`,l?s.style.opacity=E==="reverse"?"1":"0":s.style.opacity="",O&&(s.style.stroke=O),M!==null&&(s.style.strokeWidth=`${M}`),w!==null&&(s.style.fillOpacity=`${w}`));}),j){if(c)return e.style.clipPath=q(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=q(0);}else if(c)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function ut(){return !(ze===false||!yt()||!I.length||typeof g!="string"||!(g in Qe)||j||z!=="y"||f||i!==1||V!==0||re||L||ae!==false||D||ie||_||W>0||ce||le||K||ne!=null||se!=null||oe!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function ct(){let s=`svg-scroll-draw-${++gt}`,a=E==="reverse"?"0":"var(--ssd-len)",y=E==="reverse"?"var(--ssd-len)":"0",P=`stroke-dashoffset:${a};`,G=`stroke-dashoffset:${y};`;l&&(P+=`opacity:${E==="reverse"?1:0};`,G+=`opacity:${E==="reverse"?0:1};`);let H=document.createElement("style");H.setAttribute("data-svg-scroll-draw",""),H.textContent=`@keyframes ${s}{from{${P}}to{${G}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${Qe[g]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(H);function d(p,b){p.style.setProperty("--ssd-len",String(T[b])),p.style.strokeDasharray=`${T[b]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(s);}I.forEach(d);let v=false,k=-1;function h(){if(k>=0)return k;let p=e.getBoundingClientRect(),{tStart:b,tEnd:$}=Ae({top:p.top,height:p.height},ke(),je(),ye,u);return X(U(ke(),b,$,i))}return {destroy(){I.forEach(p=>{p.classList.remove(s),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),H.remove();},replay(){v=false,k=-1,I.forEach(d);},pause(){v=true,I.forEach(p=>{p.style.animationPlayState="paused";});},resume(){v&&(v=false,I.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let b=Math.min(1,Math.max(0,p));k=b,v=true,I.forEach(($,be)=>{$.classList.remove(s),$.style.strokeDashoffset=E==="reverse"?`${T[be]*b}`:`${T[be]*(1-b)}`,l&&($.style.opacity=E==="reverse"?`${1-b}`:`${b}`);});},getProgress(){return h()}}}if(ut())return ct();function ft(){let s=Math.max(1,Me),a=0,y=0;function P(h){let p=true;if(j){let b=Math.min(1,Math.max(0,h/s)),$=X(b);he=$,e.style.setProperty("--scroll-draw-progress",String($)),e.style.clipPath=q(E==="reverse"?1-$:$),ce?.($),b<1&&(p=false);}else I.forEach((b,$)=>{let be=$*V*s,Se=Math.min(1,Math.max(0,(h-be)/s)),te=X(Se);b.style.strokeDashoffset=E==="reverse"?`${T[$]*te}`:`${T[$]*(1-te)}`,l&&(b.style.opacity=E==="reverse"?`${1-te}`:`${te}`),O&&S?b.style.stroke=Te(O,S,te):S&&(b.style.stroke=S),M!==null&&F!==null?b.style.strokeWidth=`${M+(F-M)*te}`:F!==null&&(b.style.strokeWidth=`${F}`),w!==null&&A!==null?b.style.fillOpacity=`${w+(A-w)*te}`:A!==null&&(b.style.fillOpacity=`${A}`),D&&b.tagName.toLowerCase()==="path"&&Q[$]&&b.setAttribute("d",_e(Q[$],D,te)),$===0&&(ce?.(te),e.style.setProperty("--scroll-draw-progress",String(te))),Se<1&&(p=false);});if(ie){let b=Math.min(1,Math.max(0,h/s)),$=X(b);for(let be in ie){let Se=parseFloat(be);$>=Se&&!de.has(Se)&&(de.add(Se),ie[be]?.());}}return p}function G(h){if(R)return;let p=h-a;Y||(Y=true,le?.());let b=P(p);if(b&&!N){N=true,P(s*(1+Math.max(0,I.length-1)*V)),K?.(),ue<(_==="infinite"?1/0:_??0)&&(ue++,pe=setTimeout(()=>{a=performance.now(),Y=false,N=false,de.clear(),Oe(),C=requestAnimationFrame(G);},B));return}b||(C=requestAnimationFrame(G));}function H(){cancelAnimationFrame(C),clearTimeout(pe),a=performance.now(),y=0,R=false,Y=false,N=false,ue=0,de.clear(),Oe(),C=requestAnimationFrame(G);}let d=new IntersectionObserver(h=>{h.forEach(p=>{p.isIntersecting&&!(re&&N)?H():!p.isIntersecting&&!re&&!N&&(cancelAnimationFrame(C),clearTimeout(pe),a=null);});},{root:f??null,threshold:ge,rootMargin:Z}),v;function k(){clearTimeout(v),v=setTimeout(()=>{I.forEach((h,p)=>{T[p]=Re(h),h.style.strokeDasharray=`${T[p]}`;});},150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),W>0?setTimeout(()=>d.observe(e),W):d.observe(e),{destroy(){cancelAnimationFrame(C),clearTimeout(pe),d.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(v);},replay(){ue=0,H();},pause(){R||(R=true,y=performance.now()-a,cancelAnimationFrame(C));},resume(){R&&(R=false,a=performance.now()-y,C=requestAnimationFrame(G));},seek(h){let p=Math.min(1,Math.max(0,h));he=p,R=true,y=p*s,a=performance.now()-y,cancelAnimationFrame(C),P(y);},getProgress(){return he}}}if(ve)return ft();Xe();function Fe(){if(!De||R)return;let s=performance.now(),a=ke(),y=i;if(ae!==false){let d=s-Be,v=d>0?Math.abs(a-(Ce<0?a:Ce))/d:0;y=i*Math.max(.2,1+v*(typeof ae=="number"?ae:1)*.04);}Ce=a,Be=s;let P=L?Ie===-1||a>=Ie?"forward":"reverse":E;Ie=a;let G=me-fe,H=true;if(j){let d=X(U(a,fe,me,y));re&&!L&&(ee=Math.max(ee,d),d=ee),he=d,e.style.setProperty("--scroll-draw-progress",String(d));let v=P==="reverse"?1-d:d;e.style.clipPath=q(v),ce?.(d),!Y&&U(a,fe,me,y)>0&&(Y=true,le?.()),d>=1&&!N?(N=true,K?.(),ue<(_==="infinite"?1/0:_??0)&&(ue++,pe=setTimeout(()=>{ee=-1,Y=false,N=false,e.style.clipPath=q(0);},B))):d<1&&!re&&(N=false),C=requestAnimationFrame(Fe);return}if(I.forEach((d,v)=>{let k=v*V*G,h=X(U(a,fe+k,me+k,y));re&&!L&&(ee=Math.max(ee,h),h=ee),he=h,d.style.strokeDashoffset=P==="reverse"?`${T[v]*h}`:`${T[v]*(1-h)}`,l&&(d.style.opacity=P==="reverse"?`${1-h}`:`${h}`),O&&S?d.style.stroke=Te(O,S,h):S&&(d.style.stroke=S),M!==null&&F!==null?d.style.strokeWidth=`${M+(F-M)*h}`:F!==null&&(d.style.strokeWidth=`${F}`),w!==null&&A!==null?d.style.fillOpacity=`${w+(A-w)*h}`:A!==null&&(d.style.fillOpacity=`${A}`),D&&d.tagName.toLowerCase()==="path"&&Q[v]&&d.setAttribute("d",_e(Q[v],D,h)),v===0&&(ce?.(h),e.style.setProperty("--scroll-draw-progress",String(h))),h<1&&(H=false);}),ie){let d=X(U(a,fe,me,y));for(let v in ie){let k=parseFloat(v);d>=k&&!de.has(k)&&(de.add(k),ie[v]?.());}}!Y&&U(a,fe,me,y)>0&&(Y=true,le?.()),H&&!N?(N=true,K?.(),ue<(_==="infinite"?1/0:_??0)&&(ue++,pe=setTimeout(()=>{ee=-1,Y=false,N=false,de.clear(),Oe();},B))):!H&&!re&&(N=false),C=requestAnimationFrame(Fe);}let qe=new IntersectionObserver(s=>{s.forEach(a=>{De=a.isIntersecting,De&&!R?C=requestAnimationFrame(Fe):cancelAnimationFrame(C);});},{root:f??null,threshold:ge,rootMargin:Z}),Ve;function Ne(){clearTimeout(Ve),Ve=setTimeout(()=>{I.forEach((s,a)=>{T[a]=Re(s),s.style.strokeDasharray=`${T[a]}`;}),Xe();},150);}return window.addEventListener("resize",Ne),window.addEventListener("orientationchange",Ne),W>0?setTimeout(()=>qe.observe(e),W):qe.observe(e),{destroy(){cancelAnimationFrame(C),clearTimeout(pe),qe.disconnect(),window.removeEventListener("resize",Ne),window.removeEventListener("orientationchange",Ne),clearTimeout(Ve),We?.remove();},replay(){ee=-1,Ie=-1,Ce=-1,Y=false,N=false,ue=0,R=false,de.clear(),clearTimeout(pe),Oe();},pause(){R=true,cancelAnimationFrame(C);},resume(){R&&(R=false,De&&(C=requestAnimationFrame(Fe)));},seek(s){let a=Math.min(1,Math.max(0,s));he=a,ee=a,R=true,cancelAnimationFrame(C),lt(a,E);},getProgress(){return he}}}var et=new Map;function tt(e,n){et.set(e,n);}function rt(e){et.delete(e);}function wt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function nt(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let o=[],c=[],m=t[2].trim();if(m)for(let i of m.split(/[\s,]+/)){let l=i.match(/^([-+]?[\d.eE]+)(.*)$/);o.push(l?parseFloat(l[1]):0),c.push(l?l[2]:"");}n.push({fn:t[1],nums:o,units:c});}return n}function Et(e,n,r){let t=nt(e),o=nt(n);return t.length===0||t.length!==o.length?r<1?e:n:t.map((c,m)=>{let i=o[m];return c.fn!==i.fn||c.nums.length!==i.nums.length?r<1?`${c.fn}(${c.nums.map((l,g)=>`${l}${c.units[g]}`).join(", ")})`:`${i.fn}(${i.nums.map((l,g)=>`${l}${i.units[g]}`).join(", ")})`:`${c.fn}(${c.nums.map((l,g)=>`${l+(i.nums[g]-l)*r}${c.units[g]}`).join(", ")})`}).join(" ")}function st(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),o=String(n);if(wt(t))return Te(t,o,r);if(t.includes("("))return Et(t,o,r);let c=t.match(/^([-+]?[\d.]+)(.*)$/),m=o.match(/^([-+]?[\d.]+)(.*)$/);if(c&&m){let i=parseFloat(c[1]),l=parseFloat(m[1]);return `${i+(l-i)*r}${c[2]||m[2]}`}return r<1?t:o}function vt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var ot={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},St=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),xt=0;function $t(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function He(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:o={},easing:c="ease-out",speed:m=1,once:i=false,axis:l="y",scrollContainer:g,native:x=true,onProgress:V,onComplete:E}=n,re=window.matchMedia("(prefers-reduced-motion: reduce)").matches,Pe=typeof c=="function"?c:xe[c]??xe["ease-out"],z=$e(o.start??"top bottom"),Ee=$e(o.end??"bottom top"),L=typeof g=="string"?document.querySelector(g):g??null,W=Object.entries(t).map(([u,f])=>({prop:vt(u),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function ne(){let u=window.getComputedStyle(e);for(let f of W)f.from===""&&(f.from=u.getPropertyValue(f.prop).trim()||"0");}function se(){for(let u of W)e.style.setProperty(u.prop,String(u.to));}if(re)return se(),E?.(),r;ne();function oe(){if(!x||!$t()||typeof c!="string"||!(c in ot)||l!=="y"||L||i||m!==1||V||E||(o.start??"top bottom").trim()!=="top bottom"||(o.end??"bottom top").trim()!=="bottom top")return false;for(let u of W)if(!St.has(u.prop))return false;return true}function ie(){let u=`ssd-a-${++xt}`,f=W.map(w=>`${w.prop}:${w.from}`).join(";"),O=W.map(w=>`${w.prop}:${w.to}`).join(";"),S=document.createElement("style");S.setAttribute("data-ssd-animate",""),S.textContent=`@keyframes ${u}{from{${f}}to{${O}}}.${u}{animation-name:${u};animation-duration:auto;animation-timing-function:${ot[c]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(S),e.classList.add(u);let M=()=>l==="x"?window.scrollX:window.scrollY,F=()=>l==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(u),S.remove();},replay(){e.classList.remove(u),e.offsetWidth,e.classList.add(u);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(w){let A=Math.min(1,Math.max(0,w));e.classList.remove(u);for(let q of W)e.style.setProperty(q.prop,st(q.from,q.to,A));},getProgress(){let w=e.getBoundingClientRect(),A=M(),q=F(),{tStart:I,tEnd:T}=Ae({top:w.top,height:w.height},A,q,z,Ee);return Pe(U(A,I,T,m))}}}if(oe())return ie();let ae=0,ge=0,Z=0,_=false,B=false,D=-1,J=0,ve=false,Me=()=>L?l==="x"?L.scrollLeft:L.scrollTop:l==="x"?window.scrollX:window.scrollY,ze=()=>L?l==="x"?L.clientWidth:L.clientHeight:l==="x"?window.innerWidth:window.innerHeight;function ce(){let u=e.getBoundingClientRect(),f,O;if(L){let M=L.getBoundingClientRect();f=l==="x"?u.left-M.left+L.scrollLeft:u.top-M.top+L.scrollTop,O=l==="x"?u.width:u.height;}else f=l==="x"?u.left:u.top,O=l==="x"?u.width:u.height;let S=Ae({top:f,height:O},Me(),ze(),z,Ee);ae=S.tStart,ge=S.tEnd;}function le(u){e.style.setProperty("--scroll-draw-progress",String(u));for(let f of W)e.style.setProperty(f.prop,st(f.from,f.to,u));V?.(u);}function K(){if(!_||B)return;let u=Pe(U(Me(),ae,ge,m));i&&(D=Math.max(D,u),u=D),J=u,le(u),u>=1&&!ve?(ve=true,E?.()):u<1&&!i&&(ve=false),Z=requestAnimationFrame(K);}ce();{let u=Pe(U(Me(),ae,ge,m));i&&u>0&&(D=u),J=u,le(u);}let j=new IntersectionObserver(u=>{u.forEach(f=>{_=f.isIntersecting,_&&!B?Z=requestAnimationFrame(K):cancelAnimationFrame(Z);});},{root:L??null}),X;function ye(){clearTimeout(X),X=setTimeout(ce,150);}return window.addEventListener("resize",ye),window.addEventListener("orientationchange",ye),j.observe(e),tt(e,{type:"animate",getProgress:()=>J,getTrigger:()=>({tStart:ae,tEnd:ge})}),{destroy(){cancelAnimationFrame(Z),j.disconnect(),window.removeEventListener("resize",ye),window.removeEventListener("orientationchange",ye),clearTimeout(X),rt(e);},replay(){D=-1,ve=false,J=0,B=false,le(0);},pause(){B=true,cancelAnimationFrame(Z);},resume(){B&&(B=false,_&&(Z=requestAnimationFrame(K)));},seek(u){let f=Math.min(1,Math.max(0,u));J=f,D=f,B=true,cancelAnimationFrame(Z),le(f);},getProgress(){return J}}}var it={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function at(e,n={}){if(typeof window>"u")return it;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),it;let{speed:t=.3,axis:o="y",easing:c="linear",trigger:m,onProgress:i}=n,l=r.getBoundingClientRect(),g=o==="x"?l.width:l.height,x=t*g;return He(r,{props:o==="x"?{transform:["translateX(0px)",`translateX(${-x}px)`]}:{transform:["translateY(0px)",`translateY(${-x}px)`]},trigger:m??{start:"top bottom",end:"bottom top"},easing:c,native:false,onProgress:i})}function Le(e){return e.map(n=>typeof n=="string"?document.querySelector(n):n).filter(n=>n!==null)}var we={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Nt(e,n={}){if(typeof window>"u")return we;let r=Le(e).map(t=>Ge(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function Rt(e,n={}){if(typeof window>"u")return we;let r=Le(e);if(r.length===0)return we;let t=0,o=[];function c(i){return Ge(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=i+1,o[t]?.resume();}})}function m(){r.forEach((i,l)=>{o[l]=c(l);});for(let i=1;i<o.length;i++)o[i].pause();}return m(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,m();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0}}}function Ht(e,n){if(typeof window>"u")return we;let r=Le(e).map(t=>He(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function zt(e,n){if(typeof window>"u")return we;let r=Le(e);if(r.length===0)return we;let t=0,o=[];function c(i){return He(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=i+1,o[t]?.resume();}})}function m(){r.forEach((i,l)=>{o[l]=c(l);});for(let i=1;i<o.length;i++)o[i].pause();}return m(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,m();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0}}}function Wt(e,n={}){if(typeof window>"u")return we;let r=Le(e).map(t=>at(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}exports.scrollAnimateGroup=Ht;exports.scrollAnimateSequence=zt;exports.scrollDrawGroup=Nt;exports.scrollDrawSequence=Rt;exports.scrollParallaxGroup=Wt;
|
|
1
|
+
'use strict';function ht({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),o=Math.sqrt(t),f=0,d=[];for(let g=0;g<r;g++){let x=Math.pow(o,g);d.push(x),f+=x;}let i=[0],u=0;for(let g=0;g<r;g++)u+=d[g]/f,i.push(u);return g=>{if(g<=0)return 0;if(g>=1)return 1;for(let x=0;x<r;x++)if(g<=i[x+1]){let B=(g-i[x])/(i[x+1]-i[x]);if(x===0)return B*(2-B);let b=1-Math.pow(t,x);return b+(1-b)*(2*B-1)*(2*B-1)}return 1}}function bt({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),o=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return f=>f<=0?0:f>=1?1:r*Math.pow(2,-10*f)*Math.sin((f-o)*(2*Math.PI)/t)+1}var Ae={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:ht(),elastic:bt()};function Te(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",t="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:t}}function Qe(e,n,r,t){switch(t){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function et(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function Ve(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function wt(e,n,r){return Math.min(r,Math.max(n,e))}function J(e,n,r,t){return r===n?0:wt((e-n)/(r-n)*t,0,1)}function Pe(e,n,r,t,o){let f=Qe(e.top,e.height,n,t.element)-et(t.viewport,r),d=Qe(e.top,e.height,n,o.element)-et(o.viewport,r);return {tStart:f,tEnd:d}}function tt(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let t=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return t?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]:null}function Me(e,n,r){let t=tt(e),o=tt(n);return !t||!o?e:`rgb(${Math.round(t[0]+(o[0]-t[0])*r)},${Math.round(t[1]+(o[1]-t[1])*r)},${Math.round(t[2]+(o[2]-t[2])*r)})`}var rt={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};function nt(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n);}var st={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Et=0;function vt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function St(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?nt("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&nt("Element has a fill \u2014 it may obscure the stroke animation.",e);}function xt(e,n,r){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function o(){let f=r==="x"?window.scrollX:window.scrollY,d=e-f,i=n-f,u=r==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${u?`left:${d}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${d}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:${i}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${i}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",o,{passive:true}),o(),t}function Ye(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),o=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,f=>{let d=parseFloat(f),i=t[o++]??d;return String(+(d+(i-d)*r).toFixed(4))})}function Ue(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,o=r?{...rt[r],...t}:t,f=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:i=1,fade:u=false,easing:g="linear",trigger:x={},stagger:B=0,direction:b="forward",once:K=false,debug:Ce=false,axis:q="y",scrollContainer:be,autoReverse:we=false,delay:se=0,strokeColor:Q,strokeWidth:ee,fillOpacity:A,waypoints:N,velocityScale:Ee=false,threshold:Oe=0,rootMargin:Ne="0px",repeat:oe=0,repeatDelay:j=0,morphTo:I,clip:X,autoplay:ve=false,duration:ie=1e3,native:ue=true,onProgress:V,onStart:ae,onComplete:R,onEnter:pe,onLeave:Fe,onEnterBack:ke,onLeaveBack:de}=o,te=X===true?"left":typeof X=="string"?X:false,Y=typeof g=="function"?g:Ae[g]??Ae.linear,Le=Te(x.start??"top bottom"),Se=Te(x.end??"bottom top"),k=typeof be=="string"?document.querySelector(be):be??null,a=Array.isArray(Q)?Q[0]:null,m=Array.isArray(Q)?Q[1]:typeof Q=="string"?Q:null,P=Array.isArray(ee)?ee[0]:null,S=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null,L=Array.isArray(A)?A[0]:null,O=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function D(s){let l=s*100;switch(te){case "right":return `inset(0 0 0 ${100-l}%)`;case "top":return `inset(0 0 ${100-l}% 0)`;case "bottom":return `inset(${100-l}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-l}% 0 0)`}}let T=te?[]:Array.from(e.querySelectorAll(d)),w=[],_=[],U=0,ce=0,F=false,Z=false,C=0,Re=false,re=-1,He=-1,H=false,ge=0,le=0,fe,Ge=null,me=new Set,ze=-1,Ze=performance.now(),xe=NaN;function De(){return k?q==="x"?k.scrollLeft:k.scrollTop:q==="x"?window.scrollX:window.scrollY}function Je(){return k?q==="x"?k.clientWidth:k.clientHeight:q==="x"?window.innerWidth:window.innerHeight}function Ke(){let s=e.getBoundingClientRect(),l,y,M;if(k){let W=k.getBoundingClientRect();l=q==="x"?s.left-W.left+k.scrollLeft:s.top-W.top+k.scrollTop,y=q==="x"?s.width:s.height,M=De();}else l=q==="x"?s.left:s.top,y=q==="x"?s.width:s.height,M=De();let z=Pe({top:l,height:y},M,Je(),Le,Se);U=z.tStart,ce=z.tEnd,Ce&&process.env.NODE_ENV!=="production"&&(Ge?.remove(),Ge=xt(U,ce,q));}function pt(s,l){if(e.style.setProperty("--scroll-draw-progress",String(s)),te){let y=l==="reverse"?1-s:s;e.style.clipPath=D(y);return}T.forEach((y,M)=>{y.style.strokeDashoffset=l==="reverse"?`${w[M]*s}`:`${w[M]*(1-s)}`,u&&(y.style.opacity=l==="reverse"?`${1-s}`:`${s}`),a&&m?y.style.stroke=Me(a,m,s):m&&(y.style.stroke=m),P!==null&&S!==null?y.style.strokeWidth=`${P+(S-P)*s}`:S!==null&&(y.style.strokeWidth=`${S}`),L!==null&&O!==null?y.style.fillOpacity=`${L+(O-L)*s}`:O!==null&&(y.style.fillOpacity=`${O}`),I&&y.tagName.toLowerCase()==="path"&&_[M]&&y.setAttribute("d",Ye(_[M],I,s));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),te){e.style.clipPath=D(0);return}T.forEach((s,l)=>{s.style.strokeDasharray=`${w[l]}`,s.style.strokeDashoffset=b==="reverse"?"0":`${w[l]}`,u?s.style.opacity=b==="reverse"?"1":"0":s.style.opacity="",a&&(s.style.stroke=a),P!==null&&(s.style.strokeWidth=`${P}`),L!==null&&(s.style.fillOpacity=`${L}`),I&&s.tagName.toLowerCase()==="path"&&_[l]&&s.setAttribute("d",_[l]);});}if(T.forEach(s=>{St(s);let l=Ve(s);w.push(l),s.tagName.toLowerCase()==="path"?_.push(s.getAttribute("d")??""):_.push(""),f?(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=b==="reverse"?`${l}`:"0",u&&(s.style.opacity="1"),m&&(s.style.stroke=m),S!==null&&(s.style.strokeWidth=`${S}`),O!==null&&(s.style.fillOpacity=`${O}`),I&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",I)):(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=b==="reverse"?"0":`${l}`,u?s.style.opacity=b==="reverse"?"1":"0":s.style.opacity="",a&&(s.style.stroke=a),P!==null&&(s.style.strokeWidth=`${P}`),L!==null&&(s.style.fillOpacity=`${L}`));}),te){if(f)return e.style.clipPath=D(1),R?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=D(0);}else if(f)return R?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function dt(){return !(ue===false||!vt()||!T.length||typeof g!="string"||!(g in st)||te||q!=="y"||k||i!==1||B!==0||K||we||Ee!==false||I||N||oe||se>0||V||ae||R||pe||Fe||ke||de||Q!=null||ee!=null||A!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function gt(){let s=`svg-scroll-draw-${++Et}`,l=b==="reverse"?"0":"var(--ssd-len)",y=b==="reverse"?"var(--ssd-len)":"0",M=`stroke-dashoffset:${l};`,z=`stroke-dashoffset:${y};`;u&&(M+=`opacity:${b==="reverse"?1:0};`,z+=`opacity:${b==="reverse"?0:1};`);let W=document.createElement("style");W.setAttribute("data-svg-scroll-draw",""),W.textContent=`@keyframes ${s}{from{${M}}to{${z}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${st[g]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(W);function G(c,h){c.style.setProperty("--ssd-len",String(w[h])),c.style.strokeDasharray=`${w[h]}`,c.style.strokeDashoffset="",c.style.opacity="",c.style.animationPlayState="",c.classList.add(s);}T.forEach(G);let p=false,E=-1;function v(){if(E>=0)return E;let c=e.getBoundingClientRect(),{tStart:h,tEnd:$}=Pe({top:c.top,height:c.height},De(),Je(),Le,Se);return Y(J(De(),h,$,i))}return {destroy(){T.forEach(c=>{c.classList.remove(s),c.style.removeProperty("--ssd-len"),c.style.animationPlayState="";}),W.remove();},replay(){p=false,E=-1,T.forEach(G);},pause(){p=true,T.forEach(c=>{c.style.animationPlayState="paused";});},resume(){p&&(p=false,T.forEach(c=>{c.style.animationPlayState="running";}));},seek(c){let h=Math.min(1,Math.max(0,c));E=h,p=true,T.forEach(($,ye)=>{$.classList.remove(s),$.style.strokeDashoffset=b==="reverse"?`${w[ye]*h}`:`${w[ye]*(1-h)}`,u&&($.style.opacity=b==="reverse"?`${1-h}`:`${h}`);});},getProgress(){return v()}}}if(dt())return gt();function yt(){let s=Math.max(1,ie),l=0,y=0;function M(v){let c=true;if(te){let h=Math.min(1,Math.max(0,v/s)),$=Y(h);ge=$,e.style.setProperty("--scroll-draw-progress",String($)),e.style.clipPath=D(b==="reverse"?1-$:$),V?.($),h<1&&(c=false);}else T.forEach((h,$)=>{let ye=$*B*s,$e=Math.min(1,Math.max(0,(v-ye)/s)),ne=Y($e);h.style.strokeDashoffset=b==="reverse"?`${w[$]*ne}`:`${w[$]*(1-ne)}`,u&&(h.style.opacity=b==="reverse"?`${1-ne}`:`${ne}`),a&&m?h.style.stroke=Me(a,m,ne):m&&(h.style.stroke=m),P!==null&&S!==null?h.style.strokeWidth=`${P+(S-P)*ne}`:S!==null&&(h.style.strokeWidth=`${S}`),L!==null&&O!==null?h.style.fillOpacity=`${L+(O-L)*ne}`:O!==null&&(h.style.fillOpacity=`${O}`),I&&h.tagName.toLowerCase()==="path"&&_[$]&&h.setAttribute("d",Ye(_[$],I,ne)),$===0&&(V?.(ne),e.style.setProperty("--scroll-draw-progress",String(ne))),$e<1&&(c=false);});if(N){let h=Math.min(1,Math.max(0,v/s)),$=Y(h);for(let ye in N){let $e=parseFloat(ye);$>=$e&&!me.has($e)&&(me.add($e),N[ye]?.());}}return c}function z(v){if(H)return;let c=v-l;Z||(Z=true,ae?.());let h=M(c);if(h&&!F){F=true,M(s*(1+Math.max(0,T.length-1)*B)),R?.(),le<(oe==="infinite"?1/0:oe??0)&&(le++,fe=setTimeout(()=>{l=performance.now(),Z=false,F=false,me.clear(),We(),C=requestAnimationFrame(z);},j));return}h||(C=requestAnimationFrame(z));}function W(){cancelAnimationFrame(C),clearTimeout(fe),l=performance.now(),y=0,H=false,Z=false,F=false,le=0,me.clear(),We(),C=requestAnimationFrame(z);}let G=new IntersectionObserver(v=>{v.forEach(c=>{c.isIntersecting&&!(K&&F)?W():!c.isIntersecting&&!K&&!F&&(cancelAnimationFrame(C),clearTimeout(fe),l=null);});},{root:k??null,threshold:Oe,rootMargin:Ne}),p;function E(){clearTimeout(p),p=setTimeout(()=>{T.forEach((v,c)=>{w[c]=Ve(v),v.style.strokeDasharray=`${w[c]}`;});},150);}return window.addEventListener("resize",E),window.addEventListener("orientationchange",E),se>0?setTimeout(()=>G.observe(e),se):G.observe(e),{destroy(){cancelAnimationFrame(C),clearTimeout(fe),G.disconnect(),window.removeEventListener("resize",E),window.removeEventListener("orientationchange",E),clearTimeout(p);},replay(){le=0,W();},pause(){H||(H=true,y=performance.now()-l,cancelAnimationFrame(C));},resume(){H&&(H=false,l=performance.now()-y,C=requestAnimationFrame(z));},seek(v){let c=Math.min(1,Math.max(0,v));ge=c,H=true,y=c*s,l=performance.now()-y,cancelAnimationFrame(C),M(y);},getProgress(){return ge}}}if(ve)return yt();Ke();function qe(){if(!Re||H)return;let s=performance.now(),l=De(),y=i;if(Ee!==false){let p=s-Ze,E=p>0?Math.abs(l-(ze<0?l:ze))/p:0;y=i*Math.max(.2,1+E*(typeof Ee=="number"?Ee:1)*.04);}ze=l,Ze=s;let M=we?He===-1||l>=He?"forward":"reverse":b;He=l;let z=ce-U,W=true,G=z===0?0:(l-U)/z;if(isNaN(xe)||(xe<=0&&G>0?pe?.():xe>0&&G<=0&&de?.(),xe<1&&G>=1?Fe?.():xe>=1&&G<1&&ke?.()),xe=G,te){let p=Y(J(l,U,ce,y));K&&!we&&(re=Math.max(re,p),p=re),ge=p,e.style.setProperty("--scroll-draw-progress",String(p));let E=M==="reverse"?1-p:p;e.style.clipPath=D(E),V?.(p),!Z&&J(l,U,ce,y)>0&&(Z=true,ae?.()),p>=1&&!F?(F=true,R?.(),le<(oe==="infinite"?1/0:oe??0)&&(le++,fe=setTimeout(()=>{re=-1,Z=false,F=false,e.style.clipPath=D(0);},j))):p<1&&!K&&(F=false),C=requestAnimationFrame(qe);return}if(T.forEach((p,E)=>{let v=E*B*z,c=Y(J(l,U+v,ce+v,y));K&&!we&&(re=Math.max(re,c),c=re),ge=c,p.style.strokeDashoffset=M==="reverse"?`${w[E]*c}`:`${w[E]*(1-c)}`,u&&(p.style.opacity=M==="reverse"?`${1-c}`:`${c}`),a&&m?p.style.stroke=Me(a,m,c):m&&(p.style.stroke=m),P!==null&&S!==null?p.style.strokeWidth=`${P+(S-P)*c}`:S!==null&&(p.style.strokeWidth=`${S}`),L!==null&&O!==null?p.style.fillOpacity=`${L+(O-L)*c}`:O!==null&&(p.style.fillOpacity=`${O}`),I&&p.tagName.toLowerCase()==="path"&&_[E]&&p.setAttribute("d",Ye(_[E],I,c)),E===0&&(V?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(W=false);}),N){let p=Y(J(l,U,ce,y));for(let E in N){let v=parseFloat(E);p>=v&&!me.has(v)&&(me.add(v),N[E]?.());}}!Z&&J(l,U,ce,y)>0&&(Z=true,ae?.()),W&&!F?(F=true,R?.(),le<(oe==="infinite"?1/0:oe??0)&&(le++,fe=setTimeout(()=>{re=-1,Z=false,F=false,me.clear(),We();},j))):!W&&!K&&(F=false),C=requestAnimationFrame(qe);}let je=new IntersectionObserver(s=>{s.forEach(l=>{Re=l.isIntersecting,Re&&!H?C=requestAnimationFrame(qe):cancelAnimationFrame(C);});},{root:k??null,threshold:Oe,rootMargin:Ne}),Xe;function Be(){clearTimeout(Xe),Xe=setTimeout(()=>{T.forEach((s,l)=>{w[l]=Ve(s),s.style.strokeDasharray=`${w[l]}`;}),Ke();},150);}return window.addEventListener("resize",Be),window.addEventListener("orientationchange",Be),se>0?setTimeout(()=>je.observe(e),se):je.observe(e),{destroy(){cancelAnimationFrame(C),clearTimeout(fe),je.disconnect(),window.removeEventListener("resize",Be),window.removeEventListener("orientationchange",Be),clearTimeout(Xe),Ge?.remove();},replay(){re=-1,He=-1,ze=-1,Z=false,F=false,le=0,H=false,me.clear(),clearTimeout(fe),We();},pause(){H=true,cancelAnimationFrame(C);},resume(){H&&(H=false,Re&&(C=requestAnimationFrame(qe)));},seek(s){let l=Math.min(1,Math.max(0,s));ge=l,re=l,H=true,cancelAnimationFrame(C),pt(l,b);},getProgress(){return ge}}}var ot=new Map;function it(e,n){ot.set(e,n);}function at(e){ot.delete(e);}function $t(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function lt(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let o=[],f=[],d=t[2].trim();if(d)for(let i of d.split(/[\s,]+/)){let u=i.match(/^([-+]?[\d.eE]+)(.*)$/);o.push(u?parseFloat(u[1]):0),f.push(u?u[2]:"");}n.push({fn:t[1],nums:o,units:f});}return n}function At(e,n,r){let t=lt(e),o=lt(n);return t.length===0||t.length!==o.length?r<1?e:n:t.map((f,d)=>{let i=o[d];return f.fn!==i.fn||f.nums.length!==i.nums.length?r<1?`${f.fn}(${f.nums.map((u,g)=>`${u}${f.units[g]}`).join(", ")})`:`${i.fn}(${i.nums.map((u,g)=>`${u}${i.units[g]}`).join(", ")})`:`${f.fn}(${f.nums.map((u,g)=>`${u+(i.nums[g]-u)*r}${f.units[g]}`).join(", ")})`}).join(" ")}function ut(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),o=String(n);if($t(t))return Me(t,o,r);if(t.includes("("))return At(t,o,r);let f=t.match(/^([-+]?[\d.]+)(.*)$/),d=o.match(/^([-+]?[\d.]+)(.*)$/);if(f&&d){let i=parseFloat(f[1]),u=parseFloat(d[1]);return `${i+(u-i)*r}${f[2]||d[2]}`}return r<1?t:o}function Tt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var ct={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Pt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Mt=0;function kt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function _e(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:o={},easing:f="ease-out",speed:d=1,once:i=false,axis:u="y",scrollContainer:g,native:x=true,onProgress:B,onComplete:b,onEnter:K,onLeave:Ce,onEnterBack:q,onLeaveBack:be}=n,we=window.matchMedia("(prefers-reduced-motion: reduce)").matches,se=typeof f=="function"?f:Ae[f]??Ae["ease-out"],Q=Te(o.start??"top bottom"),ee=Te(o.end??"bottom top"),A=typeof g=="string"?document.querySelector(g):g??null,N=Object.entries(t).map(([a,m])=>({prop:Tt(a),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function Ee(){let a=window.getComputedStyle(e);for(let m of N)m.from===""&&(m.from=a.getPropertyValue(m.prop).trim()||"0");}function Oe(){for(let a of N)e.style.setProperty(a.prop,String(a.to));}if(we)return Oe(),b?.(),r;Ee();function Ne(){if(!x||!kt()||typeof f!="string"||!(f in ct)||u!=="y"||A||i||d!==1||B||b||K||Ce||q||be||(o.start??"top bottom").trim()!=="top bottom"||(o.end??"bottom top").trim()!=="bottom top")return false;for(let a of N)if(!Pt.has(a.prop))return false;return true}function oe(){let a=`ssd-a-${++Mt}`,m=N.map(D=>`${D.prop}:${D.from}`).join(";"),P=N.map(D=>`${D.prop}:${D.to}`).join(";"),S=document.createElement("style");S.setAttribute("data-ssd-animate",""),S.textContent=`@keyframes ${a}{from{${m}}to{${P}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${ct[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(S),e.classList.add(a);let L=()=>u==="x"?window.scrollX:window.scrollY,O=()=>u==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),S.remove();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(D){let T=Math.min(1,Math.max(0,D));e.classList.remove(a);for(let w of N)e.style.setProperty(w.prop,ut(w.from,w.to,T));},getProgress(){let D=e.getBoundingClientRect(),T=L(),w=O(),{tStart:_,tEnd:U}=Pe({top:D.top,height:D.height},T,w,Q,ee);return se(J(T,_,U,d))}}}if(Ne())return oe();let j=0,I=0,X=0,ve=false,ie=false,ue=-1,V=0,ae=false,R=NaN,pe=()=>A?u==="x"?A.scrollLeft:A.scrollTop:u==="x"?window.scrollX:window.scrollY,Fe=()=>A?u==="x"?A.clientWidth:A.clientHeight:u==="x"?window.innerWidth:window.innerHeight;function ke(){let a=e.getBoundingClientRect(),m,P;if(A){let L=A.getBoundingClientRect();m=u==="x"?a.left-L.left+A.scrollLeft:a.top-L.top+A.scrollTop,P=u==="x"?a.width:a.height;}else m=u==="x"?a.left:a.top,P=u==="x"?a.width:a.height;let S=Pe({top:m,height:P},pe(),Fe(),Q,ee);j=S.tStart,I=S.tEnd;}function de(a){e.style.setProperty("--scroll-draw-progress",String(a));for(let m of N)e.style.setProperty(m.prop,ut(m.from,m.to,a));B?.(a);}function te(a){if(isNaN(R)){R=a;return}R<=0&&a>0?K?.():R>0&&a<=0&&be?.(),R<1&&a>=1?Ce?.():R>=1&&a<1&&q?.(),R=a;}function Y(){if(!ve||ie)return;let a=I===j?0:(pe()-j)/(I-j);te(a);let m=se(J(pe(),j,I,d));i&&(ue=Math.max(ue,m),m=ue),V=m,de(m),m>=1&&!ae?(ae=true,b?.()):m<1&&!i&&(ae=false),X=requestAnimationFrame(Y);}ke();{let a=se(J(pe(),j,I,d));i&&a>0&&(ue=a),V=a,de(a);}let Le=new IntersectionObserver(a=>{a.forEach(m=>{ve=m.isIntersecting,ve&&!ie?X=requestAnimationFrame(Y):cancelAnimationFrame(X);});},{root:A??null}),Se;function k(){clearTimeout(Se),Se=setTimeout(ke,150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),Le.observe(e),it(e,{type:"animate",getProgress:()=>V,getTrigger:()=>({tStart:j,tEnd:I})}),{destroy(){cancelAnimationFrame(X),Le.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(Se),at(e);},replay(){ue=-1,ae=false,V=0,ie=false,de(0);},pause(){ie=true,cancelAnimationFrame(X);},resume(){ie&&(ie=false,ve&&(X=requestAnimationFrame(Y)));},seek(a){let m=Math.min(1,Math.max(0,a));V=m,ue=m,ie=true,cancelAnimationFrame(X),de(m);},getProgress(){return V}}}var ft={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function mt(e,n={}){if(typeof window>"u")return ft;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),ft;let{speed:t=.3,axis:o="y",easing:f="linear",trigger:d,onProgress:i}=n,u=r.getBoundingClientRect(),g=o==="x"?u.width:u.height,x=t*g;return _e(r,{props:o==="x"?{transform:["translateX(0px)",`translateX(${-x}px)`]}:{transform:["translateY(0px)",`translateY(${-x}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:f,native:false,onProgress:i})}function Ie(e){return e.map(n=>typeof n=="string"?document.querySelector(n):n).filter(n=>n!==null)}var he={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function qt(e,n={}){if(typeof window>"u")return he;let r=Ie(e).map(t=>Ue(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function Bt(e,n={}){if(typeof window>"u")return he;let r=Ie(e);if(r.length===0)return he;let t=0,o=[];function f(i){return Ue(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=i+1,o[t]?.resume();}})}function d(){r.forEach((i,u)=>{o[u]=f(u);});for(let i=1;i<o.length;i++)o[i].pause();}return d(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,d();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0}}}function Vt(e,n){if(typeof window>"u")return he;let r=Ie(e).map(t=>_e(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function _t(e,n){if(typeof window>"u")return he;let r=Ie(e);if(r.length===0)return he;let t=0,o=[];function f(i){return _e(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=i+1,o[t]?.resume();}})}function d(){r.forEach((i,u)=>{o[u]=f(u);});for(let i=1;i<o.length;i++)o[i].pause();}return d(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,d();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0}}}function Gt(e,n={}){if(typeof window>"u")return he;let r=Ie(e).map(t=>mt(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}exports.scrollAnimateGroup=Vt;exports.scrollAnimateSequence=_t;exports.scrollDrawGroup=qt;exports.scrollDrawSequence=Bt;exports.scrollParallaxGroup=Gt;
|
package/dist/group/index.d.mts
CHANGED
|
@@ -71,6 +71,14 @@ interface ScrollDrawOptions {
|
|
|
71
71
|
onProgress?: (alpha: number) => void;
|
|
72
72
|
onStart?: () => void;
|
|
73
73
|
onComplete?: () => void;
|
|
74
|
+
/** Fires when scroll position enters the trigger zone (scrolling forward). */
|
|
75
|
+
onEnter?: () => void;
|
|
76
|
+
/** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
|
|
77
|
+
onLeave?: () => void;
|
|
78
|
+
/** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
|
|
79
|
+
onEnterBack?: () => void;
|
|
80
|
+
/** Fires when scroll position exits the trigger zone at the start (scrolling back). */
|
|
81
|
+
onLeaveBack?: () => void;
|
|
74
82
|
/**
|
|
75
83
|
* Trigger the animation when the element enters the viewport instead of
|
|
76
84
|
* tying it to scroll position. The draw runs over `duration` milliseconds,
|
|
@@ -130,6 +138,14 @@ interface ScrollAnimateOptions {
|
|
|
130
138
|
native?: boolean;
|
|
131
139
|
onProgress?: (alpha: number) => void;
|
|
132
140
|
onComplete?: () => void;
|
|
141
|
+
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
|
142
|
+
onEnter?: () => void;
|
|
143
|
+
/** Fires when scroll exits the trigger zone at the end (scrolling forward). */
|
|
144
|
+
onLeave?: () => void;
|
|
145
|
+
/** Fires when scroll re-enters the trigger zone from the end (scrolling back). */
|
|
146
|
+
onEnterBack?: () => void;
|
|
147
|
+
/** Fires when scroll exits the trigger zone at the start (scrolling back). */
|
|
148
|
+
onLeaveBack?: () => void;
|
|
133
149
|
}
|
|
134
150
|
interface ScrollParallaxOptions {
|
|
135
151
|
speed?: number;
|
package/dist/group/index.d.ts
CHANGED
|
@@ -71,6 +71,14 @@ interface ScrollDrawOptions {
|
|
|
71
71
|
onProgress?: (alpha: number) => void;
|
|
72
72
|
onStart?: () => void;
|
|
73
73
|
onComplete?: () => void;
|
|
74
|
+
/** Fires when scroll position enters the trigger zone (scrolling forward). */
|
|
75
|
+
onEnter?: () => void;
|
|
76
|
+
/** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
|
|
77
|
+
onLeave?: () => void;
|
|
78
|
+
/** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
|
|
79
|
+
onEnterBack?: () => void;
|
|
80
|
+
/** Fires when scroll position exits the trigger zone at the start (scrolling back). */
|
|
81
|
+
onLeaveBack?: () => void;
|
|
74
82
|
/**
|
|
75
83
|
* Trigger the animation when the element enters the viewport instead of
|
|
76
84
|
* tying it to scroll position. The draw runs over `duration` milliseconds,
|
|
@@ -130,6 +138,14 @@ interface ScrollAnimateOptions {
|
|
|
130
138
|
native?: boolean;
|
|
131
139
|
onProgress?: (alpha: number) => void;
|
|
132
140
|
onComplete?: () => void;
|
|
141
|
+
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
|
142
|
+
onEnter?: () => void;
|
|
143
|
+
/** Fires when scroll exits the trigger zone at the end (scrolling forward). */
|
|
144
|
+
onLeave?: () => void;
|
|
145
|
+
/** Fires when scroll re-enters the trigger zone from the end (scrolling back). */
|
|
146
|
+
onEnterBack?: () => void;
|
|
147
|
+
/** Fires when scroll exits the trigger zone at the start (scrolling back). */
|
|
148
|
+
onLeaveBack?: () => void;
|
|
133
149
|
}
|
|
134
150
|
interface ScrollParallaxOptions {
|
|
135
151
|
speed?: number;
|