svg-scroll-draw 2.7.0 → 2.9.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 +2 -2
- package/dist/angular/index.d.mts +6 -0
- package/dist/angular/index.d.ts +6 -0
- package/dist/angular/index.mjs +2 -2
- package/dist/astro/index.cjs +3 -3
- package/dist/astro/index.mjs +3 -3
- package/dist/cdn/svg-scroll-draw.global.js +3 -3
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +6 -0
- package/dist/group/index.d.ts +6 -0
- package/dist/group/index.mjs +3 -3
- package/dist/horizontal/index.cjs +1 -0
- package/dist/horizontal/index.d.mts +61 -0
- package/dist/horizontal/index.d.ts +61 -0
- package/dist/horizontal/index.mjs +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +2 -2
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +6 -0
- package/dist/nuxt/index.d.ts +6 -0
- package/dist/nuxt/index.mjs +3 -3
- package/dist/pin/index.cjs +1 -1
- package/dist/pin/index.mjs +1 -1
- package/dist/progress/index.cjs +1 -0
- package/dist/progress/index.d.mts +59 -0
- package/dist/progress/index.d.ts +59 -0
- package/dist/progress/index.mjs +1 -0
- package/dist/react/index.cjs +3 -3
- package/dist/react/index.d.mts +6 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.mjs +3 -3
- package/dist/reveal/index.cjs +1 -0
- package/dist/reveal/index.d.mts +80 -0
- package/dist/reveal/index.d.ts +80 -0
- package/dist/reveal/index.mjs +1 -0
- package/dist/solid/index.cjs +2 -2
- package/dist/solid/index.d.mts +6 -0
- package/dist/solid/index.d.ts +6 -0
- package/dist/solid/index.mjs +2 -2
- package/dist/svelte/index.cjs +2 -2
- package/dist/svelte/index.d.mts +6 -0
- package/dist/svelte/index.d.ts +6 -0
- package/dist/svelte/index.mjs +2 -2
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.mts +6 -0
- package/dist/vue/index.d.ts +6 -0
- package/dist/vue/index.mjs +2 -2
- package/package.json +16 -1
package/dist/astro/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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)),
|
|
2
|
-
<div style="position:absolute;${c?`left:${
|
|
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
|
+
function ot({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),u=Math.sqrt(t),i=0,p=[];for(let g=0;g<r;g++){let M=Math.pow(u,g);p.push(M),i+=M;}let m=[0],c=0;for(let g=0;g<r;g++)c+=p[g]/i,m.push(c);return g=>{if(g<=0)return 0;if(g>=1)return 1;for(let M=0;M<r;M++)if(g<=m[M+1]){let F=(g-m[M])/(m[M+1]-m[M]);if(M===0)return F*(2-F);let S=1-Math.pow(t,M);return S+(1-S)*(2*F-1)*(2*F-1)}return 1}}function st({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),u=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return i=>i<=0?0:i>=1?1:r*Math.pow(2,-10*i)*Math.sin((i-u)*(2*Math.PI)/t)+1}var pe={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:ot(),elastic:st()};function de(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 St(e,n,r){return Math.min(r,Math.max(n,e))}function Z(e,n,r,t){return r===n?0:St((e-n)/(r-n)*t,0,1)}function ve(e,n,r,t,u){let i=tt(e.top,e.height,n,t.element)-rt(t.viewport,r),p=tt(e.top,e.height,n,u.element)-rt(u.viewport,r);return {tStart:i,tEnd:p}}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),u=nt(n);return !t||!u?e:`rgb(${Math.round(t[0]+(u[0]-t[0])*r)},${Math.round(t[1]+(u[1]-t[1])*r)},${Math.round(t[2]+(u[2]-t[2])*r)})`}var 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 u(){let i=r==="x"?window.scrollX:window.scrollY,p=e-i,m=n-i,c=r==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
+
<div style="position:absolute;${c?`left:${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(t),window.addEventListener("scroll",u,{passive:true}),u(),t}function Je(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,i=>{let p=parseFloat(i),m=t[u++]??p;return String(+(p+(m-p)*r).toFixed(4))})}function _e(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,u=r?{...Xe[r],...t}:t,i=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:p="path, polyline, line, polygon, rect, circle",speed:m=1,fade:c=false,easing:g="linear",trigger:M={},stagger:F=0,direction:S="forward",once:J=false,debug:Ee=false,axis:H="y",scrollContainer:ee,autoReverse:te=false,delay:re=0,strokeColor:x,strokeWidth:R,fillOpacity:D,waypoints:h,velocityScale:C=false,threshold:W=0,rootMargin:ne="0px",repeat:z=0,repeatDelay:ce=0,morphTo:T,clip:U,autoplay:K=false,duration:oe=1e3,native:_=true,onProgress:d,onStart:A,onComplete:b,onEnter:$,onLeave:ge,onEnterBack:Ae,onLeaveBack:Le}=u,ye=U===true?"left":typeof U=="string"?U:false,he=typeof g=="function"?g:pe[g]??pe.linear,Me=de(M.start??"top bottom"),Fe=de(M.end??"bottom top"),G=typeof ee=="string"?document.querySelector(ee):ee??null,ue=Array.isArray(x)?x[0]:null,V=Array.isArray(x)?x[1]:typeof x=="string"?x:null,B=Array.isArray(R)?R[0]:null,s=Array.isArray(R)?R[1]:typeof R=="number"?R:null,f=Array.isArray(D)?D[0]:null,L=Array.isArray(D)?D[1]:typeof D=="number"?D:null;function j(o){let a=o*100;switch(ye){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 E=ye?[]:Array.from(e.querySelectorAll(p)),I=[],P=[],Q=0,se=0,Y=false,me=false,X=0,He=false,be=-1,Re=-1,ie=false,Ce=0,Se=0,xe,Ge=null,Te=new Set,qe=-1,Ke=performance.now(),Pe=NaN;function Ne(){return G?H==="x"?G.scrollLeft:G.scrollTop:H==="x"?window.scrollX:window.scrollY}function Qe(){return G?H==="x"?G.clientWidth:G.clientHeight:H==="x"?window.innerWidth:window.innerHeight}function et(){let o=e.getBoundingClientRect(),a,w,q;if(G){let le=G.getBoundingClientRect();a=H==="x"?o.left-le.left+G.scrollLeft:o.top-le.top+G.scrollTop,w=H==="x"?o.width:o.height,q=Ne();}else a=H==="x"?o.left:o.top,w=H==="x"?o.width:o.height,q=Ne();let ae=ve({top:a,height:w},q,Qe(),Me,Fe);Q=ae.tStart,se=ae.tEnd,Ee&&process.env.NODE_ENV!=="production"&&(Ge?.remove(),Ge=At(Q,se,H));}function ht(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),ye){let w=a==="reverse"?1-o:o;e.style.clipPath=j(w);return}E.forEach((w,q)=>{w.style.strokeDashoffset=a==="reverse"?`${I[q]*o}`:`${I[q]*(1-o)}`,c&&(w.style.opacity=a==="reverse"?`${1-o}`:`${o}`),ue&&V?w.style.stroke=Oe(ue,V,o):V&&(w.style.stroke=V),B!==null&&s!==null?w.style.strokeWidth=`${B+(s-B)*o}`:s!==null&&(w.style.strokeWidth=`${s}`),f!==null&&L!==null?w.style.fillOpacity=`${f+(L-f)*o}`:L!==null&&(w.style.fillOpacity=`${L}`),T&&w.tagName.toLowerCase()==="path"&&P[q]&&w.setAttribute("d",Je(P[q],T,o));});}function ze(){if(e.style.setProperty("--scroll-draw-progress","0"),ye){e.style.clipPath=j(0);return}E.forEach((o,a)=>{o.style.strokeDasharray=`${I[a]}`,o.style.strokeDashoffset=S==="reverse"?"0":`${I[a]}`,c?o.style.opacity=S==="reverse"?"1":"0":o.style.opacity="",ue&&(o.style.stroke=ue),B!==null&&(o.style.strokeWidth=`${B}`),f!==null&&(o.style.fillOpacity=`${f}`),T&&o.tagName.toLowerCase()==="path"&&P[a]&&o.setAttribute("d",P[a]);});}if(E.forEach(o=>{Tt(o);let a=We(o);I.push(a),o.tagName.toLowerCase()==="path"?P.push(o.getAttribute("d")??""):P.push(""),i?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=S==="reverse"?`${a}`:"0",c&&(o.style.opacity="1"),V&&(o.style.stroke=V),s!==null&&(o.style.strokeWidth=`${s}`),L!==null&&(o.style.fillOpacity=`${L}`),T&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",T)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=S==="reverse"?"0":`${a}`,c?o.style.opacity=S==="reverse"?"1":"0":o.style.opacity="",ue&&(o.style.stroke=ue),B!==null&&(o.style.strokeWidth=`${B}`),f!==null&&(o.style.fillOpacity=`${f}`));}),ye){if(i)return e.style.clipPath=j(1),b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(i)return b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function bt(){return !(_===false||!xt()||!E.length||typeof g!="string"||!(g in at)||ye||H!=="y"||G||m!==1||F!==0||J||te||C!==false||T||h||z||re>0||d||A||b||$||ge||Ae||Le||x!=null||R!=null||D!=null||(M.start??"top bottom").trim()!=="top bottom"||(M.end??"bottom top").trim()!=="bottom top")}function wt(){let o=`svg-scroll-draw-${++Et}`,a=S==="reverse"?"0":"var(--ssd-len)",w=S==="reverse"?"var(--ssd-len)":"0",q=`stroke-dashoffset:${a};`,ae=`stroke-dashoffset:${w};`;c&&(q+=`opacity:${S==="reverse"?1:0};`,ae+=`opacity:${S==="reverse"?0:1};`);let le=document.createElement("style");le.setAttribute("data-svg-scroll-draw",""),le.textContent=`@keyframes ${o}{from{${q}}to{${ae}}}.${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(le);function fe(l,v){l.style.setProperty("--ssd-len",String(I[v])),l.style.strokeDasharray=`${I[v]}`,l.style.strokeDashoffset="",l.style.opacity="",l.style.animationPlayState="",l.classList.add(o);}E.forEach(fe);let y=false,k=-1;function O(){if(k>=0)return k;let l=e.getBoundingClientRect(),{tStart:v,tEnd:N}=ve({top:l.top,height:l.height},Ne(),Qe(),Me,Fe);return he(Z(Ne(),v,N,m))}return {destroy(){E.forEach(l=>{l.classList.remove(o),l.style.removeProperty("--ssd-len"),l.style.animationPlayState="";}),le.remove();},replay(){y=false,k=-1,E.forEach(fe);},pause(){y=true,E.forEach(l=>{l.style.animationPlayState="paused";});},resume(){y&&(y=false,E.forEach(l=>{l.style.animationPlayState="running";}));},seek(l){let v=Math.min(1,Math.max(0,l));k=v,y=true,E.forEach((N,$e)=>{N.classList.remove(o),N.style.strokeDashoffset=S==="reverse"?`${I[$e]*v}`:`${I[$e]*(1-v)}`,c&&(N.style.opacity=S==="reverse"?`${1-v}`:`${v}`);});},getProgress(){return O()}}}if(bt())return wt();function vt(){let o=Math.max(1,oe),a=0,w=0;function q(O){let l=true;if(ye){let v=Math.min(1,Math.max(0,O/o)),N=he(v);Ce=N,e.style.setProperty("--scroll-draw-progress",String(N)),e.style.clipPath=j(S==="reverse"?1-N:N),d?.(N),v<1&&(l=false);}else E.forEach((v,N)=>{let $e=N*F*o,ke=Math.min(1,Math.max(0,(O-$e)/o)),we=he(ke);v.style.strokeDashoffset=S==="reverse"?`${I[N]*we}`:`${I[N]*(1-we)}`,c&&(v.style.opacity=S==="reverse"?`${1-we}`:`${we}`),ue&&V?v.style.stroke=Oe(ue,V,we):V&&(v.style.stroke=V),B!==null&&s!==null?v.style.strokeWidth=`${B+(s-B)*we}`:s!==null&&(v.style.strokeWidth=`${s}`),f!==null&&L!==null?v.style.fillOpacity=`${f+(L-f)*we}`:L!==null&&(v.style.fillOpacity=`${L}`),T&&v.tagName.toLowerCase()==="path"&&P[N]&&v.setAttribute("d",Je(P[N],T,we)),N===0&&(d?.(we),e.style.setProperty("--scroll-draw-progress",String(we))),ke<1&&(l=false);});if(h){let v=Math.min(1,Math.max(0,O/o)),N=he(v);for(let $e in h){let ke=parseFloat($e);N>=ke&&!Te.has(ke)&&(Te.add(ke),h[$e]?.());}}return l}function ae(O){if(ie)return;let l=O-a;me||(me=true,A?.());let v=q(l);if(v&&!Y){Y=true,q(o*(1+Math.max(0,E.length-1)*F)),b?.(),Se<(z==="infinite"?1/0:z??0)&&(Se++,xe=setTimeout(()=>{a=performance.now(),me=false,Y=false,Te.clear(),ze(),X=requestAnimationFrame(ae);},ce));return}v||(X=requestAnimationFrame(ae));}function le(){cancelAnimationFrame(X),clearTimeout(xe),a=performance.now(),w=0,ie=false,me=false,Y=false,Se=0,Te.clear(),ze(),X=requestAnimationFrame(ae);}let fe=new IntersectionObserver(O=>{O.forEach(l=>{l.isIntersecting&&!(J&&Y)?le():!l.isIntersecting&&!J&&!Y&&(cancelAnimationFrame(X),clearTimeout(xe),a=null);});},{root:G??null,threshold:W,rootMargin:ne}),y;function k(){clearTimeout(y),y=setTimeout(()=>{E.forEach((O,l)=>{I[l]=We(O),O.style.strokeDasharray=`${I[l]}`;});},150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),re>0?setTimeout(()=>fe.observe(e),re):fe.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(xe),fe.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(y);},replay(){Se=0,le();},pause(){ie||(ie=true,w=performance.now()-a,cancelAnimationFrame(X));},resume(){ie&&(ie=false,a=performance.now()-w,X=requestAnimationFrame(ae));},seek(O){let l=Math.min(1,Math.max(0,O));Ce=l,ie=true,w=l*o,a=performance.now()-w,cancelAnimationFrame(X),q(w);},getProgress(){return Ce}}}if(K)return vt();et();function Ve(){if(!He||ie)return;let o=performance.now(),a=Ne(),w=m;if(C!==false){let y=o-Ke,k=y>0?Math.abs(a-(qe<0?a:qe))/y:0;w=m*Math.max(.2,1+k*(typeof C=="number"?C:1)*.04);}qe=a,Ke=o;let q=te?Re===-1||a>=Re?"forward":"reverse":S;Re=a;let ae=se-Q,le=true,fe=ae===0?0:(a-Q)/ae;if(isNaN(Pe)||(Pe<=0&&fe>0?$?.():Pe>0&&fe<=0&&Le?.(),Pe<1&&fe>=1?ge?.():Pe>=1&&fe<1&&Ae?.()),Pe=fe,ye){let y=he(Z(a,Q,se,w));J&&!te&&(be=Math.max(be,y),y=be),Ce=y,e.style.setProperty("--scroll-draw-progress",String(y));let k=q==="reverse"?1-y:y;e.style.clipPath=j(k),d?.(y),!me&&Z(a,Q,se,w)>0&&(me=true,A?.()),y>=1&&!Y?(Y=true,b?.(),Se<(z==="infinite"?1/0:z??0)&&(Se++,xe=setTimeout(()=>{be=-1,me=false,Y=false,e.style.clipPath=j(0);},ce))):y<1&&!J&&(Y=false),X=requestAnimationFrame(Ve);return}if(E.forEach((y,k)=>{let O=k*F*ae,l=he(Z(a,Q+O,se+O,w));J&&!te&&(be=Math.max(be,l),l=be),Ce=l,y.style.strokeDashoffset=q==="reverse"?`${I[k]*l}`:`${I[k]*(1-l)}`,c&&(y.style.opacity=q==="reverse"?`${1-l}`:`${l}`),ue&&V?y.style.stroke=Oe(ue,V,l):V&&(y.style.stroke=V),B!==null&&s!==null?y.style.strokeWidth=`${B+(s-B)*l}`:s!==null&&(y.style.strokeWidth=`${s}`),f!==null&&L!==null?y.style.fillOpacity=`${f+(L-f)*l}`:L!==null&&(y.style.fillOpacity=`${L}`),T&&y.tagName.toLowerCase()==="path"&&P[k]&&y.setAttribute("d",Je(P[k],T,l)),k===0&&(d?.(l),e.style.setProperty("--scroll-draw-progress",String(l))),l<1&&(le=false);}),h){let y=he(Z(a,Q,se,w));for(let k in h){let O=parseFloat(k);y>=O&&!Te.has(O)&&(Te.add(O),h[k]?.());}}!me&&Z(a,Q,se,w)>0&&(me=true,A?.()),le&&!Y?(Y=true,b?.(),Se<(z==="infinite"?1/0:z??0)&&(Se++,xe=setTimeout(()=>{be=-1,me=false,Y=false,Te.clear(),ze();},ce))):!le&&!J&&(Y=false),X=requestAnimationFrame(Ve);}let je=new IntersectionObserver(o=>{o.forEach(a=>{He=a.isIntersecting,He&&!ie?X=requestAnimationFrame(Ve):cancelAnimationFrame(X);});},{root:G??null,threshold:W,rootMargin:ne}),Ye;function Be(){clearTimeout(Ye),Ye=setTimeout(()=>{E.forEach((o,a)=>{I[a]=We(o),o.style.strokeDasharray=`${I[a]}`;}),et();},150);}return window.addEventListener("resize",Be),window.addEventListener("orientationchange",Be),re>0?setTimeout(()=>je.observe(e),re):je.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(xe),je.disconnect(),window.removeEventListener("resize",Be),window.removeEventListener("orientationchange",Be),clearTimeout(Ye),Ge?.remove();},replay(){be=-1,Re=-1,qe=-1,me=false,Y=false,Se=0,ie=false,Te.clear(),clearTimeout(xe),ze();},pause(){ie=true,cancelAnimationFrame(X);},resume(){ie&&(ie=false,He&&(X=requestAnimationFrame(Ve)));},seek(o){let a=Math.min(1,Math.max(0,o));Ce=a,be=a,ie=true,cancelAnimationFrame(X),ht(a,S);},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 u=[],i=[],p=t[2].trim();if(p)for(let m of p.split(/[\s,]+/)){let c=m.match(/^([-+]?[\d.eE]+)(.*)$/);u.push(c?parseFloat(c[1]):0),i.push(c?c[2]:"");}n.push({fn:t[1],nums:u,units:i});}return n}function Ct(e,n,r){let t=ct(e),u=ct(n);return t.length===0||t.length!==u.length?r<1?e:n:t.map((i,p)=>{let m=u[p];return i.fn!==m.fn||i.nums.length!==m.nums.length?r<1?`${i.fn}(${i.nums.map((c,g)=>`${c}${i.units[g]}`).join(", ")})`:`${m.fn}(${m.nums.map((c,g)=>`${c}${m.units[g]}`).join(", ")})`:`${i.fn}(${i.nums.map((c,g)=>`${c+(m.nums[g]-c)*r}${i.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),u=String(n);if(Mt(t))return Oe(t,u,r);if(t.includes("("))return Ct(t,u,r);let i=t.match(/^([-+]?[\d.]+)(.*)$/),p=u.match(/^([-+]?[\d.]+)(.*)$/);if(i&&p){let m=parseFloat(i[1]),c=parseFloat(p[1]);return `${m+(c-m)*r}${i[2]||p[2]}`}return r<1?t:u}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:u={},easing:i="ease-out",speed:p=1,once:m=false,axis:c="y",scrollContainer:g,native:M=true,velocityScale:F=false,onProgress:S,onComplete:J,onEnter:Ee,onLeave:H,onEnterBack:ee,onLeaveBack:te}=n,re=window.matchMedia("(prefers-reduced-motion: reduce)").matches,x=typeof i=="function"?i:pe[i]??pe["ease-out"],R=de(u.start??"top bottom"),D=de(u.end??"bottom top"),h=typeof g=="string"?document.querySelector(g):g??null,C=Object.entries(t).map(([s,f])=>({prop:$t(s),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function W(){let s=window.getComputedStyle(e);for(let f of C)f.from===""&&(f.from=s.getPropertyValue(f.prop).trim()||"0");}function ne(){for(let s of C)e.style.setProperty(s.prop,String(s.to));}if(re)return ne(),J?.(),r;W();function z(){if(!M||!kt()||typeof i!="string"||!(i in mt)||c!=="y"||h||m||p!==1||S||J||Ee||H||ee||te||F!==false||(u.start??"top bottom").trim()!=="top bottom"||(u.end??"bottom top").trim()!=="bottom top")return false;for(let s of C)if(!Lt.has(s.prop))return false;return true}function ce(){let s=`ssd-a-${++Pt}`,f=C.map(P=>`${P.prop}:${P.from}`).join(";"),L=C.map(P=>`${P.prop}:${P.to}`).join(";"),j=document.createElement("style");j.setAttribute("data-ssd-animate",""),j.textContent=`@keyframes ${s}{from{${f}}to{${L}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${mt[i]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(j),e.classList.add(s);let E=()=>c==="x"?window.scrollX:window.scrollY,I=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(s),j.remove();},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(P){let Q=Math.min(1,Math.max(0,P));e.classList.remove(s);for(let se of C)e.style.setProperty(se.prop,ut(se.from,se.to,Q));},getProgress(){let P=e.getBoundingClientRect(),Q=E(),se=I(),{tStart:Y,tEnd:me}=ve({top:P.top,height:P.height},Q,se,R,D);return x(Z(Q,Y,me,p))}}}if(z())return ce();let T=0,U=0,K=0,oe=false,_=false,d=-1,A=0,b=false,$=NaN,ge=-1,Ae=0,Le=()=>h?c==="x"?h.scrollLeft:h.scrollTop:c==="x"?window.scrollX:window.scrollY,ye=()=>h?c==="x"?h.clientWidth:h.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function he(){let s=e.getBoundingClientRect(),f,L;if(h){let E=h.getBoundingClientRect();f=c==="x"?s.left-E.left+h.scrollLeft:s.top-E.top+h.scrollTop,L=c==="x"?s.width:s.height;}else f=c==="x"?s.left:s.top,L=c==="x"?s.width:s.height;let j=ve({top:f,height:L},Le(),ye(),R,D);T=j.tStart,U=j.tEnd;}function Me(s){e.style.setProperty("--scroll-draw-progress",String(s));for(let f of C)e.style.setProperty(f.prop,ut(f.from,f.to,s));S?.(s);}function Fe(s){if(isNaN($)){$=s;return}$<=0&&s>0?Ee?.():$>0&&s<=0&&te?.(),$<1&&s>=1?H?.():$>=1&&s<1&&ee?.(),$=s;}function G(){if(!oe||_)return;let s=performance.now(),f=Le(),L=p;if(F!==false){let I=s-Ae,P=I>0?Math.abs(f-(ge<0?f:ge))/I:0;L=p*Math.max(.2,1+P*(typeof F=="number"?F:1)*.04);}ge=f,Ae=s;let j=U===T?0:(f-T)/(U-T);Fe(j);let E=x(Z(f,T,U,L));m&&(d=Math.max(d,E),E=d),A=E,Me(E),E>=1&&!b?(b=true,J?.()):E<1&&!m&&(b=false),K=requestAnimationFrame(G);}he();{let s=x(Z(Le(),T,U,p));m&&s>0&&(d=s),A=s,Me(s);}let ue=new IntersectionObserver(s=>{s.forEach(f=>{oe=f.isIntersecting,oe&&!_?K=requestAnimationFrame(G):cancelAnimationFrame(K);});},{root:h??null}),V;function B(){clearTimeout(V),V=setTimeout(he,150);}return window.addEventListener("resize",B),window.addEventListener("orientationchange",B),ue.observe(e),De(e,{type:"animate",getProgress:()=>A,getTrigger:()=>({tStart:T,tEnd:U})}),{destroy(){cancelAnimationFrame(K),ue.disconnect(),window.removeEventListener("resize",B),window.removeEventListener("orientationchange",B),clearTimeout(V),Ie(e);},replay(){d=-1,b=false,A=0,_=false,Me(0);},pause(){_=true,cancelAnimationFrame(K);},resume(){_&&(_=false,oe&&(K=requestAnimationFrame(G)));},seek(s){let f=Math.min(1,Math.max(0,s));A=f,d=f,_=true,cancelAnimationFrame(K),Me(f);},getProgress(){return A}}}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:u=0,to:i,format:p,easing:m="ease-out",trigger:c={},once:g=true,decimals:M,onComplete:F}=n,S=M!==void 0?d=>d.toFixed(M):p??(d=>String(Math.round(d))),J=typeof m=="function"?m:pe[m]??pe["ease-out"],Ee=de(c.start??"top 80%"),H=de(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=S(i),F?.(),Ue;t.textContent=S(u);let te=0,re=0,x=0,R=false,D=false,h=-1,C=0,W=false,ne=()=>window.scrollY,z=()=>window.innerHeight;function ce(){let d=t.getBoundingClientRect(),A=ve({top:d.top,height:d.height},ne(),z(),Ee,H);te=A.tStart,re=A.tEnd;}function T(d){t.textContent=S(u+(i-u)*d),t.style.setProperty("--scroll-draw-progress",String(d));}function U(){if(!R||D)return;let d=J(Z(ne(),te,re,1));g&&(h=Math.max(h,d),d=h),C=d,T(d),d>=1&&!W?(W=true,F?.()):d<1&&!g&&(W=false),x=requestAnimationFrame(U);}ce();{let d=J(Z(ne(),te,re,1));g&&d>0&&(h=d),C=d,T(d);}let K=new IntersectionObserver(d=>{d.forEach(A=>{R=A.isIntersecting,R&&!D?x=requestAnimationFrame(U):cancelAnimationFrame(x);});}),oe;function _(){clearTimeout(oe),oe=setTimeout(ce,150);}return window.addEventListener("resize",_),window.addEventListener("orientationchange",_),K.observe(t),De(t,{type:"counter",getProgress:()=>C,getTrigger:()=>({tStart:te,tEnd:re})}),{destroy(){cancelAnimationFrame(x),K.disconnect(),window.removeEventListener("resize",_),window.removeEventListener("orientationchange",_),clearTimeout(oe),Ie(t);},replay(){h=-1,W=false,C=0,D=false,T(0);},pause(){D=true,cancelAnimationFrame(x);},resume(){D&&(D=false,R&&(x=requestAnimationFrame(U)));},seek(d){let A=Math.min(1,Math.max(0,d));C=A,h=A,D=true,cancelAnimationFrame(x),T(A);},getProgress(){return C}}}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 i of n){let p=i.offsetTop;r.has(p)||r.set(p,[]),r.get(p).push(i);}let t=[],u=Array.from(r.keys()).sort((i,p)=>i-p);for(let i of u){let p=r.get(i),m=document.createElement("span");m.setAttribute("aria-hidden","true"),m.style.display="inline-block";for(let c of p)m.appendChild(c);t.push(m);}e.textContent="";for(let i of t)e.appendChild(i),e.appendChild(document.createTextNode(" "));return t}function Dt(e,n,r,t){if(r<=1||t===0)return e;let u=(r-1)*t,i=n*t,p=i+(1-u);return p<=i?e>=i?1:0:Math.min(1,Math.max(0,(e-i)/(p-i)))}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:u="words",stagger:i=.04,easing:p="ease-out",from:m={opacity:0,y:24},trigger:c={},once:g=true,onComplete:M}=n,F=window.matchMedia("(prefers-reduced-motion: reduce)").matches,S=typeof p=="function"?p:pe[p]??pe["ease-out"],J=de(c.start??"top 85%"),Ee=de(c.end??"top 40%"),H=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let ee;u==="chars"?ee=Ot(t):u==="lines"?ee=ft(t):ee=gt(t);let te=ee.length;function re(b,$){m?.opacity!==void 0&&(b.style.opacity=String(m.opacity+(1-m.opacity)*$));let ge=It($,m);ge&&(b.style.transform=ge);}function x(b){t.style.setProperty("--scroll-draw-progress",String(b)),ee.forEach(($,ge)=>{let Ae=S(Dt(b,ge,te,i));re($,Ae);});}if(F)return x(1),M?.(),{destroy(){t.innerHTML=H,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};x(0);let R=0,D=0,h=0,C=false,W=false,ne=-1,z=0,ce=false,T=()=>window.scrollY,U=()=>window.innerHeight;function K(){let b=t.getBoundingClientRect(),$=ve({top:b.top,height:b.height},T(),U(),J,Ee);R=$.tStart,D=$.tEnd;}function oe(){if(!C||W)return;let b=Z(T(),R,D,1);g&&(ne=Math.max(ne,b),b=ne),z=b,x(b),b>=1&&!ce?(ce=true,M?.()):b<1&&!g&&(ce=false),h=requestAnimationFrame(oe);}K();let _=new IntersectionObserver(b=>{b.forEach($=>{C=$.isIntersecting,C&&!W?h=requestAnimationFrame(oe):cancelAnimationFrame(h);});}),d;function A(){clearTimeout(d),d=setTimeout(()=>{if(u==="lines"){let b=z;t.innerHTML=H,t.setAttribute("aria-label",t.textContent??""),ee=ft(t),x(b);}K();},150);}return window.addEventListener("resize",A),window.addEventListener("orientationchange",A),_.observe(t),De(t,{type:"text",getProgress:()=>z,getTrigger:()=>({tStart:R,tEnd:D})}),{destroy(){cancelAnimationFrame(h),_.disconnect(),window.removeEventListener("resize",A),window.removeEventListener("orientationchange",A),clearTimeout(d),t.innerHTML=H,t.removeAttribute("aria-label"),Ie(t);},replay(){ne=-1,ce=false,z=0,W=false,x(0);},pause(){W=true,cancelAnimationFrame(h);},resume(){W&&(W=false,C&&(h=requestAnimationFrame(oe)));},seek(b){let $=Math.min(1,Math.max(0,b));z=$,ne=$,W=true,cancelAnimationFrame(h),x($);},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 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,
|
|
2
|
-
<div style="position:absolute;${c?`left:${
|
|
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);})();
|
|
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,d=[];for(let p=0;p<t;p++){let x=Math.pow(a,p);d.push(x),i+=x}let m=[0],c=0;for(let p=0;p<t;p++)c+=d[p]/i,m.push(c);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let x=0;x<t;x++)if(p<=m[x+1]){let F=(p-m[x])/(m[x+1]-m[x]);if(x===0)return F*(2-F);let E=1-Math.pow(n,x);return E+(1-E)*(2*F-1)*(2*F-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 te={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 be(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 re(e,r,t,n){return t===r?0:Dt((e-r)/(t-r)*n,0,1)}function xe(e,r,t,n,a){let i=lt(e.top,e.height,r,n.element)-ct(n.viewport,t),d=lt(e.top,e.height,r,a.element)-ct(a.viewport,t);return{tStart:i,tEnd:d}}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 Le(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,d=e-i,m=r-i,c=t==="x";n.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`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;${c?`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",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 d=parseFloat(i),m=n[a++]??d;return String(+(d+(m-d)*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:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:c=!1,easing:p="linear",trigger:x={},stagger:F=0,direction:E="forward",once:W=!1,debug:ge=!1,axis:S="y",scrollContainer:M,autoReverse:g=!1,delay:A=0,strokeColor:b,strokeWidth:R,fillOpacity:z,waypoints:T,velocityScale:H=!1,threshold:ye=0,rootMargin:we="0px",repeat:ae=0,repeatDelay:ve=0,morphTo:k,clip:U,autoplay:se=!1,duration:ce=1e3,native:Z=!0,onProgress:y,onStart:N,onComplete:le,onEnter:ue,onLeave:Me,onEnterBack:Ie,onLeaveBack:ke}=a,me=U===!0?"left":typeof U=="string"?U:!1,fe=typeof p=="function"?p:te[p]??te.linear,Ae=be(x.start??"top bottom"),Oe=be(x.end??"bottom top"),_=typeof M=="string"?document.querySelector(M):M??null,ne=Array.isArray(b)?b[0]:null,V=Array.isArray(b)?b[1]:typeof b=="string"?b:null,B=Array.isArray(R)?R[0]:null,s=Array.isArray(R)?R[1]:typeof R=="number"?R:null,f=Array.isArray(z)?z[0]:null,P=Array.isArray(z)?z[1]:typeof z=="number"?z:null;function G(o){let l=o*100;switch(me){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 $=me?[]:Array.from(e.querySelectorAll(d)),D=[],C=[],Y=0,J=0,j=!1,oe=!1,X=0,Fe=!1,pe=-1,Ne=-1,K=!1,Te=0,he=0,Ee,Ue=null,Se=new Set,Re=-1,st=performance.now(),Pe=NaN;function De(){return _?S==="x"?_.scrollLeft:_.scrollTop:S==="x"?window.scrollX:window.scrollY}function it(){return _?S==="x"?_.clientWidth:_.clientHeight:S==="x"?window.innerWidth:window.innerHeight}function at(){let o=e.getBoundingClientRect(),l,w,q;if(_){let ee=_.getBoundingClientRect();l=S==="x"?o.left-ee.left+_.scrollLeft:o.top-ee.top+_.scrollTop,w=S==="x"?o.width:o.height,q=De()}else l=S==="x"?o.left:o.top,w=S==="x"?o.width:o.height,q=De();let Q=xe({top:l,height:w},q,it(),Ae,Oe);Y=Q.tStart,J=Q.tEnd,ge&&process.env.NODE_ENV!=="production"&&(Ue?.remove(),Ue=Rt(Y,J,S))}function xt(o,l){if(e.style.setProperty("--scroll-draw-progress",String(o)),me){let w=l==="reverse"?1-o:o;e.style.clipPath=G(w);return}$.forEach((w,q)=>{w.style.strokeDashoffset=l==="reverse"?`${D[q]*o}`:`${D[q]*(1-o)}`,c&&(w.style.opacity=l==="reverse"?`${1-o}`:`${o}`),ne&&V?w.style.stroke=Le(ne,V,o):V&&(w.style.stroke=V),B!==null&&s!==null?w.style.strokeWidth=`${B+(s-B)*o}`:s!==null&&(w.style.strokeWidth=`${s}`),f!==null&&P!==null?w.style.fillOpacity=`${f+(P-f)*o}`:P!==null&&(w.style.fillOpacity=`${P}`),k&&w.tagName.toLowerCase()==="path"&&C[q]&&w.setAttribute("d",tt(C[q],k,o))})}function He(){if(e.style.setProperty("--scroll-draw-progress","0"),me){e.style.clipPath=G(0);return}$.forEach((o,l)=>{o.style.strokeDasharray=`${D[l]}`,o.style.strokeDashoffset=E==="reverse"?"0":`${D[l]}`,c?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",ne&&(o.style.stroke=ne),B!==null&&(o.style.strokeWidth=`${B}`),f!==null&&(o.style.fillOpacity=`${f}`),k&&o.tagName.toLowerCase()==="path"&&C[l]&&o.setAttribute("d",C[l])})}if($.forEach(o=>{Nt(o);let l=Ve(o);D.push(l),o.tagName.toLowerCase()==="path"?C.push(o.getAttribute("d")??""):C.push(""),i?(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=E==="reverse"?`${l}`:"0",c&&(o.style.opacity="1"),V&&(o.style.stroke=V),s!==null&&(o.style.strokeWidth=`${s}`),P!==null&&(o.style.fillOpacity=`${P}`),k&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",k)):(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=E==="reverse"?"0":`${l}`,c?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",ne&&(o.style.stroke=ne),B!==null&&(o.style.strokeWidth=`${B}`),f!==null&&(o.style.fillOpacity=`${f}`))}),me){if(i)return e.style.clipPath=G(1),le?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=G(0)}else if(i)return le?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function At(){return!(Z===!1||!Ft()||!$.length||typeof p!="string"||!(p in pt)||me||S!=="y"||_||m!==1||F!==0||W||g||H!==!1||k||T||ae||A>0||y||N||le||ue||Me||Ie||ke||b!=null||R!=null||z!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function Tt(){let o=`svg-scroll-draw-${++Ot}`,l=E==="reverse"?"0":"var(--ssd-len)",w=E==="reverse"?"var(--ssd-len)":"0",q=`stroke-dashoffset:${l};`,Q=`stroke-dashoffset:${w};`;c&&(q+=`opacity:${E==="reverse"?1:0};`,Q+=`opacity:${E==="reverse"?0:1};`);let ee=document.createElement("style");ee.setAttribute("data-svg-scroll-draw",""),ee.textContent=`@keyframes ${o}{from{${q}}to{${Q}}}.${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(ee);function ie(u,v){u.style.setProperty("--ssd-len",String(D[v])),u.style.strokeDasharray=`${D[v]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(o)}$.forEach(ie);let h=!1,L=-1;function I(){if(L>=0)return L;let u=e.getBoundingClientRect(),{tStart:v,tEnd:O}=xe({top:u.top,height:u.height},De(),it(),Ae,Oe);return fe(re(De(),v,O,m))}return{destroy(){$.forEach(u=>{u.classList.remove(o),u.style.removeProperty("--ssd-len"),u.style.animationPlayState=""}),ee.remove()},replay(){h=!1,L=-1,$.forEach(ie)},pause(){h=!0,$.forEach(u=>{u.style.animationPlayState="paused"})},resume(){h&&(h=!1,$.forEach(u=>{u.style.animationPlayState="running"}))},seek(u){let v=Math.min(1,Math.max(0,u));L=v,h=!0,$.forEach((O,$e)=>{O.classList.remove(o),O.style.strokeDashoffset=E==="reverse"?`${D[$e]*v}`:`${D[$e]*(1-v)}`,c&&(O.style.opacity=E==="reverse"?`${1-v}`:`${v}`)})},getProgress(){return I()}}}if(At())return Tt();function $t(){let o=Math.max(1,ce),l=0,w=0;function q(I){let u=!0;if(me){let v=Math.min(1,Math.max(0,I/o)),O=fe(v);Te=O,e.style.setProperty("--scroll-draw-progress",String(O)),e.style.clipPath=G(E==="reverse"?1-O:O),y?.(O),v<1&&(u=!1)}else $.forEach((v,O)=>{let $e=O*F*o,Ce=Math.min(1,Math.max(0,(I-$e)/o)),de=fe(Ce);v.style.strokeDashoffset=E==="reverse"?`${D[O]*de}`:`${D[O]*(1-de)}`,c&&(v.style.opacity=E==="reverse"?`${1-de}`:`${de}`),ne&&V?v.style.stroke=Le(ne,V,de):V&&(v.style.stroke=V),B!==null&&s!==null?v.style.strokeWidth=`${B+(s-B)*de}`:s!==null&&(v.style.strokeWidth=`${s}`),f!==null&&P!==null?v.style.fillOpacity=`${f+(P-f)*de}`:P!==null&&(v.style.fillOpacity=`${P}`),k&&v.tagName.toLowerCase()==="path"&&C[O]&&v.setAttribute("d",tt(C[O],k,de)),O===0&&(y?.(de),e.style.setProperty("--scroll-draw-progress",String(de))),Ce<1&&(u=!1)});if(T){let v=Math.min(1,Math.max(0,I/o)),O=fe(v);for(let $e in T){let Ce=parseFloat($e);O>=Ce&&!Se.has(Ce)&&(Se.add(Ce),T[$e]?.())}}return u}function Q(I){if(K)return;let u=I-l;oe||(oe=!0,N?.());let v=q(u);if(v&&!j){j=!0,q(o*(1+Math.max(0,$.length-1)*F)),le?.(),he<(ae==="infinite"?1/0:ae??0)&&(he++,Ee=setTimeout(()=>{l=performance.now(),oe=!1,j=!1,Se.clear(),He(),X=requestAnimationFrame(Q)},ve));return}v||(X=requestAnimationFrame(Q))}function ee(){cancelAnimationFrame(X),clearTimeout(Ee),l=performance.now(),w=0,K=!1,oe=!1,j=!1,he=0,Se.clear(),He(),X=requestAnimationFrame(Q)}let ie=new IntersectionObserver(I=>{I.forEach(u=>{u.isIntersecting&&!(W&&j)?ee():!u.isIntersecting&&!W&&!j&&(cancelAnimationFrame(X),clearTimeout(Ee),l=null)})},{root:_??null,threshold:ye,rootMargin:we}),h;function L(){clearTimeout(h),h=setTimeout(()=>{$.forEach((I,u)=>{D[u]=Ve(I),I.style.strokeDasharray=`${D[u]}`})},150)}return window.addEventListener("resize",L),window.addEventListener("orientationchange",L),A>0?setTimeout(()=>ie.observe(e),A):ie.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(Ee),ie.disconnect(),window.removeEventListener("resize",L),window.removeEventListener("orientationchange",L),clearTimeout(h)},replay(){he=0,ee()},pause(){K||(K=!0,w=performance.now()-l,cancelAnimationFrame(X))},resume(){K&&(K=!1,l=performance.now()-w,X=requestAnimationFrame(Q))},seek(I){let u=Math.min(1,Math.max(0,I));Te=u,K=!0,w=u*o,l=performance.now()-w,cancelAnimationFrame(X),q(w)},getProgress(){return Te}}}if(se)return $t();at();function qe(){if(!Fe||K)return;let o=performance.now(),l=De(),w=m;if(H!==!1){let h=o-st,L=h>0?Math.abs(l-(Re<0?l:Re))/h:0;w=m*Math.max(.2,1+L*(typeof H=="number"?H:1)*.04)}Re=l,st=o;let q=g?Ne===-1||l>=Ne?"forward":"reverse":E;Ne=l;let Q=J-Y,ee=!0,ie=Q===0?0:(l-Y)/Q;if(isNaN(Pe)||(Pe<=0&&ie>0?ue?.():Pe>0&&ie<=0&&ke?.(),Pe<1&&ie>=1?Me?.():Pe>=1&&ie<1&&Ie?.()),Pe=ie,me){let h=fe(re(l,Y,J,w));W&&!g&&(pe=Math.max(pe,h),h=pe),Te=h,e.style.setProperty("--scroll-draw-progress",String(h));let L=q==="reverse"?1-h:h;e.style.clipPath=G(L),y?.(h),!oe&&re(l,Y,J,w)>0&&(oe=!0,N?.()),h>=1&&!j?(j=!0,le?.(),he<(ae==="infinite"?1/0:ae??0)&&(he++,Ee=setTimeout(()=>{pe=-1,oe=!1,j=!1,e.style.clipPath=G(0)},ve))):h<1&&!W&&(j=!1),X=requestAnimationFrame(qe);return}if($.forEach((h,L)=>{let I=L*F*Q,u=fe(re(l,Y+I,J+I,w));W&&!g&&(pe=Math.max(pe,u),u=pe),Te=u,h.style.strokeDashoffset=q==="reverse"?`${D[L]*u}`:`${D[L]*(1-u)}`,c&&(h.style.opacity=q==="reverse"?`${1-u}`:`${u}`),ne&&V?h.style.stroke=Le(ne,V,u):V&&(h.style.stroke=V),B!==null&&s!==null?h.style.strokeWidth=`${B+(s-B)*u}`:s!==null&&(h.style.strokeWidth=`${s}`),f!==null&&P!==null?h.style.fillOpacity=`${f+(P-f)*u}`:P!==null&&(h.style.fillOpacity=`${P}`),k&&h.tagName.toLowerCase()==="path"&&C[L]&&h.setAttribute("d",tt(C[L],k,u)),L===0&&(y?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(ee=!1)}),T){let h=fe(re(l,Y,J,w));for(let L in T){let I=parseFloat(L);h>=I&&!Se.has(I)&&(Se.add(I),T[L]?.())}}!oe&&re(l,Y,J,w)>0&&(oe=!0,N?.()),ee&&!j?(j=!0,le?.(),he<(ae==="infinite"?1/0:ae??0)&&(he++,Ee=setTimeout(()=>{pe=-1,oe=!1,j=!1,Se.clear(),He()},ve))):!ee&&!W&&(j=!1),X=requestAnimationFrame(qe)}let Ze=new IntersectionObserver(o=>{o.forEach(l=>{Fe=l.isIntersecting,Fe&&!K?X=requestAnimationFrame(qe):cancelAnimationFrame(X)})},{root:_??null,threshold:ye,rootMargin:we}),Je;function ze(){clearTimeout(Je),Je=setTimeout(()=>{$.forEach((o,l)=>{D[l]=Ve(o),o.style.strokeDasharray=`${D[l]}`}),at()},150)}return window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze),A>0?setTimeout(()=>Ze.observe(e),A):Ze.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(Ee),Ze.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Je),Ue?.remove()},replay(){pe=-1,Ne=-1,Re=-1,oe=!1,j=!1,he=0,K=!1,Se.clear(),clearTimeout(Ee),He()},pause(){K=!0,cancelAnimationFrame(X)},resume(){K&&(K=!1,Fe&&(X=requestAnimationFrame(qe)))},seek(o){let l=Math.min(1,Math.max(0,o));Te=l,pe=l,K=!0,cancelAnimationFrame(X),xt(l,E)},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=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let c=m.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,d)=>{let m=a[d];return i.fn!==m.fn||i.nums.length!==m.nums.length?t<1?`${i.fn}(${i.nums.map((c,p)=>`${c}${i.units[p]}`).join(", ")})`:`${m.fn}(${m.nums.map((c,p)=>`${c}${m.units[p]}`).join(", ")})`:`${i.fn}(${i.nums.map((c,p)=>`${c+(m.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 Le(n,a,t);if(n.includes("("))return qt(n,a,t);let i=n.match(/^([-+]?[\d.]+)(.*)$/),d=a.match(/^([-+]?[\d.]+)(.*)$/);if(i&&d){let m=parseFloat(i[1]),c=parseFloat(d[1]);return`${m+(c-m)*t}${i[2]||d[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:d=1,once:m=!1,axis:c="y",scrollContainer:p,native:x=!0,velocityScale:F=!1,onProgress:E,onComplete:W,onEnter:ge,onLeave:S,onEnterBack:M,onLeaveBack:g}=r,A=window.matchMedia("(prefers-reduced-motion: reduce)").matches,b=typeof i=="function"?i:te[i]??te["ease-out"],R=be(a.start??"top bottom"),z=be(a.end??"bottom top"),T=typeof p=="string"?document.querySelector(p):p??null,H=Object.entries(n).map(([s,f])=>({prop:zt(s),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function ye(){let s=window.getComputedStyle(e);for(let f of H)f.from===""&&(f.from=s.getPropertyValue(f.prop).trim()||"0")}function we(){for(let s of H)e.style.setProperty(s.prop,String(s.to))}if(A)return we(),W?.(),t;ye();function ae(){if(!x||!Wt()||typeof i!="string"||!(i in ht)||c!=="y"||T||m||d!==1||E||W||ge||S||M||g||F!==!1||(a.start??"top bottom").trim()!=="top bottom"||(a.end??"bottom top").trim()!=="bottom top")return!1;for(let s of H)if(!Vt.has(s.prop))return!1;return!0}function ve(){let s=`ssd-a-${++Bt}`,f=H.map(C=>`${C.prop}:${C.from}`).join(";"),P=H.map(C=>`${C.prop}:${C.to}`).join(";"),G=document.createElement("style");G.setAttribute("data-ssd-animate",""),G.textContent=`@keyframes ${s}{from{${f}}to{${P}}}.${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(G),e.classList.add(s);let $=()=>c==="x"?window.scrollX:window.scrollY,D=()=>c==="x"?window.innerWidth:window.innerHeight;return{destroy(){e.classList.remove(s),G.remove()},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(C){let Y=Math.min(1,Math.max(0,C));e.classList.remove(s);for(let J of H)e.style.setProperty(J.prop,yt(J.from,J.to,Y))},getProgress(){let C=e.getBoundingClientRect(),Y=$(),J=D(),{tStart:j,tEnd:oe}=xe({top:C.top,height:C.height},Y,J,R,z);return b(re(Y,j,oe,d))}}}if(ae())return ve();let k=0,U=0,se=0,ce=!1,Z=!1,y=-1,N=0,le=!1,ue=NaN,Me=-1,Ie=0,ke=()=>T?c==="x"?T.scrollLeft:T.scrollTop:c==="x"?window.scrollX:window.scrollY,me=()=>T?c==="x"?T.clientWidth:T.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function fe(){let s=e.getBoundingClientRect(),f,P;if(T){let $=T.getBoundingClientRect();f=c==="x"?s.left-$.left+T.scrollLeft:s.top-$.top+T.scrollTop,P=c==="x"?s.width:s.height}else f=c==="x"?s.left:s.top,P=c==="x"?s.width:s.height;let G=xe({top:f,height:P},ke(),me(),R,z);k=G.tStart,U=G.tEnd}function Ae(s){e.style.setProperty("--scroll-draw-progress",String(s));for(let f of H)e.style.setProperty(f.prop,yt(f.from,f.to,s));E?.(s)}function Oe(s){if(isNaN(ue)){ue=s;return}ue<=0&&s>0?ge?.():ue>0&&s<=0&&g?.(),ue<1&&s>=1?S?.():ue>=1&&s<1&&M?.(),ue=s}function _(){if(!ce||Z)return;let s=performance.now(),f=ke(),P=d;if(F!==!1){let D=s-Ie,C=D>0?Math.abs(f-(Me<0?f:Me))/D:0;P=d*Math.max(.2,1+C*(typeof F=="number"?F:1)*.04)}Me=f,Ie=s;let G=U===k?0:(f-k)/(U-k);Oe(G);let $=b(re(f,k,U,P));m&&(y=Math.max(y,$),$=y),N=$,Ae($),$>=1&&!le?(le=!0,W?.()):$<1&&!m&&(le=!1),se=requestAnimationFrame(_)}fe();{let s=b(re(ke(),k,U,d));m&&s>0&&(y=s),N=s,Ae(s)}let ne=new IntersectionObserver(s=>{s.forEach(f=>{ce=f.isIntersecting,ce&&!Z?se=requestAnimationFrame(_):cancelAnimationFrame(se)})},{root:T??null}),V;function B(){clearTimeout(V),V=setTimeout(fe,150)}return window.addEventListener("resize",B),window.addEventListener("orientationchange",B),ne.observe(e),_e(e,{type:"animate",getProgress:()=>N,getTrigger:()=>({tStart:k,tEnd:U})}),{destroy(){cancelAnimationFrame(se),ne.disconnect(),window.removeEventListener("resize",B),window.removeEventListener("orientationchange",B),clearTimeout(V),Ge(e)},replay(){y=-1,le=!1,N=0,Z=!1,Ae(0)},pause(){Z=!0,cancelAnimationFrame(se)},resume(){Z&&(Z=!1,ce&&(se=requestAnimationFrame(_)))},seek(s){let f=Math.min(1,Math.max(0,s));N=f,y=f,Z=!0,cancelAnimationFrame(se),Ae(f)},getProgress(){return N}}}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:d,onProgress:m}=r,c=t.getBoundingClientRect(),p=a==="x"?c.width:c.height,x=n*p;return bt(t,{props:a==="x"?{transform:["translateX(0px)",`translateX(${-x}px)`]}:{transform:["translateY(0px)",`translateY(${-x}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:i,native:!1,onProgress:m})}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:d,easing:m="ease-out",trigger:c={},once:p=!0,decimals:x,onComplete:F}=r,E=x!==void 0?y=>y.toFixed(x):d??(y=>String(Math.round(y))),W=typeof m=="function"?m:te[m]??te["ease-out"],ge=be(c.start??"top 80%"),S=be(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=E(i),F?.(),rt;n.textContent=E(a);let g=0,A=0,b=0,R=!1,z=!1,T=-1,H=0,ye=!1,we=()=>window.scrollY,ae=()=>window.innerHeight;function ve(){let y=n.getBoundingClientRect(),N=xe({top:y.top,height:y.height},we(),ae(),ge,S);g=N.tStart,A=N.tEnd}function k(y){n.textContent=E(a+(i-a)*y),n.style.setProperty("--scroll-draw-progress",String(y))}function U(){if(!R||z)return;let y=W(re(we(),g,A,1));p&&(T=Math.max(T,y),y=T),H=y,k(y),y>=1&&!ye?(ye=!0,F?.()):y<1&&!p&&(ye=!1),b=requestAnimationFrame(U)}ve();{let y=W(re(we(),g,A,1));p&&y>0&&(T=y),H=y,k(y)}let se=new IntersectionObserver(y=>{y.forEach(N=>{R=N.isIntersecting,R&&!z?b=requestAnimationFrame(U):cancelAnimationFrame(b)})}),ce;function Z(){clearTimeout(ce),ce=setTimeout(ve,150)}return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),se.observe(n),_e(n,{type:"counter",getProgress:()=>H,getTrigger:()=>({tStart:g,tEnd:A})}),{destroy(){cancelAnimationFrame(b),se.disconnect(),window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z),clearTimeout(ce),Ge(n)},replay(){T=-1,ye=!1,H=0,z=!1,k(0)},pause(){z=!0,cancelAnimationFrame(b)},resume(){z&&(z=!1,R&&(b=requestAnimationFrame(U)))},seek(y){let N=Math.min(1,Math.max(0,y));H=N,T=N,z=!0,cancelAnimationFrame(b),k(N)},getProgress(){return H}}}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 te[e]??te.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 S of r.scenes){if(S.background){let g=document.createElement("img");g.id=_t,g.src=S.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g)}let M=S.animations.filter(g=>g.type==="draw");if(M.length){let g=document.createElementNS(St,"svg");g.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let A of M){let b=document.createElementNS(St,"path");b.id=A.target.replace(/^#/,""),b.setAttribute("d",A.d),b.setAttribute("fill","none"),b.setAttribute("stroke",A.stroke),b.setAttribute("stroke-width",String(A.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let R=A.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(R),b.style.strokeDashoffset=String(R),g.appendChild(b),a.push({kind:"draw",el:b,start:Xe(A.start),end:Xe(A.end),ease:Gt(A.easing),length:R})}}for(let g of S.animations){if(g.type!=="fade")continue;let A=n.querySelector(g.target)??document.querySelector(g.target);A&&(A.style.opacity=String(g.from),a.push({kind:"fade",el:A,start:Xe(g.start),end:Xe(g.end),ease:te["ease-in-out"]??te.linear,from:g.from,to:g.to}))}}let i=0,d=()=>{let S=t.offsetHeight-window.innerHeight;return S<=0?t.getBoundingClientRect().top<=0?1:0:nt(-t.getBoundingClientRect().top/S)},m=S=>{for(let M of a){let g=M.end-M.start,A=g<=0?S>=M.end?1:0:nt((S-M.start)/g),b=M.ease(A);M.kind==="draw"?M.el.style.strokeDashoffset=String(M.length*(1-b)):M.el.style.opacity=String(M.from+(M.to-M.from)*b)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(1),{destroy:()=>{},getProgress:()=>1};let c=0,p=!1,x=!1,F=()=>{i=d(),m(i),p&&(c=requestAnimationFrame(F))},E=()=>{p||(p=!0,c=requestAnimationFrame(F))},W=()=>{p=!1,cancelAnimationFrame(c)},ge=new IntersectionObserver(S=>{for(let M of S)x=M.isIntersecting,x?E():W()},{threshold:0});return ge.observe(n),i=d(),m(i),{destroy(){W(),ge.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"),d=this.getAttribute("direction"),m=this.getAttribute("selector");n&&(t.speed=parseFloat(n)),a&&(t.easing=a),i&&(t.stagger=parseFloat(i)),d&&(t.direction=d),m&&(t.selector=m),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/group/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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)),
|
|
2
|
-
<div style="position:absolute;${
|
|
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;
|
|
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)),s=Math.sqrt(t),f=0,p=[];for(let g=0;g<r;g++){let A=Math.pow(s,g);p.push(A),f+=A;}let a=[0],c=0;for(let g=0;g<r;g++)c+=p[g]/f,a.push(c);return g=>{if(g<=0)return 0;if(g>=1)return 1;for(let A=0;A<r;A++)if(g<=a[A+1]){let R=(g-a[A])/(a[A+1]-a[A]);if(A===0)return R*(2-R);let x=1-Math.pow(t,A);return x+(1-x)*(2*R-1)*(2*R-1)}return 1}}function bt({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),s=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-s)*(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 Be(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 K(e,n,r,t){return r===n?0:wt((e-n)/(r-n)*t,0,1)}function Pe(e,n,r,t,s){let f=Qe(e.top,e.height,n,t.element)-et(t.viewport,r),p=Qe(e.top,e.height,n,s.element)-et(s.viewport,r);return {tStart:f,tEnd:p}}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),s=tt(n);return !t||!s?e:`rgb(${Math.round(t[0]+(s[0]-t[0])*r)},${Math.round(t[1]+(s[1]-t[1])*r)},${Math.round(t[2]+(s[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 ot={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},vt=0;function Et(){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 s(){let f=r==="x"?window.scrollX:window.scrollY,p=e-f,a=n-f,c=r==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
+
<div style="position:absolute;${c?`left:${a}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${a}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",s,{passive:true}),s(),t}function Ye(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),s=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,f=>{let p=parseFloat(f),a=t[s++]??p;return String(+(p+(a-p)*r).toFixed(4))})}function Ue(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,s=r?{...rt[r],...t}:t,f=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:p="path, polyline, line, polygon, rect, circle",speed:a=1,fade:c=false,easing:g="linear",trigger:A={},stagger:R=0,direction:x="forward",once:Y=false,debug:Ce=false,axis:V="y",scrollContainer:we,autoReverse:pe=false,delay:de=0,strokeColor:U,strokeWidth:Q,fillOpacity:ee,waypoints:P,velocityScale:G=false,threshold:Oe=0,rootMargin:Ne="0px",repeat:ae=0,repeatDelay:ke=0,morphTo:k,clip:te,autoplay:le=false,duration:ve=1e3,native:ce=true,onProgress:j,onStart:Z,onComplete:J,onEnter:re,onLeave:Ee,onEnterBack:Le,onLeaveBack:Se}=s,ne=te===true?"left":typeof te=="string"?te:false,oe=typeof g=="function"?g:Ae[g]??Ae.linear,ge=Te(A.start??"top bottom"),Fe=Te(A.end??"bottom top"),I=typeof we=="string"?document.querySelector(we):we??null,B=Array.isArray(U)?U[0]:null,L=Array.isArray(U)?U[1]:typeof U=="string"?U:null,D=Array.isArray(Q)?Q[0]:null,i=Array.isArray(Q)?Q[1]:typeof Q=="number"?Q:null,m=Array.isArray(ee)?ee[0]:null,w=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null;function C(o){let l=o*100;switch(ne){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 b=ne?[]:Array.from(e.querySelectorAll(p)),$=[],v=[],F=0,H=0,O=false,_=false,N=0,Re=false,se=-1,He=-1,z=false,ye=0,ue=0,fe,Ge=null,me=new Set,ze=-1,Ze=performance.now(),xe=NaN;function De(){return I?V==="x"?I.scrollLeft:I.scrollTop:V==="x"?window.scrollX:window.scrollY}function Je(){return I?V==="x"?I.clientWidth:I.clientHeight:V==="x"?window.innerWidth:window.innerHeight}function Ke(){let o=e.getBoundingClientRect(),l,y,M;if(I){let q=I.getBoundingClientRect();l=V==="x"?o.left-q.left+I.scrollLeft:o.top-q.top+I.scrollTop,y=V==="x"?o.width:o.height,M=De();}else l=V==="x"?o.left:o.top,y=V==="x"?o.width:o.height,M=De();let W=Pe({top:l,height:y},M,Je(),ge,Fe);F=W.tStart,H=W.tEnd,Ce&&process.env.NODE_ENV!=="production"&&(Ge?.remove(),Ge=xt(F,H,V));}function pt(o,l){if(e.style.setProperty("--scroll-draw-progress",String(o)),ne){let y=l==="reverse"?1-o:o;e.style.clipPath=C(y);return}b.forEach((y,M)=>{y.style.strokeDashoffset=l==="reverse"?`${$[M]*o}`:`${$[M]*(1-o)}`,c&&(y.style.opacity=l==="reverse"?`${1-o}`:`${o}`),B&&L?y.style.stroke=Me(B,L,o):L&&(y.style.stroke=L),D!==null&&i!==null?y.style.strokeWidth=`${D+(i-D)*o}`:i!==null&&(y.style.strokeWidth=`${i}`),m!==null&&w!==null?y.style.fillOpacity=`${m+(w-m)*o}`:w!==null&&(y.style.fillOpacity=`${w}`),k&&y.tagName.toLowerCase()==="path"&&v[M]&&y.setAttribute("d",Ye(v[M],k,o));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),ne){e.style.clipPath=C(0);return}b.forEach((o,l)=>{o.style.strokeDasharray=`${$[l]}`,o.style.strokeDashoffset=x==="reverse"?"0":`${$[l]}`,c?o.style.opacity=x==="reverse"?"1":"0":o.style.opacity="",B&&(o.style.stroke=B),D!==null&&(o.style.strokeWidth=`${D}`),m!==null&&(o.style.fillOpacity=`${m}`),k&&o.tagName.toLowerCase()==="path"&&v[l]&&o.setAttribute("d",v[l]);});}if(b.forEach(o=>{St(o);let l=Be(o);$.push(l),o.tagName.toLowerCase()==="path"?v.push(o.getAttribute("d")??""):v.push(""),f?(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=x==="reverse"?`${l}`:"0",c&&(o.style.opacity="1"),L&&(o.style.stroke=L),i!==null&&(o.style.strokeWidth=`${i}`),w!==null&&(o.style.fillOpacity=`${w}`),k&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",k)):(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=x==="reverse"?"0":`${l}`,c?o.style.opacity=x==="reverse"?"1":"0":o.style.opacity="",B&&(o.style.stroke=B),D!==null&&(o.style.strokeWidth=`${D}`),m!==null&&(o.style.fillOpacity=`${m}`));}),ne){if(f)return e.style.clipPath=C(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=C(0);}else if(f)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function dt(){return !(ce===false||!Et()||!b.length||typeof g!="string"||!(g in ot)||ne||V!=="y"||I||a!==1||R!==0||Y||pe||G!==false||k||P||ae||de>0||j||Z||J||re||Ee||Le||Se||U!=null||Q!=null||ee!=null||(A.start??"top bottom").trim()!=="top bottom"||(A.end??"bottom top").trim()!=="bottom top")}function gt(){let o=`svg-scroll-draw-${++vt}`,l=x==="reverse"?"0":"var(--ssd-len)",y=x==="reverse"?"var(--ssd-len)":"0",M=`stroke-dashoffset:${l};`,W=`stroke-dashoffset:${y};`;c&&(M+=`opacity:${x==="reverse"?1:0};`,W+=`opacity:${x==="reverse"?0:1};`);let q=document.createElement("style");q.setAttribute("data-svg-scroll-draw",""),q.textContent=`@keyframes ${o}{from{${M}}to{${W}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${ot[g]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(q);function X(u,h){u.style.setProperty("--ssd-len",String($[h])),u.style.strokeDasharray=`${$[h]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(o);}b.forEach(X);let d=false,E=-1;function S(){if(E>=0)return E;let u=e.getBoundingClientRect(),{tStart:h,tEnd:T}=Pe({top:u.top,height:u.height},De(),Je(),ge,Fe);return oe(K(De(),h,T,a))}return {destroy(){b.forEach(u=>{u.classList.remove(o),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),q.remove();},replay(){d=false,E=-1,b.forEach(X);},pause(){d=true,b.forEach(u=>{u.style.animationPlayState="paused";});},resume(){d&&(d=false,b.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let h=Math.min(1,Math.max(0,u));E=h,d=true,b.forEach((T,he)=>{T.classList.remove(o),T.style.strokeDashoffset=x==="reverse"?`${$[he]*h}`:`${$[he]*(1-h)}`,c&&(T.style.opacity=x==="reverse"?`${1-h}`:`${h}`);});},getProgress(){return S()}}}if(dt())return gt();function yt(){let o=Math.max(1,ve),l=0,y=0;function M(S){let u=true;if(ne){let h=Math.min(1,Math.max(0,S/o)),T=oe(h);ye=T,e.style.setProperty("--scroll-draw-progress",String(T)),e.style.clipPath=C(x==="reverse"?1-T:T),j?.(T),h<1&&(u=false);}else b.forEach((h,T)=>{let he=T*R*o,$e=Math.min(1,Math.max(0,(S-he)/o)),ie=oe($e);h.style.strokeDashoffset=x==="reverse"?`${$[T]*ie}`:`${$[T]*(1-ie)}`,c&&(h.style.opacity=x==="reverse"?`${1-ie}`:`${ie}`),B&&L?h.style.stroke=Me(B,L,ie):L&&(h.style.stroke=L),D!==null&&i!==null?h.style.strokeWidth=`${D+(i-D)*ie}`:i!==null&&(h.style.strokeWidth=`${i}`),m!==null&&w!==null?h.style.fillOpacity=`${m+(w-m)*ie}`:w!==null&&(h.style.fillOpacity=`${w}`),k&&h.tagName.toLowerCase()==="path"&&v[T]&&h.setAttribute("d",Ye(v[T],k,ie)),T===0&&(j?.(ie),e.style.setProperty("--scroll-draw-progress",String(ie))),$e<1&&(u=false);});if(P){let h=Math.min(1,Math.max(0,S/o)),T=oe(h);for(let he in P){let $e=parseFloat(he);T>=$e&&!me.has($e)&&(me.add($e),P[he]?.());}}return u}function W(S){if(z)return;let u=S-l;_||(_=true,Z?.());let h=M(u);if(h&&!O){O=true,M(o*(1+Math.max(0,b.length-1)*R)),J?.(),ue<(ae==="infinite"?1/0:ae??0)&&(ue++,fe=setTimeout(()=>{l=performance.now(),_=false,O=false,me.clear(),We(),N=requestAnimationFrame(W);},ke));return}h||(N=requestAnimationFrame(W));}function q(){cancelAnimationFrame(N),clearTimeout(fe),l=performance.now(),y=0,z=false,_=false,O=false,ue=0,me.clear(),We(),N=requestAnimationFrame(W);}let X=new IntersectionObserver(S=>{S.forEach(u=>{u.isIntersecting&&!(Y&&O)?q():!u.isIntersecting&&!Y&&!O&&(cancelAnimationFrame(N),clearTimeout(fe),l=null);});},{root:I??null,threshold:Oe,rootMargin:Ne}),d;function E(){clearTimeout(d),d=setTimeout(()=>{b.forEach((S,u)=>{$[u]=Be(S),S.style.strokeDasharray=`${$[u]}`;});},150);}return window.addEventListener("resize",E),window.addEventListener("orientationchange",E),de>0?setTimeout(()=>X.observe(e),de):X.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(fe),X.disconnect(),window.removeEventListener("resize",E),window.removeEventListener("orientationchange",E),clearTimeout(d);},replay(){ue=0,q();},pause(){z||(z=true,y=performance.now()-l,cancelAnimationFrame(N));},resume(){z&&(z=false,l=performance.now()-y,N=requestAnimationFrame(W));},seek(S){let u=Math.min(1,Math.max(0,S));ye=u,z=true,y=u*o,l=performance.now()-y,cancelAnimationFrame(N),M(y);},getProgress(){return ye}}}if(le)return yt();Ke();function qe(){if(!Re||z)return;let o=performance.now(),l=De(),y=a;if(G!==false){let d=o-Ze,E=d>0?Math.abs(l-(ze<0?l:ze))/d:0;y=a*Math.max(.2,1+E*(typeof G=="number"?G:1)*.04);}ze=l,Ze=o;let M=pe?He===-1||l>=He?"forward":"reverse":x;He=l;let W=H-F,q=true,X=W===0?0:(l-F)/W;if(isNaN(xe)||(xe<=0&&X>0?re?.():xe>0&&X<=0&&Se?.(),xe<1&&X>=1?Ee?.():xe>=1&&X<1&&Le?.()),xe=X,ne){let d=oe(K(l,F,H,y));Y&&!pe&&(se=Math.max(se,d),d=se),ye=d,e.style.setProperty("--scroll-draw-progress",String(d));let E=M==="reverse"?1-d:d;e.style.clipPath=C(E),j?.(d),!_&&K(l,F,H,y)>0&&(_=true,Z?.()),d>=1&&!O?(O=true,J?.(),ue<(ae==="infinite"?1/0:ae??0)&&(ue++,fe=setTimeout(()=>{se=-1,_=false,O=false,e.style.clipPath=C(0);},ke))):d<1&&!Y&&(O=false),N=requestAnimationFrame(qe);return}if(b.forEach((d,E)=>{let S=E*R*W,u=oe(K(l,F+S,H+S,y));Y&&!pe&&(se=Math.max(se,u),u=se),ye=u,d.style.strokeDashoffset=M==="reverse"?`${$[E]*u}`:`${$[E]*(1-u)}`,c&&(d.style.opacity=M==="reverse"?`${1-u}`:`${u}`),B&&L?d.style.stroke=Me(B,L,u):L&&(d.style.stroke=L),D!==null&&i!==null?d.style.strokeWidth=`${D+(i-D)*u}`:i!==null&&(d.style.strokeWidth=`${i}`),m!==null&&w!==null?d.style.fillOpacity=`${m+(w-m)*u}`:w!==null&&(d.style.fillOpacity=`${w}`),k&&d.tagName.toLowerCase()==="path"&&v[E]&&d.setAttribute("d",Ye(v[E],k,u)),E===0&&(j?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(q=false);}),P){let d=oe(K(l,F,H,y));for(let E in P){let S=parseFloat(E);d>=S&&!me.has(S)&&(me.add(S),P[E]?.());}}!_&&K(l,F,H,y)>0&&(_=true,Z?.()),q&&!O?(O=true,J?.(),ue<(ae==="infinite"?1/0:ae??0)&&(ue++,fe=setTimeout(()=>{se=-1,_=false,O=false,me.clear(),We();},ke))):!q&&!Y&&(O=false),N=requestAnimationFrame(qe);}let je=new IntersectionObserver(o=>{o.forEach(l=>{Re=l.isIntersecting,Re&&!z?N=requestAnimationFrame(qe):cancelAnimationFrame(N);});},{root:I??null,threshold:Oe,rootMargin:Ne}),Xe;function Ve(){clearTimeout(Xe),Xe=setTimeout(()=>{b.forEach((o,l)=>{$[l]=Be(o),o.style.strokeDasharray=`${$[l]}`;}),Ke();},150);}return window.addEventListener("resize",Ve),window.addEventListener("orientationchange",Ve),de>0?setTimeout(()=>je.observe(e),de):je.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(fe),je.disconnect(),window.removeEventListener("resize",Ve),window.removeEventListener("orientationchange",Ve),clearTimeout(Xe),Ge?.remove();},replay(){se=-1,He=-1,ze=-1,_=false,O=false,ue=0,z=false,me.clear(),clearTimeout(fe),We();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,Re&&(N=requestAnimationFrame(qe)));},seek(o){let l=Math.min(1,Math.max(0,o));ye=l,se=l,z=true,cancelAnimationFrame(N),pt(l,x);},getProgress(){return ye}}}var st=new Map;function it(e,n){st.set(e,n);}function at(e){st.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 s=[],f=[],p=t[2].trim();if(p)for(let a of p.split(/[\s,]+/)){let c=a.match(/^([-+]?[\d.eE]+)(.*)$/);s.push(c?parseFloat(c[1]):0),f.push(c?c[2]:"");}n.push({fn:t[1],nums:s,units:f});}return n}function At(e,n,r){let t=lt(e),s=lt(n);return t.length===0||t.length!==s.length?r<1?e:n:t.map((f,p)=>{let a=s[p];return f.fn!==a.fn||f.nums.length!==a.nums.length?r<1?`${f.fn}(${f.nums.map((c,g)=>`${c}${f.units[g]}`).join(", ")})`:`${a.fn}(${a.nums.map((c,g)=>`${c}${a.units[g]}`).join(", ")})`:`${f.fn}(${f.nums.map((c,g)=>`${c+(a.nums[g]-c)*r}${f.units[g]}`).join(", ")})`}).join(" ")}function ct(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),s=String(n);if($t(t))return Me(t,s,r);if(t.includes("("))return At(t,s,r);let f=t.match(/^([-+]?[\d.]+)(.*)$/),p=s.match(/^([-+]?[\d.]+)(.*)$/);if(f&&p){let a=parseFloat(f[1]),c=parseFloat(p[1]);return `${a+(c-a)*r}${f[2]||p[2]}`}return r<1?t:s}function Tt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var ut={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:s={},easing:f="ease-out",speed:p=1,once:a=false,axis:c="y",scrollContainer:g,native:A=true,velocityScale:R=false,onProgress:x,onComplete:Y,onEnter:Ce,onLeave:V,onEnterBack:we,onLeaveBack:pe}=n,de=window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=typeof f=="function"?f:Ae[f]??Ae["ease-out"],Q=Te(s.start??"top bottom"),ee=Te(s.end??"bottom top"),P=typeof g=="string"?document.querySelector(g):g??null,G=Object.entries(t).map(([i,m])=>({prop:Tt(i),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function Oe(){let i=window.getComputedStyle(e);for(let m of G)m.from===""&&(m.from=i.getPropertyValue(m.prop).trim()||"0");}function Ne(){for(let i of G)e.style.setProperty(i.prop,String(i.to));}if(de)return Ne(),Y?.(),r;Oe();function ae(){if(!A||!kt()||typeof f!="string"||!(f in ut)||c!=="y"||P||a||p!==1||x||Y||Ce||V||we||pe||R!==false||(s.start??"top bottom").trim()!=="top bottom"||(s.end??"bottom top").trim()!=="bottom top")return false;for(let i of G)if(!Pt.has(i.prop))return false;return true}function ke(){let i=`ssd-a-${++Mt}`,m=G.map(v=>`${v.prop}:${v.from}`).join(";"),w=G.map(v=>`${v.prop}:${v.to}`).join(";"),C=document.createElement("style");C.setAttribute("data-ssd-animate",""),C.textContent=`@keyframes ${i}{from{${m}}to{${w}}}.${i}{animation-name:${i};animation-duration:auto;animation-timing-function:${ut[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C),e.classList.add(i);let b=()=>c==="x"?window.scrollX:window.scrollY,$=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(i),C.remove();},replay(){e.classList.remove(i),e.offsetWidth,e.classList.add(i);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(v){let F=Math.min(1,Math.max(0,v));e.classList.remove(i);for(let H of G)e.style.setProperty(H.prop,ct(H.from,H.to,F));},getProgress(){let v=e.getBoundingClientRect(),F=b(),H=$(),{tStart:O,tEnd:_}=Pe({top:v.top,height:v.height},F,H,Q,ee);return U(K(F,O,_,p))}}}if(ae())return ke();let k=0,te=0,le=0,ve=false,ce=false,j=-1,Z=0,J=false,re=NaN,Ee=-1,Le=0,Se=()=>P?c==="x"?P.scrollLeft:P.scrollTop:c==="x"?window.scrollX:window.scrollY,ne=()=>P?c==="x"?P.clientWidth:P.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function oe(){let i=e.getBoundingClientRect(),m,w;if(P){let b=P.getBoundingClientRect();m=c==="x"?i.left-b.left+P.scrollLeft:i.top-b.top+P.scrollTop,w=c==="x"?i.width:i.height;}else m=c==="x"?i.left:i.top,w=c==="x"?i.width:i.height;let C=Pe({top:m,height:w},Se(),ne(),Q,ee);k=C.tStart,te=C.tEnd;}function ge(i){e.style.setProperty("--scroll-draw-progress",String(i));for(let m of G)e.style.setProperty(m.prop,ct(m.from,m.to,i));x?.(i);}function Fe(i){if(isNaN(re)){re=i;return}re<=0&&i>0?Ce?.():re>0&&i<=0&&pe?.(),re<1&&i>=1?V?.():re>=1&&i<1&&we?.(),re=i;}function I(){if(!ve||ce)return;let i=performance.now(),m=Se(),w=p;if(R!==false){let $=i-Le,v=$>0?Math.abs(m-(Ee<0?m:Ee))/$:0;w=p*Math.max(.2,1+v*(typeof R=="number"?R:1)*.04);}Ee=m,Le=i;let C=te===k?0:(m-k)/(te-k);Fe(C);let b=U(K(m,k,te,w));a&&(j=Math.max(j,b),b=j),Z=b,ge(b),b>=1&&!J?(J=true,Y?.()):b<1&&!a&&(J=false),le=requestAnimationFrame(I);}oe();{let i=U(K(Se(),k,te,p));a&&i>0&&(j=i),Z=i,ge(i);}let B=new IntersectionObserver(i=>{i.forEach(m=>{ve=m.isIntersecting,ve&&!ce?le=requestAnimationFrame(I):cancelAnimationFrame(le);});},{root:P??null}),L;function D(){clearTimeout(L),L=setTimeout(oe,150);}return window.addEventListener("resize",D),window.addEventListener("orientationchange",D),B.observe(e),it(e,{type:"animate",getProgress:()=>Z,getTrigger:()=>({tStart:k,tEnd:te})}),{destroy(){cancelAnimationFrame(le),B.disconnect(),window.removeEventListener("resize",D),window.removeEventListener("orientationchange",D),clearTimeout(L),at(e);},replay(){j=-1,J=false,Z=0,ce=false,ge(0);},pause(){ce=true,cancelAnimationFrame(le);},resume(){ce&&(ce=false,ve&&(le=requestAnimationFrame(I)));},seek(i){let m=Math.min(1,Math.max(0,i));Z=m,j=m,ce=true,cancelAnimationFrame(le),ge(m);},getProgress(){return Z}}}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:s="y",easing:f="linear",trigger:p,onProgress:a}=n,c=r.getBoundingClientRect(),g=s==="x"?c.width:c.height,A=t*g;return _e(r,{props:s==="x"?{transform:["translateX(0px)",`translateX(${-A}px)`]}:{transform:["translateY(0px)",`translateY(${-A}px)`]},trigger:p??{start:"top bottom",end:"bottom top"},easing:f,native:false,onProgress:a})}function Ie(e){return e.map(n=>typeof n=="string"?document.querySelector(n):n).filter(n=>n!==null)}var be={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function qt(e,n={}){if(typeof window>"u")return be;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(s=>s.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function Vt(e,n={}){if(typeof window>"u")return be;let r=Ie(e);if(r.length===0)return be;let t=0,s=[];function f(a){return Ue(r[a],{...n,once:true,onComplete(){n.onComplete?.(),t=a+1,s[t]?.resume();}})}function p(){r.forEach((a,c)=>{s[c]=f(c);});for(let a=1;a<s.length;a++)s[a].pause();}return p(),{destroy(){s.forEach(a=>a.destroy()),s.length=0;},replay(){s.forEach(a=>a.destroy()),s.length=0,t=0,p();},pause(){s[t]?.pause();},resume(){s[t]?.resume();},seek(a){s[t]?.seek(a);},getProgress(){return s[t]?.getProgress()??0}}}function Bt(e,n){if(typeof window>"u")return be;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(s=>s.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function _t(e,n){if(typeof window>"u")return be;let r=Ie(e);if(r.length===0)return be;let t=0,s=[];function f(a){return _e(r[a],{...n,once:true,onComplete(){n.onComplete?.(),t=a+1,s[t]?.resume();}})}function p(){r.forEach((a,c)=>{s[c]=f(c);});for(let a=1;a<s.length;a++)s[a].pause();}return p(),{destroy(){s.forEach(a=>a.destroy()),s.length=0;},replay(){s.forEach(a=>a.destroy()),s.length=0,t=0,p();},pause(){s[t]?.pause();},resume(){s[t]?.resume();},seek(a){s[t]?.seek(a);},getProgress(){return s[t]?.getProgress()??0}}}function Gt(e,n={}){if(typeof window>"u")return be;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(s=>s.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}exports.scrollAnimateGroup=Bt;exports.scrollAnimateSequence=_t;exports.scrollDrawGroup=qt;exports.scrollDrawSequence=Vt;exports.scrollParallaxGroup=Gt;
|
package/dist/group/index.d.mts
CHANGED
|
@@ -136,6 +136,12 @@ interface ScrollAnimateOptions {
|
|
|
136
136
|
axis?: 'x' | 'y';
|
|
137
137
|
scrollContainer?: string | Element;
|
|
138
138
|
native?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Scale animation speed by scroll velocity — faster scrolling = faster animation.
|
|
141
|
+
* Pass `true` for default sensitivity (1) or a number to control it.
|
|
142
|
+
* Higher values = more dramatic speed-up. Default sensitivity: 1.
|
|
143
|
+
*/
|
|
144
|
+
velocityScale?: boolean | number;
|
|
139
145
|
onProgress?: (alpha: number) => void;
|
|
140
146
|
onComplete?: () => void;
|
|
141
147
|
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
package/dist/group/index.d.ts
CHANGED
|
@@ -136,6 +136,12 @@ interface ScrollAnimateOptions {
|
|
|
136
136
|
axis?: 'x' | 'y';
|
|
137
137
|
scrollContainer?: string | Element;
|
|
138
138
|
native?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Scale animation speed by scroll velocity — faster scrolling = faster animation.
|
|
141
|
+
* Pass `true` for default sensitivity (1) or a number to control it.
|
|
142
|
+
* Higher values = more dramatic speed-up. Default sensitivity: 1.
|
|
143
|
+
*/
|
|
144
|
+
velocityScale?: boolean | number;
|
|
139
145
|
onProgress?: (alpha: number) => void;
|
|
140
146
|
onComplete?: () => void;
|
|
141
147
|
/** Fires when scroll enters the trigger zone (scrolling forward). */
|