svg-scroll-draw 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/index.cjs +3 -3
- package/dist/angular/index.d.mts +42 -0
- package/dist/angular/index.d.ts +42 -0
- package/dist/angular/index.mjs +3 -3
- package/dist/astro/index.cjs +3 -3
- package/dist/astro/index.d.mts +20 -5
- package/dist/astro/index.d.ts +20 -5
- package/dist/astro/index.mjs +3 -3
- package/dist/cdn/svg-scroll-draw.dev.global.js +1878 -0
- package/dist/cdn/svg-scroll-draw.global.js +3 -3
- package/dist/cinematic/index.cjs +2 -2
- package/dist/cinematic/index.mjs +2 -2
- package/dist/cli/init.js +104 -101
- package/dist/devtools/index.cjs +1 -1
- package/dist/devtools/index.mjs +1 -1
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +42 -0
- package/dist/group/index.d.ts +42 -0
- package/dist/group/index.mjs +3 -3
- package/dist/horizontal/index.cjs +1 -1
- package/dist/horizontal/index.d.mts +48 -1
- package/dist/horizontal/index.d.ts +48 -1
- package/dist/horizontal/index.mjs +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.mjs +4 -4
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +27 -0
- package/dist/nuxt/index.d.ts +27 -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 -1
- package/dist/progress/index.d.mts +15 -0
- package/dist/progress/index.d.ts +15 -0
- package/dist/progress/index.mjs +1 -1
- package/dist/react/index.cjs +3 -3
- package/dist/react/index.d.mts +27 -0
- package/dist/react/index.d.ts +27 -0
- package/dist/react/index.mjs +3 -3
- package/dist/reveal/index.cjs +1 -1
- package/dist/reveal/index.mjs +1 -1
- package/dist/snap/index.cjs +1 -1
- package/dist/snap/index.d.mts +8 -0
- package/dist/snap/index.d.ts +8 -0
- package/dist/snap/index.mjs +1 -1
- package/dist/solid/index.cjs +3 -3
- package/dist/solid/index.d.mts +42 -0
- package/dist/solid/index.d.ts +42 -0
- package/dist/solid/index.mjs +3 -3
- package/dist/svelte/index.cjs +3 -3
- package/dist/svelte/index.d.mts +42 -0
- package/dist/svelte/index.d.ts +42 -0
- package/dist/svelte/index.mjs +3 -3
- package/dist/text/index.cjs +1 -1
- package/dist/text/index.d.mts +15 -0
- package/dist/text/index.d.ts +15 -0
- package/dist/text/index.mjs +1 -1
- package/dist/timeline/index.cjs +8 -8
- package/dist/timeline/index.d.mts +31 -0
- package/dist/timeline/index.d.ts +31 -0
- package/dist/timeline/index.mjs +8 -8
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.d.mts +15 -0
- package/dist/video/index.d.ts +15 -0
- package/dist/video/index.mjs +1 -1
- package/dist/vue/index.cjs +3 -3
- package/dist/vue/index.d.mts +27 -0
- package/dist/vue/index.d.ts +27 -0
- package/dist/vue/index.mjs +3 -3
- package/dist/web-component/index.cjs +3 -3
- package/dist/web-component/index.mjs +3 -3
- package/package.json +22 -5
package/dist/progress/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function X({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),
|
|
1
|
+
function X({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),c=Math.sqrt(n),i=0,p=[];for(let o=0;o<r;o++){let u=Math.pow(c,o);p.push(u),i+=u;}let m=[0],h=0;for(let o=0;o<r;o++)h+=p[o]/i,m.push(h);return o=>{if(o<=0)return 0;if(o>=1)return 1;for(let u=0;u<r;u++)if(o<=m[u+1]){let f=(o-m[u])/(m[u+1]-m[u]);if(u===0)return f*(2-f);let d=1-Math.pow(n,u);return d+(1-d)*(2*f-1)*(2*f-1)}return 1}}function j({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),c=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return i=>i<=0?0:i>=1?1:r*Math.pow(2,-10*i)*Math.sin((i-c)*(2*Math.PI)/n)+1}var P={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:X(),elastic:j()};function T(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function F(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function C(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function J(e,t,r){return Math.min(r,Math.max(t,e))}function R(e,t,r,n){return r===t?0:J((e-t)/(r-t)*n,0,1)}function V(e,t,r){let n=e.getBoundingClientRect(),c=r==="x"?n.width:n.height;return t?{top:r==="x"?n.left-t.getBoundingClientRect().left+t.scrollLeft:n.top-t.getBoundingClientRect().top+t.scrollTop,height:c,scroll:0}:{top:r==="x"?n.left:n.top,height:c,scroll:r==="x"?window.scrollX:window.scrollY}}function D(e,t,r,n,c){let i=F(e.top,e.height,t,n.element)-C(n.viewport,r),p=F(e.top,e.height,t,c.element)-C(c.viewport,r);return {tStart:i,tEnd:p}}var O=new Map;function $(e,t){O.set(e,t);}function G(e){O.delete(e);}var K=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function N(e,...t){K&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var q={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function te(e,t={}){if(typeof window>"u")return q;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return N("scrollProgress: element not found:",e),q;let n=r,{variable:c="--scroll-progress",easedVariable:i="--scroll-progress-eased",trigger:p={},easing:m="linear",speed:h=1,axis:o="y",scrollContainer:u,onProgress:f}=t,d=typeof m=="function"?m:P[m]??P.linear,W=T(p.start??"top bottom"),z=T(p.end??"bottom top"),l=typeof u=="string"?document.querySelector(u):u??null,y=0,x=0,g=0,E=false,b=false,w=0,A=()=>l?o==="x"?l.scrollLeft:l.scrollTop:o==="x"?window.scrollX:window.scrollY,B=()=>l?o==="x"?l.clientWidth:l.clientHeight:o==="x"?window.innerWidth:window.innerHeight;function v(){let s=V(n,l,o),a=D(s,s.scroll,B(),W,z);y=a.tStart,x=a.tEnd;}function _(s,a){n.style.setProperty(c,String(s)),i!=null&&n.style.setProperty(i,String(a)),f?.(s,a);}function S(){if(!E||b)return;let s=R(A(),y,x,h),a=d(s);w=s,_(s,a),g=requestAnimationFrame(S);}v();{let s=R(A(),y,x,h),a=d(s);w=s,_(s,a);}let L=new IntersectionObserver(s=>{s.forEach(a=>{E=a.isIntersecting,E&&!b?g=requestAnimationFrame(S):cancelAnimationFrame(g);});},{root:l??null}),I;function M(){clearTimeout(I),I=setTimeout(v,150);}return window.addEventListener("resize",M),window.addEventListener("orientationchange",M),L.observe(r),$(r,{type:"animate",getProgress:()=>w,getTrigger:()=>({tStart:y,tEnd:x})}),{destroy(){cancelAnimationFrame(g),L.disconnect(),window.removeEventListener("resize",M),window.removeEventListener("orientationchange",M),clearTimeout(I),n.style.removeProperty(c),i!=null&&n.style.removeProperty(i),G(r);},replay(){v();},pause(){b=true,cancelAnimationFrame(g);},resume(){b&&(b=false,E&&(g=requestAnimationFrame(S)));},seek(s){let a=Math.min(1,Math.max(0,s)),k=d(a);w=a,b=true,cancelAnimationFrame(g),_(a,k);},getProgress(){return w}}}export{te as scrollProgress};
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${c?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",i,{passive:true}),i(),t}function Je(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,o=>{let l=parseFloat(o),u=t[i++]??l;return String(+(l+(u-l)*r).toFixed(4))})}function at(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,i=r?{...ot[r],...t}:t,o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:l="path, polyline, line, polygon, rect, circle",speed:u=1,fade:c=false,easing:y="linear",trigger:L={},stagger:C=0,direction:S="forward",once:U=false,debug:de=false,axis:F="y",scrollContainer:_,autoReverse:H=false,delay:G=0,strokeColor:x,strokeWidth:M,fillOpacity:P,waypoints:p,velocityScale:v=false,threshold:N=0,rootMargin:I="0px",repeat:E=0,repeatDelay:J=0,morphTo:T,clip:R,autoplay:D=false,duration:K=1e3,native:X=true,onProgress:d,onStart:$,onComplete:b,onEnter:h,onLeave:Y,onEnterBack:Se,onLeaveBack:xe}=i,be=R===true?"left":typeof R=="string"?R:false,we=typeof y=="function"?y:re[y]??re.linear,Ce=ne(L.start??"top bottom"),He=ne(L.end??"bottom top"),oe=typeof _=="string"?document.querySelector(_):_??null,ge=Array.isArray(x)?x[0]:null,ee=Array.isArray(x)?x[1]:typeof x=="string"?x:null,te=Array.isArray(M)?M[0]:null,a=Array.isArray(M)?M[1]:typeof M=="number"?M:null,g=Array.isArray(P)?P[0]:null,z=Array.isArray(P)?P[1]:typeof P=="number"?P:null;function se(s){let m=s*100;switch(be){case "right":return `inset(0 0 0 ${100-m}%)`;case "top":return `inset(0 0 ${100-m}% 0)`;case "bottom":return `inset(${100-m}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-m}% 0 0)`}}let O=be?[]:Array.from(e.querySelectorAll(l)),B=[],V=[],le=0,ce=0,ie=false,ye=false,ae=0,ze=false,ve=-1,Ve=-1,ue=false,$e=0,Te=0,Ae,Ye=null,Me=new Set,qe=-1,Ke=performance.now(),Ne=NaN;function Re(){return oe?F==="x"?oe.scrollLeft:oe.scrollTop:F==="x"?window.scrollX:window.scrollY}function Qe(){return oe?F==="x"?oe.clientWidth:oe.clientHeight:F==="x"?window.innerWidth:window.innerHeight}function et(){let s=e.getBoundingClientRect(),m,A,Q;if(oe){let fe=oe.getBoundingClientRect();m=F==="x"?s.left-fe.left+oe.scrollLeft:s.top-fe.top+oe.scrollTop,A=F==="x"?s.width:s.height,Q=Re();}else m=F==="x"?s.left:s.top,A=F==="x"?s.width:s.height,Q=Re();let me=pe({top:m,height:A},Q,Qe(),Ce,He);le=me.tStart,ce=me.tEnd,de&&process.env.NODE_ENV!=="production"&&(Ye?.remove(),Ye=kt(le,ce,F));}function Et(s,m){if(e.style.setProperty("--scroll-draw-progress",String(s)),be){let A=m==="reverse"?1-s:s;e.style.clipPath=se(A);return}O.forEach((A,Q)=>{A.style.strokeDashoffset=m==="reverse"?`${B[Q]*s}`:`${B[Q]*(1-s)}`,c&&(A.style.opacity=m==="reverse"?`${1-s}`:`${s}`),ge&&ee?A.style.stroke=Oe(ge,ee,s):ee&&(A.style.stroke=ee),te!==null&&a!==null?A.style.strokeWidth=`${te+(a-te)*s}`:a!==null&&(A.style.strokeWidth=`${a}`),g!==null&&z!==null?A.style.fillOpacity=`${g+(z-g)*s}`:z!==null&&(A.style.fillOpacity=`${z}`),T&&A.tagName.toLowerCase()==="path"&&V[Q]&&A.setAttribute("d",Je(V[Q],T,s));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),be){e.style.clipPath=se(0);return}O.forEach((s,m)=>{s.style.strokeDasharray=`${B[m]}`,s.style.strokeDashoffset=S==="reverse"?"0":`${B[m]}`,c?s.style.opacity=S==="reverse"?"1":"0":s.style.opacity="",ge&&(s.style.stroke=ge),te!==null&&(s.style.strokeWidth=`${te}`),g!==null&&(s.style.fillOpacity=`${g}`),T&&s.tagName.toLowerCase()==="path"&&V[m]&&s.setAttribute("d",V[m]);});}if(O.forEach(s=>{$t(s);let m=Ge(s);B.push(m),s.tagName.toLowerCase()==="path"?V.push(s.getAttribute("d")??""):V.push(""),o?(s.style.strokeDasharray=`${m}`,s.style.strokeDashoffset=S==="reverse"?`${m}`:"0",c&&(s.style.opacity="1"),ee&&(s.style.stroke=ee),a!==null&&(s.style.strokeWidth=`${a}`),z!==null&&(s.style.fillOpacity=`${z}`),T&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",T)):(s.style.strokeDasharray=`${m}`,s.style.strokeDashoffset=S==="reverse"?"0":`${m}`,c?s.style.opacity=S==="reverse"?"1":"0":s.style.opacity="",ge&&(s.style.stroke=ge),te!==null&&(s.style.strokeWidth=`${te}`),g!==null&&(s.style.fillOpacity=`${g}`));}),be){if(o)return e.style.clipPath=se(1),b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=se(0);}else if(o)return b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function St(){return !(X===false||!Ct()||!O.length||typeof y!="string"||!(y in it)||be||F!=="y"||oe||u!==1||C!==0||U||H||v!==false||T||p||E||G>0||d||$||b||h||Y||Se||xe||x!=null||M!=null||P!=null||(L.start??"top bottom").trim()!=="top bottom"||(L.end??"bottom top").trim()!=="bottom top")}function xt(){let s=`svg-scroll-draw-${++Lt}`,m=S==="reverse"?"0":"var(--ssd-len)",A=S==="reverse"?"var(--ssd-len)":"0",Q=`stroke-dashoffset:${m};`,me=`stroke-dashoffset:${A};`;c&&(Q+=`opacity:${S==="reverse"?1:0};`,me+=`opacity:${S==="reverse"?0:1};`);let fe=document.createElement("style");fe.setAttribute("data-svg-scroll-draw",""),fe.textContent=`@keyframes ${s}{from{${Q}}to{${me}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${it[y]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(fe);function he(f,k){f.style.setProperty("--ssd-len",String(B[k])),f.style.strokeDasharray=`${B[k]}`,f.style.strokeDashoffset="",f.style.opacity="",f.style.animationPlayState="",f.classList.add(s);}O.forEach(he);let w=false,q=-1;function W(){if(q>=0)return q;let f=e.getBoundingClientRect(),{tStart:k,tEnd:j}=pe({top:f.top,height:f.height},Re(),Qe(),Ce,He);return we(Z(Re(),k,j,u))}return {destroy(){O.forEach(f=>{f.classList.remove(s),f.style.removeProperty("--ssd-len"),f.style.animationPlayState="";}),fe.remove();},replay(){w=false,q=-1,O.forEach(he);},pause(){w=true,O.forEach(f=>{f.style.animationPlayState="paused";});},resume(){w&&(w=false,O.forEach(f=>{f.style.animationPlayState="running";}));},seek(f){let k=Math.min(1,Math.max(0,f));q=k,w=true,O.forEach((j,ke)=>{j.classList.remove(s),j.style.strokeDashoffset=S==="reverse"?`${B[ke]*k}`:`${B[ke]*(1-k)}`,c&&(j.style.opacity=S==="reverse"?`${1-k}`:`${k}`);});},getProgress(){return W()}}}if(St())return xt();function Tt(){let s=Math.max(1,K),m=0,A=0;function Q(W){let f=true;if(be){let k=Math.min(1,Math.max(0,W/s)),j=we(k);$e=j,e.style.setProperty("--scroll-draw-progress",String(j)),e.style.clipPath=se(S==="reverse"?1-j:j),d?.(j),k<1&&(f=false);}else O.forEach((k,j)=>{let ke=j*C*s,Ie=Math.min(1,Math.max(0,(W-ke)/s)),Ee=we(Ie);k.style.strokeDashoffset=S==="reverse"?`${B[j]*Ee}`:`${B[j]*(1-Ee)}`,c&&(k.style.opacity=S==="reverse"?`${1-Ee}`:`${Ee}`),ge&&ee?k.style.stroke=Oe(ge,ee,Ee):ee&&(k.style.stroke=ee),te!==null&&a!==null?k.style.strokeWidth=`${te+(a-te)*Ee}`:a!==null&&(k.style.strokeWidth=`${a}`),g!==null&&z!==null?k.style.fillOpacity=`${g+(z-g)*Ee}`:z!==null&&(k.style.fillOpacity=`${z}`),T&&k.tagName.toLowerCase()==="path"&&V[j]&&k.setAttribute("d",Je(V[j],T,Ee)),j===0&&(d?.(Ee),e.style.setProperty("--scroll-draw-progress",String(Ee))),Ie<1&&(f=false);});if(p){let k=Math.min(1,Math.max(0,W/s)),j=we(k);for(let ke in p){let Ie=parseFloat(ke);j>=Ie&&!Me.has(Ie)&&(Me.add(Ie),p[ke]?.());}}return f}function me(W){if(ue)return;let f=W-m;ye||(ye=true,$?.());let k=Q(f);if(k&&!ie){ie=true,Q(s*(1+Math.max(0,O.length-1)*C)),b?.(),Te<(E==="infinite"?1/0:E??0)&&(Te++,Ae=setTimeout(()=>{m=performance.now(),ye=false,ie=false,Me.clear(),We(),ae=requestAnimationFrame(me);},J));return}k||(ae=requestAnimationFrame(me));}function fe(){cancelAnimationFrame(ae),clearTimeout(Ae),m=performance.now(),A=0,ue=false,ye=false,ie=false,Te=0,Me.clear(),We(),ae=requestAnimationFrame(me);}let he=new IntersectionObserver(W=>{W.forEach(f=>{f.isIntersecting&&!(U&&ie)?fe():!f.isIntersecting&&!U&&!ie&&(cancelAnimationFrame(ae),clearTimeout(Ae),m=null);});},{root:oe??null,threshold:N,rootMargin:I}),w;function q(){clearTimeout(w),w=setTimeout(()=>{O.forEach((W,f)=>{B[f]=Ge(W),W.style.strokeDasharray=`${B[f]}`;});},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),G>0?setTimeout(()=>he.observe(e),G):he.observe(e),{destroy(){cancelAnimationFrame(ae),clearTimeout(Ae),he.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(w);},replay(){Te=0,fe();},pause(){ue||(ue=true,A=performance.now()-m,cancelAnimationFrame(ae));},resume(){ue&&(ue=false,m=performance.now()-A,ae=requestAnimationFrame(me));},seek(W){let f=Math.min(1,Math.max(0,W));$e=f,ue=true,A=f*s,m=performance.now()-A,cancelAnimationFrame(ae),Q(A);},getProgress(){return $e}}}if(D)return Tt();et();function Be(){if(!ze||ue)return;let s=performance.now(),m=Re(),A=u;if(v!==false){let w=s-Ke,q=w>0?Math.abs(m-(qe<0?m:qe))/w:0;A=u*Math.max(.2,1+q*(typeof v=="number"?v:1)*.04);}qe=m,Ke=s;let Q=H?Ve===-1||m>=Ve?"forward":"reverse":S;Ve=m;let me=ce-le,fe=true,he=me===0?0:(m-le)/me;if(isNaN(Ne)||(Ne<=0&&he>0?h?.():Ne>0&&he<=0&&xe?.(),Ne<1&&he>=1?Y?.():Ne>=1&&he<1&&Se?.()),Ne=he,be){let w=we(Z(m,le,ce,A));U&&!H&&(ve=Math.max(ve,w),w=ve),$e=w,e.style.setProperty("--scroll-draw-progress",String(w));let q=Q==="reverse"?1-w:w;e.style.clipPath=se(q),d?.(w),!ye&&Z(m,le,ce,A)>0&&(ye=true,$?.()),w>=1&&!ie?(ie=true,b?.(),Te<(E==="infinite"?1/0:E??0)&&(Te++,Ae=setTimeout(()=>{ve=-1,ye=false,ie=false,e.style.clipPath=se(0);},J))):w<1&&!U&&(ie=false),ae=requestAnimationFrame(Be);return}if(O.forEach((w,q)=>{let W=q*C*me,f=we(Z(m,le+W,ce+W,A));U&&!H&&(ve=Math.max(ve,f),f=ve),$e=f,w.style.strokeDashoffset=Q==="reverse"?`${B[q]*f}`:`${B[q]*(1-f)}`,c&&(w.style.opacity=Q==="reverse"?`${1-f}`:`${f}`),ge&&ee?w.style.stroke=Oe(ge,ee,f):ee&&(w.style.stroke=ee),te!==null&&a!==null?w.style.strokeWidth=`${te+(a-te)*f}`:a!==null&&(w.style.strokeWidth=`${a}`),g!==null&&z!==null?w.style.fillOpacity=`${g+(z-g)*f}`:z!==null&&(w.style.fillOpacity=`${z}`),T&&w.tagName.toLowerCase()==="path"&&V[q]&&w.setAttribute("d",Je(V[q],T,f)),q===0&&(d?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(fe=false);}),p){let w=we(Z(m,le,ce,A));for(let q in p){let W=parseFloat(q);w>=W&&!Me.has(W)&&(Me.add(W),p[q]?.());}}!ye&&Z(m,le,ce,A)>0&&(ye=true,$?.()),fe&&!ie?(ie=true,b?.(),Te<(E==="infinite"?1/0:E??0)&&(Te++,Ae=setTimeout(()=>{ve=-1,ye=false,ie=false,Me.clear(),We();},J))):!fe&&!U&&(ie=false),ae=requestAnimationFrame(Be);}let je=new IntersectionObserver(s=>{s.forEach(m=>{ze=m.isIntersecting,ze&&!ue?ae=requestAnimationFrame(Be):cancelAnimationFrame(ae);});},{root:oe??null,threshold:N,rootMargin:I}),Ue;function _e(){clearTimeout(Ue),Ue=setTimeout(()=>{O.forEach((s,m)=>{B[m]=Ge(s),s.style.strokeDasharray=`${B[m]}`;}),et();},150);}return window.addEventListener("resize",_e),window.addEventListener("orientationchange",_e),G>0?setTimeout(()=>je.observe(e),G):je.observe(e),{destroy(){cancelAnimationFrame(ae),clearTimeout(Ae),je.disconnect(),window.removeEventListener("resize",_e),window.removeEventListener("orientationchange",_e),clearTimeout(Ue),Ye?.remove();},replay(){ve=-1,Ve=-1,qe=-1,ye=false,ie=false,Te=0,ue=false,Me.clear(),clearTimeout(Ae),We();},pause(){ue=true,cancelAnimationFrame(ae);},resume(){ue&&(ue=false,ze&&(ae=requestAnimationFrame(Be)));},seek(s){let m=Math.min(1,Math.max(0,s));$e=m,ve=m,ue=true,cancelAnimationFrame(ae),Et(m,S);},getProgress(){return $e}}}var lt=new Map;function Pe(e,n){lt.set(e,n);}function Le(e){lt.delete(e);}function Nt(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 i=[],o=[],l=t[2].trim();if(l)for(let u of l.split(/[\s,]+/)){let c=u.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(c?parseFloat(c[1]):0),o.push(c?c[2]:"");}n.push({fn:t[1],nums:i,units:o});}return n}function It(e,n,r){let t=ct(e),i=ct(n);return t.length===0||t.length!==i.length?r<1?e:n:t.map((o,l)=>{let u=i[l];return o.fn!==u.fn||o.nums.length!==u.nums.length?r<1?`${o.fn}(${o.nums.map((c,y)=>`${c}${o.units[y]}`).join(", ")})`:`${u.fn}(${u.nums.map((c,y)=>`${c}${u.units[y]}`).join(", ")})`:`${o.fn}(${o.nums.map((c,y)=>`${c+(u.nums[y]-c)*r}${o.units[y]}`).join(", ")})`}).join(" ")}function ut(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),i=String(n);if(Nt(t))return Oe(t,i,r);if(t.includes("("))return It(t,i,r);let o=t.match(/^([-+]?[\d.]+)(.*)$/),l=i.match(/^([-+]?[\d.]+)(.*)$/);if(o&&l){let u=parseFloat(o[1]),c=parseFloat(l[1]);return `${u+(c-u)*r}${o[2]||l[2]}`}return r<1?t:i}function Ot(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"},Rt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Ft=0;function Dt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function ft(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:i={},easing:o="ease-out",speed:l=1,once:u=false,axis:c="y",scrollContainer:y,native:L=true,velocityScale:C=false,onProgress:S,onComplete:U,onEnter:de,onLeave:F,onEnterBack:_,onLeaveBack:H}=n,G=window.matchMedia("(prefers-reduced-motion: reduce)").matches,x=typeof o=="function"?o:re[o]??re["ease-out"],M=ne(i.start??"top bottom"),P=ne(i.end??"bottom top"),p=typeof y=="string"?document.querySelector(y):y??null,v=Object.entries(t).map(([a,g])=>({prop:Ot(a),from:Array.isArray(g)?g[0]:"",to:Array.isArray(g)?g[1]:g}));function N(){let a=window.getComputedStyle(e);for(let g of v)g.from===""&&(g.from=a.getPropertyValue(g.prop).trim()||"0");}function I(){for(let a of v)e.style.setProperty(a.prop,String(a.to));}if(G)return I(),U?.(),r;N();function E(){if(!L||!Dt()||typeof o!="string"||!(o in mt)||c!=="y"||p||u||l!==1||S||U||de||F||_||H||C!==false||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return false;for(let a of v)if(!Rt.has(a.prop))return false;return true}function J(){let a=`ssd-a-${++Ft}`,g=v.map(V=>`${V.prop}:${V.from}`).join(";"),z=v.map(V=>`${V.prop}:${V.to}`).join(";"),se=document.createElement("style");se.setAttribute("data-ssd-animate",""),se.textContent=`@keyframes ${a}{from{${g}}to{${z}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${mt[o]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(se),e.classList.add(a);let O=()=>c==="x"?window.scrollX:window.scrollY,B=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),se.remove();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(V){let le=Math.min(1,Math.max(0,V));e.classList.remove(a);for(let ce of v)e.style.setProperty(ce.prop,ut(ce.from,ce.to,le));},getProgress(){let V=e.getBoundingClientRect(),le=O(),ce=B(),{tStart:ie,tEnd:ye}=pe({top:V.top,height:V.height},le,ce,M,P);return x(Z(le,ie,ye,l))}}}if(E())return J();let T=0,R=0,D=0,K=false,X=false,d=-1,$=0,b=false,h=NaN,Y=-1,Se=0,xe=()=>p?c==="x"?p.scrollLeft:p.scrollTop:c==="x"?window.scrollX:window.scrollY,be=()=>p?c==="x"?p.clientWidth:p.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function we(){let a=e.getBoundingClientRect(),g,z;if(p){let O=p.getBoundingClientRect();g=c==="x"?a.left-O.left+p.scrollLeft:a.top-O.top+p.scrollTop,z=c==="x"?a.width:a.height;}else g=c==="x"?a.left:a.top,z=c==="x"?a.width:a.height;let se=pe({top:g,height:z},xe(),be(),M,P);T=se.tStart,R=se.tEnd;}function Ce(a){e.style.setProperty("--scroll-draw-progress",String(a));for(let g of v)e.style.setProperty(g.prop,ut(g.from,g.to,a));S?.(a);}function He(a){if(isNaN(h)){h=a;return}h<=0&&a>0?de?.():h>0&&a<=0&&H?.(),h<1&&a>=1?F?.():h>=1&&a<1&&_?.(),h=a;}function oe(){if(!K||X)return;let a=performance.now(),g=xe(),z=l;if(C!==false){let B=a-Se,V=B>0?Math.abs(g-(Y<0?g:Y))/B:0;z=l*Math.max(.2,1+V*(typeof C=="number"?C:1)*.04);}Y=g,Se=a;let se=R===T?0:(g-T)/(R-T);He(se);let O=x(Z(g,T,R,z));u&&(d=Math.max(d,O),O=d),$=O,Ce(O),O>=1&&!b?(b=true,U?.()):O<1&&!u&&(b=false),D=requestAnimationFrame(oe);}we();{let a=x(Z(xe(),T,R,l));u&&a>0&&(d=a),$=a,Ce(a);}let ge=new IntersectionObserver(a=>{a.forEach(g=>{K=g.isIntersecting,K&&!X?D=requestAnimationFrame(oe):cancelAnimationFrame(D);});},{root:p??null}),ee;function te(){clearTimeout(ee),ee=setTimeout(we,150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),ge.observe(e),Pe(e,{type:"animate",getProgress:()=>$,getTrigger:()=>({tStart:T,tEnd:R})}),{destroy(){cancelAnimationFrame(D),ge.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(ee),Le(e);},replay(){d=-1,b=false,$=0,X=false,Ce(0);},pause(){X=true,cancelAnimationFrame(D);},resume(){X&&(X=false,K&&(D=requestAnimationFrame(oe)));},seek(a){let g=Math.min(1,Math.max(0,a));$=g,d=g,X=true,cancelAnimationFrame(D),Ce(g);},getProgress(){return $}}}var Ze={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function pt(e,n){if(typeof window>"u")return Ze;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),Ze;let t=r,{from:i=0,to:o,format:l,easing:u="ease-out",trigger:c={},once:y=true,decimals:L,onComplete:C}=n,S=L!==void 0?d=>d.toFixed(L):l??(d=>String(Math.round(d))),U=typeof u=="function"?u:re[u]??re["ease-out"],de=ne(c.start??"top 80%"),F=ne(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=S(o),C?.(),Ze;t.textContent=S(i);let H=0,G=0,x=0,M=false,P=false,p=-1,v=0,N=false,I=()=>window.scrollY,E=()=>window.innerHeight;function J(){let d=t.getBoundingClientRect(),$=pe({top:d.top,height:d.height},I(),E(),de,F);H=$.tStart,G=$.tEnd;}function T(d){t.textContent=S(i+(o-i)*d),t.style.setProperty("--scroll-draw-progress",String(d));}function R(){if(!M||P)return;let d=U(Z(I(),H,G,1));y&&(p=Math.max(p,d),d=p),v=d,T(d),d>=1&&!N?(N=true,C?.()):d<1&&!y&&(N=false),x=requestAnimationFrame(R);}J();{let d=U(Z(I(),H,G,1));y&&d>0&&(p=d),v=d,T(d);}let D=new IntersectionObserver(d=>{d.forEach($=>{M=$.isIntersecting,M&&!P?x=requestAnimationFrame(R):cancelAnimationFrame(x);});}),K;function X(){clearTimeout(K),K=setTimeout(J,150);}return window.addEventListener("resize",X),window.addEventListener("orientationchange",X),D.observe(t),Pe(t,{type:"counter",getProgress:()=>v,getTrigger:()=>({tStart:H,tEnd:G})}),{destroy(){cancelAnimationFrame(x),D.disconnect(),window.removeEventListener("resize",X),window.removeEventListener("orientationchange",X),clearTimeout(K),Le(t);},replay(){p=-1,N=false,v=0,P=false,T(0);},pause(){P=true,cancelAnimationFrame(x);},resume(){P&&(P=false,M&&(x=requestAnimationFrame(R)));},seek(d){let $=Math.min(1,Math.max(0,d));v=$,p=$,P=true,cancelAnimationFrame(x),T($);},getProgress(){return v}}}var dt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function gt(e,n={}){if(typeof window>"u")return dt;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollVideo: <video> element not found:",e),dt;let t=r,{trigger:i={},easing:o="linear",once:l=false,axis:u="y",preload:c="auto",onReady:y,onComplete:L,onProgress:C}=n,S=window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=typeof o=="function"?o:re[o]??re.linear,de=ne(i.start??"top top"),F=ne(i.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=c);let _=n.from??0,H=n.to,G=0,x=0,M=0,P=false,p=false,v=-1,N=0,I=false,E=false,J=()=>u==="x"?window.scrollX:window.scrollY,T=()=>u==="x"?window.innerWidth:window.innerHeight;function R(){let h=t.getBoundingClientRect(),Y=u==="x"?h.left:h.top,Se=u==="x"?h.width:h.height,xe=pe({top:Y,height:Se},J(),T(),de,F);G=xe.tStart,x=xe.tEnd;}function D(h){if(!E)return;let Y=H??t.duration??0;t.currentTime=_+(Y-_)*h,t.style.setProperty("--scroll-draw-progress",String(h)),C?.(h);}function K(){if(!P||p||!E)return;let h=U(Z(J(),G,x,1));l&&(v=Math.max(v,h),h=v),N=h,D(h),h>=1&&!I?(I=true,L?.()):h<1&&!l&&(I=false),M=requestAnimationFrame(K);}function X(){if(E=true,H===void 0&&(H=t.duration),S){D(1),y?.();return}R(),y?.(),P&&!p&&(M=requestAnimationFrame(K));}t.readyState>=1?X():t.addEventListener("loadedmetadata",X,{once:true}),E||R();let d=new IntersectionObserver(h=>{h.forEach(Y=>{P=Y.isIntersecting,P&&!p&&E?M=requestAnimationFrame(K):cancelAnimationFrame(M);});}),$;function b(){clearTimeout($),$=setTimeout(R,150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),d.observe(t),Pe(t,{type:"video",getProgress:()=>N,getTrigger:()=>({tStart:G,tEnd:x})}),{destroy(){cancelAnimationFrame(M),d.disconnect(),t.removeEventListener("loadedmetadata",X),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout($),Le(t);},replay(){v=-1,I=false,N=0,p=false,D(0);},pause(){p=true,cancelAnimationFrame(M);},resume(){p&&(p=false,P&&E&&(M=requestAnimationFrame(K)));},seek(h){let Y=Math.min(1,Math.max(0,h));N=Y,v=Y,p=true,cancelAnimationFrame(M),D(Y);},getProgress(){return N}}}function bt(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 Ht(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 yt(e){let n=bt(e),r=new Map;for(let o of n){let l=o.offsetTop;r.has(l)||r.set(l,[]),r.get(l).push(o);}let t=[],i=Array.from(r.keys()).sort((o,l)=>o-l);for(let o of i){let l=r.get(o),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block";for(let c of l)u.appendChild(c);t.push(u);}e.textContent="";for(let o of t)e.appendChild(o),e.appendChild(document.createTextNode(" "));return t}function zt(e,n,r,t){if(r<=1||t===0)return e;let i=(r-1)*t,o=n*t,l=o+(1-i);return l<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(l-o)))}function Vt(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 ht={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function wt(e,n={}){if(typeof window>"u")return ht;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),ht;let t=r,{split:i="words",stagger:o=.04,easing:l="ease-out",from:u={opacity:0,y:24},trigger:c={},once:y=true,onComplete:L}=n,C=window.matchMedia("(prefers-reduced-motion: reduce)").matches,S=typeof l=="function"?l:re[l]??re["ease-out"],U=ne(c.start??"top 85%"),de=ne(c.end??"top 40%"),F=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let _;i==="chars"?_=Ht(t):i==="lines"?_=yt(t):_=bt(t);let H=_.length;function G(b,h){u?.opacity!==void 0&&(b.style.opacity=String(u.opacity+(1-u.opacity)*h));let Y=Vt(h,u);Y&&(b.style.transform=Y);}function x(b){t.style.setProperty("--scroll-draw-progress",String(b)),_.forEach((h,Y)=>{let Se=S(zt(b,Y,H,o));G(h,Se);});}if(C)return x(1),L?.(),{destroy(){t.innerHTML=F,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};x(0);let M=0,P=0,p=0,v=false,N=false,I=-1,E=0,J=false,T=()=>window.scrollY,R=()=>window.innerHeight;function D(){let b=t.getBoundingClientRect(),h=pe({top:b.top,height:b.height},T(),R(),U,de);M=h.tStart,P=h.tEnd;}function K(){if(!v||N)return;let b=Z(T(),M,P,1);y&&(I=Math.max(I,b),b=I),E=b,x(b),b>=1&&!J?(J=true,L?.()):b<1&&!y&&(J=false),p=requestAnimationFrame(K);}D();let X=new IntersectionObserver(b=>{b.forEach(h=>{v=h.isIntersecting,v&&!N?p=requestAnimationFrame(K):cancelAnimationFrame(p);});}),d;function $(){clearTimeout(d),d=setTimeout(()=>{if(i==="lines"){let b=E;t.innerHTML=F,t.setAttribute("aria-label",t.textContent??""),_=yt(t),x(b);}D();},150);}return window.addEventListener("resize",$),window.addEventListener("orientationchange",$),X.observe(t),Pe(t,{type:"text",getProgress:()=>E,getTrigger:()=>({tStart:M,tEnd:P})}),{destroy(){cancelAnimationFrame(p),X.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),clearTimeout(d),t.innerHTML=F,t.removeAttribute("aria-label"),Le(t);},replay(){I=-1,J=false,E=0,N=false,x(0);},pause(){N=true,cancelAnimationFrame(p);},resume(){N&&(N=false,v&&(p=requestAnimationFrame(K)));},seek(b){let h=Math.min(1,Math.max(0,b));E=h,I=h,N=true,cancelAnimationFrame(p),x(h);},getProgress(){return E}}}function Bt(e,n={}){let[r,t]=_t.useState(0),i=_t.useRef(n);i.current=n;let o=_t.useRef(-1);return _t.useEffect(()=>{if(typeof window>"u")return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t(1);return}let l=typeof e=="string"?document.querySelector(e):e.current;if(!l)return;let u=l,{axis:c="y",scrollContainer:y,trigger:L={}}=i.current,C=typeof y=="string"?document.querySelector(y):y??null,S=ne(L.start??"top bottom"),U=ne(L.end??"bottom top"),de=0,F=0,_=false,H=0;function G(){return C?c==="x"?C.scrollLeft:C.scrollTop:c==="x"?window.scrollX:window.scrollY}function x(){return C?c==="x"?C.clientWidth:C.clientHeight:c==="x"?window.innerWidth:window.innerHeight}function M(){let I=u.getBoundingClientRect(),E=G(),J=c==="x"?I.left:I.top,T=c==="x"?I.width:I.height,R=pe({top:J,height:T},E,x(),S,U);de=R.tStart,F=R.tEnd;}function P(){if(!_)return;let{speed:I=1,easing:E="linear",once:J=false}=i.current,T=typeof E=="function"?E:re[E]??re.linear,R=Z(G(),de,F,I),D=T(R);J&&(o.current=Math.max(o.current,D),D=o.current),t(D),H=requestAnimationFrame(P);}let p=new IntersectionObserver(I=>{I.forEach(E=>{_=E.isIntersecting,_?H=requestAnimationFrame(P):cancelAnimationFrame(H);});},{root:C??null,threshold:0});M(),p.observe(u);let v;function N(){clearTimeout(v),v=setTimeout(M,150);}return window.addEventListener("resize",N),window.addEventListener("orientationchange",N),()=>{cancelAnimationFrame(H),clearTimeout(v),p.disconnect(),window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N);}},[]),r}function br({children:e,className:n,style:r,...t}){let i=_t.useRef(null);return _t.useEffect(()=>{if(!i.current)return;let o=at(i.current,t);return ()=>o.destroy()},[]),jsxRuntime.jsx("div",{ref:i,className:n,style:r,children:e})}function wr({children:e,className:n,style:r,...t}){let i=_t.useRef(null);return _t.useEffect(()=>{if(!i.current)return;let o=ft(i.current,t);return ()=>o.destroy()},[]),jsxRuntime.jsx("div",{ref:i,className:n,style:r,children:e})}function vr({className:e,style:n,...r}){let t=_t.useRef(null);return _t.useEffect(()=>{if(!t.current)return;let i=pt(t.current,r);return ()=>i.destroy()},[]),jsxRuntime.jsx("span",{ref:t,className:e,style:n})}function Er({src:e,className:n,style:r,muted:t=true,playsInline:i=true,...o}){let l=_t.useRef(null);return _t.useEffect(()=>{if(!l.current)return;let u=gt(l.current,o);return ()=>u.destroy()},[]),jsxRuntime.jsx("video",{ref:l,src:e,className:n,style:r,muted:t,playsInline:i,preload:"auto"})}function Sr({children:e,as:n="p",className:r,style:t,...i}){let o=_t.useRef(null);return _t.useEffect(()=>{if(!o.current)return;let l=wt(o.current,i);return ()=>l.destroy()},[]),_t__default.default.createElement(n,{ref:o,className:r,style:t},e)}exports.ScrollAnimate=wr;exports.ScrollCounter=vr;exports.ScrollDraw=br;exports.ScrollText=Sr;exports.ScrollVideo=Er;exports.useScrollDrawProgress=Bt;
|
|
1
|
+
'use strict';var ur=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ur__default=/*#__PURE__*/_interopDefault(ur);function Vt({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),o=0,a=[];for(let f=0;f<r;f++){let E=Math.pow(s,f);a.push(E),o+=E;}let u=[0],m=0;for(let f=0;f<r;f++)m+=a[f]/o,u.push(m);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let E=0;E<r;E++)if(f<=u[E+1]){let R=(f-u[E])/(u[E+1]-u[E]);if(E===0)return R*(2-R);let L=1-Math.pow(t,E);return L+(1-L)*(2*R-1)*(2*R-1)}return 1}}function _t({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 o=>o<=0?0:o>=1?1:r*Math.pow(2,-10*o)*Math.sin((o-s)*(2*Math.PI)/t)+1}var Q={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Vt(),elastic:_t()};function ne(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 gt(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 yt(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function Ve(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function qt(e,n,r){return Math.min(r,Math.max(n,e))}function Z(e,n,r,t){return r===n?0:qt((e-n)/(r-n)*t,0,1)}function Je(e,n,r){let t=e.getBoundingClientRect(),s=r==="x"?t.width:t.height;return n?{top:r==="x"?t.left-n.getBoundingClientRect().left+n.scrollLeft:t.top-n.getBoundingClientRect().top+n.scrollTop,height:s,scroll:0}:{top:r==="x"?t.left:t.top,height:s,scroll:r==="x"?window.scrollX:window.scrollY}}function ye(e,n,r,t,s){let o=gt(e.top,e.height,n,t.element)-yt(t.viewport,r),a=gt(e.top,e.height,n,s.element)-yt(s.viewport,r);return {tStart:o,tEnd:a}}function ht(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 _e(e,n,r){let t=ht(e),s=ht(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 bt={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}};var Ke=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function he(e,...n){Ke&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var Wt="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Bt="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",wt=33;function Gt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Ut(e){let n=[];for(let r=0;r<wt;r++){let t=r/(wt-1);n.push(String(Math.round(e(t)*1e5)/1e5));}return `linear(${n.join(",")})`}function et(e){switch(e){case "linear":return "linear";case "ease-in":return Wt;case "ease-out":return Bt;case "ease-in-out":return Gt()?Ut(Q["ease-in-out"]):null;default:return null}}var jt=0;function Xt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function Yt(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?he("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&he("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Qt(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 o=r==="x"?window.scrollX:window.scrollY,a=e-o,u=n-o,m=r==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${m?`left:${a}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${a}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;${m?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",s,{passive:true}),s(),{el:t,destroy(){window.removeEventListener("scroll",s),t.remove();}}}var vt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,St=/[MmLlHhVvCcSsQqTtAaZz]/g;function Zt(e,n,r){if(!Ke)return;let t=(e.match(St)??[]).join("").toUpperCase(),s=(n.match(St)??[]).join("").toUpperCase(),o=(e.match(vt)??[]).length,a=(n.match(vt)??[]).length;if(t!==s){he(`morphTo: command sequence differs (${t||"\u2205"} \u2192 ${s||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}o!==a&&he(`morphTo: coordinate count differs (${o} \u2192 ${a}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function it(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),s=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,o=>{let a=parseFloat(o),u=t[s++]??a;return String(+(a+(u-a)*r).toFixed(4))})}function Et(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,s=r?{...bt[r],...t}:t,o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:a="path, polyline, line, polygon, rect, circle",speed:u=1,fade:m=false,easing:f="linear",trigger:E={},stagger:R=0,direction:L="forward",once:te=false,debug:be=false,axis:N="y",scrollContainer:q,autoReverse:F=false,delay:H=0,strokeColor:M,strokeWidth:C,fillOpacity:A,waypoints:w,velocityScale:$=false,threshold:k=0,rootMargin:v="0px",repeat:y=0,repeatDelay:G=0,morphTo:I,clip:W,autoplay:U=false,duration:oe=1e3,native:me=true,onProgress:h,onStart:P,onComplete:g,onEnter:d,onLeave:z,onEnterBack:de,onLeaveBack:Ee}=s,fe=W===true?"left":typeof W=="string"?W:false,Te=typeof f=="function"?f:Q[f]??Q.linear,Pe=ne(E.start??"top bottom"),He=ne(E.end??"bottom top"),we=typeof q=="string"?document.querySelector(q):q??null,ve=Array.isArray(M)?M[0]:null,ie=Array.isArray(M)?M[1]:typeof M=="string"?M:null,ae=Array.isArray(C)?C[0]:null,J=Array.isArray(C)?C[1]:typeof C=="number"?C:null,pe=Array.isArray(A)?A[0]:null,re=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function Le(i){let c=i*100;switch(fe){case "right":return `inset(0 0 0 ${100-c}%)`;case "top":return `inset(0 0 ${100-c}% 0)`;case "bottom":return `inset(${100-c}% 0 0 0)`;case "center":return `circle(${i*150}% at 50% 50%)`;default:return `inset(0 ${100-c}% 0 0)`}}let B=fe?[]:Array.from(e.querySelectorAll(a)),O=[],l=[],p=0,Se=0,V=false,j=false,X=0,K=false,le=-1,Ce=-1,se=false,xe=0,Re=0,Ie,rt=null;function lt(){rt?.destroy(),rt=null;}let Oe=new Set,ct=NaN,Fe=true,Ue=-1,ut=performance.now(),ze=NaN;function nt(){return we?N==="x"?we.scrollLeft:we.scrollTop:N==="x"?window.scrollX:window.scrollY}function mt(){return we?N==="x"?we.clientWidth:we.clientHeight:N==="x"?window.innerWidth:window.innerHeight}function ft(){let i=Je(e,we,N),c=ye(i,i.scroll,mt(),Pe,He);p=c.tStart,Se=c.tEnd,be&&Ke&&(lt(),rt=Qt(p,Se,N));}function Dt(i,c){if(e.style.setProperty("--scroll-draw-progress",String(i)),fe){let T=c==="reverse"?1-i:i;e.style.clipPath=Le(T);return}B.forEach((T,ce)=>{T.style.strokeDashoffset=c==="reverse"?`${O[ce]*i}`:`${O[ce]*(1-i)}`,m&&(T.style.opacity=c==="reverse"?`${1-i}`:`${i}`),ve&&ie?T.style.stroke=_e(ve,ie,i):ie&&(T.style.stroke=ie),ae!==null&&J!==null?T.style.strokeWidth=`${ae+(J-ae)*i}`:J!==null&&(T.style.strokeWidth=`${J}`),pe!==null&&re!==null?T.style.fillOpacity=`${pe+(re-pe)*i}`:re!==null&&(T.style.fillOpacity=`${re}`),I&&T.tagName.toLowerCase()==="path"&&l[ce]&&T.setAttribute("d",it(l[ce],I,i));});}function je(){if(e.style.setProperty("--scroll-draw-progress","0"),fe){e.style.clipPath=Le(0);return}B.forEach((i,c)=>{i.style.strokeDasharray=`${O[c]}`,i.style.strokeDashoffset=L==="reverse"?"0":`${O[c]}`,m?i.style.opacity=L==="reverse"?"1":"0":i.style.opacity="",ve&&(i.style.stroke=ve),ae!==null&&(i.style.strokeWidth=`${ae}`),pe!==null&&(i.style.fillOpacity=`${pe}`),I&&i.tagName.toLowerCase()==="path"&&l[c]&&i.setAttribute("d",l[c]);});}if(B.forEach(i=>{Yt(i);let c=Ve(i);O.push(c);let T=i.tagName.toLowerCase()==="path";T?l.push(i.getAttribute("d")??""):l.push(""),I&&(T?Zt(l[l.length-1],I,i):he(`morphTo only applies to <path> elements \u2014 ignored on <${i.tagName}>.`,i)),o?(i.style.strokeDasharray=`${c}`,i.style.strokeDashoffset=L==="reverse"?`${c}`:"0",m&&(i.style.opacity="1"),ie&&(i.style.stroke=ie),J!==null&&(i.style.strokeWidth=`${J}`),re!==null&&(i.style.fillOpacity=`${re}`),I&&i.tagName.toLowerCase()==="path"&&i.setAttribute("d",I)):(i.style.strokeDasharray=`${c}`,i.style.strokeDashoffset=L==="reverse"?"0":`${c}`,m?i.style.opacity=L==="reverse"?"1":"0":i.style.opacity="",ve&&(i.style.stroke=ve),ae!==null&&(i.style.strokeWidth=`${ae}`),pe!==null&&(i.style.fillOpacity=`${pe}`));}),fe){if(o)return e.style.clipPath=Le(1),g?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=Le(0);}else if(o)return g?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let pt=typeof f=="string"?et(f):null;function Nt(){return !(me===false||!Xt()||!B.length||!pt||fe||N!=="y"||we||u!==1||R!==0||te||F||$!==false||I||w||y||H>0||h||P||g||d||z||de||Ee||M!=null||C!=null||A!=null||(E.start??"top bottom").trim()!=="top bottom"||(E.end??"bottom top").trim()!=="bottom top")}function Ht(){let i=++jt,c=`svg-scroll-draw-${i}`,T=`svg-scroll-draw-host-${i}`,ce=`--svg-scroll-draw-${i}`,ke=L==="reverse"?"0":"var(--ssd-len)",$e=L==="reverse"?"var(--ssd-len)":"0",Me=`stroke-dashoffset:${ke};`,x=`stroke-dashoffset:${$e};`;m&&(Me+=`opacity:${L==="reverse"?1:0};`,x+=`opacity:${L==="reverse"?0:1};`);let D=document.createElement("style");D.setAttribute("data-svg-scroll-draw",""),D.textContent=`@keyframes ${c}{from{${Me}}to{${x}}}.${T}{view-timeline-name:${ce};view-timeline-axis:block;}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${pt};animation-fill-mode:both;animation-timeline:${ce};animation-range:cover 0% cover 100%;}`,document.head.appendChild(D),e.classList.add(T);function ue(b,ee){b.style.setProperty("--ssd-len",String(O[ee])),b.style.strokeDasharray=`${O[ee]}`,b.style.strokeDashoffset="",b.style.opacity="",b.style.animationPlayState="",b.classList.add(c);}B.forEach(ue);let S=false,_=-1;function Y(){if(_>=0)return _;let b=e.getBoundingClientRect(),{tStart:ee,tEnd:Ae}=ye({top:b.top,height:b.height},nt(),mt(),Pe,He);return Te(Z(nt(),ee,Ae,u))}return {destroy(){e.classList.remove(T),B.forEach(b=>{b.classList.remove(c),b.style.removeProperty("--ssd-len"),b.style.animationPlayState="";}),D.remove();},replay(){S=false,_=-1,B.forEach(ue);},pause(){S=true,B.forEach(b=>{b.style.animationPlayState="paused";});},resume(){S&&(S=false,B.forEach(b=>{b.style.animationPlayState="running";}));},seek(b){let ee=Math.min(1,Math.max(0,b));_=ee,S=true,B.forEach((Ae,ge)=>{Ae.classList.remove(c),Ae.style.strokeDashoffset=L==="reverse"?`${O[ge]*ee}`:`${O[ge]*(1-ee)}`,m&&(Ae.style.opacity=L==="reverse"?`${1-ee}`:`${ee}`);});},getProgress(){return Y()},refresh(){B.forEach((b,ee)=>{O[ee]=Ve(b),b.style.setProperty("--ssd-len",String(O[ee])),b.style.strokeDasharray=`${O[ee]}`;});}}}if(Nt())return Ht();function zt(){let i=Math.max(1,oe),c=0,T=0,ce=false;function ke(S){let _=true;if(fe){let Y=Math.min(1,Math.max(0,S/i)),b=Te(Y);xe=b,e.style.setProperty("--scroll-draw-progress",String(b)),e.style.clipPath=Le(L==="reverse"?1-b:b),h?.(b),Y<1&&(_=false);}else B.forEach((Y,b)=>{let ee=b*R*i,Ae=Math.min(1,Math.max(0,(S-ee)/i)),ge=Te(Ae);Y.style.strokeDashoffset=L==="reverse"?`${O[b]*ge}`:`${O[b]*(1-ge)}`,m&&(Y.style.opacity=L==="reverse"?`${1-ge}`:`${ge}`),ve&&ie?Y.style.stroke=_e(ve,ie,ge):ie&&(Y.style.stroke=ie),ae!==null&&J!==null?Y.style.strokeWidth=`${ae+(J-ae)*ge}`:J!==null&&(Y.style.strokeWidth=`${J}`),pe!==null&&re!==null?Y.style.fillOpacity=`${pe+(re-pe)*ge}`:re!==null&&(Y.style.fillOpacity=`${re}`),I&&Y.tagName.toLowerCase()==="path"&&l[b]&&Y.setAttribute("d",it(l[b],I,ge)),b===0&&(xe=ge,h?.(ge),e.style.setProperty("--scroll-draw-progress",String(ge))),Ae<1&&(_=false);});if(w){let Y=Math.min(1,Math.max(0,S/i)),b=Te(Y);for(let ee in w){let Ae=parseFloat(ee);b>=Ae&&!Oe.has(Ae)&&(Oe.add(Ae),w[ee]?.());}}return _}function $e(S){if(se)return;let _=S-c;j||(j=true,P?.());let Y=ke(_);if(Y&&!V){V=true,ke(i*(1+Math.max(0,B.length-1)*R)),g?.(),Re<(y==="infinite"?1/0:y??0)&&(Re++,Ie=setTimeout(()=>{c=performance.now(),j=false,V=false,Oe.clear(),je(),X=requestAnimationFrame($e);},G));return}Y||(X=requestAnimationFrame($e));}function Me(){cancelAnimationFrame(X),clearTimeout(Ie),c=performance.now(),T=0,se=false,j=false,V=false,Re=0,ce=true,xe=0,Oe.clear(),je(),X=requestAnimationFrame($e);}let x=new IntersectionObserver(S=>{S.forEach(_=>{_.isIntersecting&&!(te&&V)?Me():!_.isIntersecting&&!te&&!V&&(cancelAnimationFrame(X),clearTimeout(Ie),ce=false);});},{root:we??null,threshold:k,rootMargin:v}),D;function ue(){clearTimeout(D),D=setTimeout(()=>{B.forEach((S,_)=>{O[_]=Ve(S),S.style.strokeDasharray=`${O[_]}`;});},150);}return window.addEventListener("resize",ue),window.addEventListener("orientationchange",ue),H>0?setTimeout(()=>x.observe(e),H):x.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(Ie),x.disconnect(),window.removeEventListener("resize",ue),window.removeEventListener("orientationchange",ue),clearTimeout(D);},replay(){Re=0,Me();},pause(){se||!ce||(se=true,T=performance.now()-c,cancelAnimationFrame(X));},resume(){se&&(se=false,ce=true,c=performance.now()-T,X=requestAnimationFrame($e));},seek(S){let _=Math.min(1,Math.max(0,S));xe=_,se=true,T=_*i,c=performance.now()-T,cancelAnimationFrame(X),ke(T);},getProgress(){return xe},refresh(){clearTimeout(D),B.forEach((S,_)=>{O[_]=Ve(S),S.style.strokeDasharray=`${O[_]}`;});}}}if(U)return zt();ft();function Xe(){if(!K||se)return;let i=performance.now(),c=nt();if(!Fe&&$===false&&c===ct){X=requestAnimationFrame(Xe);return}Fe=false,ct=c;let T=u;if($!==false){let x=i-ut,D=x>0?Math.abs(c-(Ue<0?c:Ue))/x:0;T=u*Math.max(.2,1+D*(typeof $=="number"?$:1)*.04);}Ue=c,ut=i;let ce=F?Ce===-1||c>=Ce?"forward":"reverse":L;Ce=c;let ke=Se-p,$e=true,Me=ke===0?0:(c-p)/ke;if(isNaN(ze)||(ze<=0&&Me>0?d?.():ze>0&&Me<=0&&Ee?.(),ze<1&&Me>=1?z?.():ze>=1&&Me<1&&de?.()),ze=Me,fe){let x=Te(Z(c,p,Se,T));te&&!F&&(le=Math.max(le,x),x=le),xe=x,e.style.setProperty("--scroll-draw-progress",String(x));let D=ce==="reverse"?1-x:x;e.style.clipPath=Le(D),h?.(x),!j&&Z(c,p,Se,T)>0&&(j=true,P?.()),x>=1&&!V?(V=true,g?.(),Re<(y==="infinite"?1/0:y??0)&&(Re++,Ie=setTimeout(()=>{le=-1,j=false,V=false,e.style.clipPath=Le(0);},G))):x<1&&!te&&(V=false),X=requestAnimationFrame(Xe);return}if(B.forEach((x,D)=>{let ue=D*R*ke,S=Te(Z(c,p+ue,Se+ue,T));te&&!F&&(le=Math.max(le,S),S=le),xe=S,x.style.strokeDashoffset=ce==="reverse"?`${O[D]*S}`:`${O[D]*(1-S)}`,m&&(x.style.opacity=ce==="reverse"?`${1-S}`:`${S}`),ve&&ie?x.style.stroke=_e(ve,ie,S):ie&&(x.style.stroke=ie),ae!==null&&J!==null?x.style.strokeWidth=`${ae+(J-ae)*S}`:J!==null&&(x.style.strokeWidth=`${J}`),pe!==null&&re!==null?x.style.fillOpacity=`${pe+(re-pe)*S}`:re!==null&&(x.style.fillOpacity=`${re}`),I&&x.tagName.toLowerCase()==="path"&&l[D]&&x.setAttribute("d",it(l[D],I,S)),D===0&&(h?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&($e=false);}),w){let x=Te(Z(c,p,Se,T));for(let D in w){let ue=parseFloat(D);x>=ue&&!Oe.has(ue)&&(Oe.add(ue),w[D]?.());}}!j&&Z(c,p,Se,T)>0&&(j=true,P?.()),$e&&!V?(V=true,g?.(),Re<(y==="infinite"?1/0:y??0)&&(Re++,Ie=setTimeout(()=>{le=-1,j=false,V=false,Oe.clear(),je(),Fe=true;},G))):!$e&&!te&&(V=false),X=requestAnimationFrame(Xe);}let ot=false;function Ye(){ot||(ot=true,X=requestAnimationFrame(function(){Xe();}));}function Qe(){ot=false,cancelAnimationFrame(X);}let st=new IntersectionObserver(i=>{i.forEach(c=>{K=c.isIntersecting,K&&!se?(Fe=true,Ye()):Qe();});},{root:we??null,threshold:k,rootMargin:v});function dt(){B.forEach((i,c)=>{O[c]=Ve(i),i.style.strokeDasharray=`${O[c]}`;}),ft(),Fe=true;}let Ze;function qe(){clearTimeout(Ze),Ze=setTimeout(dt,150);}window.addEventListener("resize",qe),window.addEventListener("orientationchange",qe);let We;return typeof ResizeObserver<"u"&&(We=new ResizeObserver(()=>qe()),We.observe(document.body),We.observe(document.documentElement),We.observe(e)),H>0?setTimeout(()=>st.observe(e),H):st.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(Ie),Qe(),st.disconnect(),We?.disconnect(),window.removeEventListener("resize",qe),window.removeEventListener("orientationchange",qe),clearTimeout(Ze),lt();},replay(){le=-1,Ce=-1,Ue=-1,j=false,V=false,Re=0,se=false,xe=0,Oe.clear(),clearTimeout(Ie),je(),Fe=true,K&&Ye();},pause(){se=true,Qe();},resume(){se&&(se=false,Fe=true,K&&Ye());},seek(i){let c=Math.min(1,Math.max(0,i));xe=c,le=c,se=true,Qe(),Dt(c,L),Fe=true;},getProgress(){return xe},refresh(){clearTimeout(Ze),dt(),K&&!se&&Ye();}}}var Tt=new Map;function De(e,n){Tt.set(e,n);}function Ne(e){Tt.delete(e);}function Jt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function xt(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let s=[],o=[],a=t[2].trim();if(a)for(let u of a.split(/[\s,]+/)){let m=u.match(/^([-+]?[\d.eE]+)(.*)$/);s.push(m?parseFloat(m[1]):0),o.push(m?m[2]:"");}n.push({fn:t[1],nums:s,units:o});}return n}function Kt(e,n,r){let t=xt(e),s=xt(n);return t.length===0||t.length!==s.length?r<1?e:n:t.map((o,a)=>{let u=s[a];return o.fn!==u.fn||o.nums.length!==u.nums.length?r<1?`${o.fn}(${o.nums.map((m,f)=>`${m}${o.units[f]}`).join(", ")})`:`${u.fn}(${u.nums.map((m,f)=>`${m}${u.units[f]}`).join(", ")})`:`${o.fn}(${o.nums.map((m,f)=>`${m+(u.nums[f]-m)*r}${o.units[f]}`).join(", ")})`}).join(" ")}function At(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),s=String(n);if(Jt(t))return _e(t,s,r);if(t.includes("("))return Kt(t,s,r);let o=t.match(/^([-+]?[\d.]+)(.*)$/),a=s.match(/^([-+]?[\d.]+)(.*)$/);if(o&&a){let u=parseFloat(o[1]),m=parseFloat(a[1]);return `${u+(m-u)*r}${o[2]||a[2]}`}return r<1?t:s}function er(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var tr=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),rr=0,Mt="--scroll-draw-progress";function nr(){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:s={},easing:o="ease-out",speed:a=1,once:u=false,axis:m="y",scrollContainer:f,native:E=true,velocityScale:R=false,respectReducedMotion:L=true,triggerElement:te,onProgress:be,onComplete:N,onEnter:q,onLeave:F,onEnterBack:H,onLeaveBack:M}=n,C=L&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,A=typeof o=="function"?o:Q[o]??Q["ease-out"],w=ne(s.start??"top bottom"),$=ne(s.end??"bottom top"),k=te??e,v=typeof f=="string"?document.querySelector(f):f??null,y=Object.entries(t).map(([l,p])=>({prop:er(l),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function G(){let l=window.getComputedStyle(e);for(let p of y)p.from===""&&(p.from=l.getPropertyValue(p.prop).trim()||"0");}function I(){for(let l of y)e.style.setProperty(l.prop,String(l.to));}let W=new Map;for(let l of [...y.map(p=>p.prop),Mt])W.set(l,e.style.getPropertyValue(l));function U(){for(let[l,p]of W)p?e.style.setProperty(l,p):e.style.removeProperty(l);}if(C)return I(),N?.(),{...r,destroy:U,getProgress:()=>1};G();let oe=typeof o=="string"?et(o):null;function me(){if(!E||!nr()||!oe||m!=="y"||v||k!==e||u||a!==1||be||N||q||F||H||M||R!==false||(s.start??"top bottom").trim()!=="top bottom"||(s.end??"bottom top").trim()!=="bottom top")return false;for(let l of y)if(!tr.has(l.prop))return false;return true}function h(){let l=`ssd-a-${++rr}`,p=y.map(K=>`${K.prop}:${K.from}`).join(";"),Se=y.map(K=>`${K.prop}:${K.to}`).join(";"),V=document.createElement("style");V.setAttribute("data-ssd-animate",""),V.textContent=`@keyframes ${l}{from{${p}}to{${Se}}}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${oe};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(V),e.classList.add(l);let j=()=>m==="x"?window.scrollX:window.scrollY,X=()=>m==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(l),V.remove(),e.style.animationPlayState="",U();},replay(){e.classList.remove(l),e.offsetWidth,e.classList.add(l);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(K){let le=Math.min(1,Math.max(0,K));e.classList.remove(l);for(let Ce of y)e.style.setProperty(Ce.prop,At(Ce.from,Ce.to,le));},getProgress(){let K=e.getBoundingClientRect(),le=j(),Ce=X(),{tStart:se,tEnd:xe}=ye({top:K.top,height:K.height},le,Ce,w,$);return A(Z(le,se,xe,a))}}}if(me())return h();let P=0,g=0,d=0,z=false,de=false,Ee=-1,fe=0,Te=false,Pe=NaN,He=-1,we=0,ve=()=>v?m==="x"?v.scrollLeft:v.scrollTop:m==="x"?window.scrollX:window.scrollY,ie=()=>v?m==="x"?v.clientWidth:v.clientHeight:m==="x"?window.innerWidth:window.innerHeight;function ae(){let l=Je(k,v,m),p=ye(l,l.scroll,ie(),w,$);P=p.tStart,g=p.tEnd;}function J(l){e.style.setProperty(Mt,String(l));for(let p of y)e.style.setProperty(p.prop,At(p.from,p.to,l));be?.(l);}function pe(l){if(isNaN(Pe)){Pe=l;return}Pe<=0&&l>0?q?.():Pe>0&&l<=0&&M?.(),Pe<1&&l>=1?F?.():Pe>=1&&l<1&&H?.(),Pe=l;}function re(){if(!z||de)return;let l=performance.now(),p=ve(),Se=a;if(R!==false){let X=l-we,K=X>0?Math.abs(p-(He<0?p:He))/X:0;Se=a*Math.max(.2,1+K*(typeof R=="number"?R:1)*.04);}He=p,we=l;let V=g===P?0:(p-P)/(g-P);pe(V);let j=A(Z(p,P,g,Se));u&&(Ee=Math.max(Ee,j),j=Ee),fe=j,J(j),j>=1&&!Te?(Te=true,N?.()):j<1&&!u&&(Te=false),d=requestAnimationFrame(re);}ae(),g===P&&he("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let l=A(Z(ve(),P,g,a));u&&l>0&&(Ee=l),fe=l,J(l);}let Le=new IntersectionObserver(l=>{l.forEach(p=>{z=p.isIntersecting,z&&!de?d=requestAnimationFrame(re):cancelAnimationFrame(d);});},{root:v??null}),B;function O(){clearTimeout(B),B=setTimeout(ae,150);}return window.addEventListener("resize",O),window.addEventListener("orientationchange",O),Le.observe(e),De(e,{type:"animate",getProgress:()=>fe,getTrigger:()=>({tStart:P,tEnd:g})}),{destroy(){cancelAnimationFrame(d),Le.disconnect(),window.removeEventListener("resize",O),window.removeEventListener("orientationchange",O),clearTimeout(B),U(),Ne(e);},replay(){Ee=-1,Te=false,fe=0,de=false,J(0);},pause(){de=true,cancelAnimationFrame(d);},resume(){de&&(de=false,z&&(d=requestAnimationFrame(re)));},seek(l){let p=Math.min(1,Math.max(0,l));fe=p,Ee=p,de=true,cancelAnimationFrame(d),J(p);},getProgress(){return fe}}}var at={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Lt(e,n){if(typeof window>"u")return at;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return he("scrollCounter: element not found:",e),at;let t=r,{from:s=0,to:o,format:a,easing:u="ease-out",trigger:m={},once:f=true,decimals:E,onComplete:R}=n,L=E!==void 0?h=>h.toFixed(E):a??(h=>String(Math.round(h))),te=typeof u=="function"?u:Q[u]??Q["ease-out"],be=ne(m.start??"top 80%"),N=ne(m.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=L(o),R?.(),at;let F=0,H=0,M=0,C=false,A=false,w=-1,$=0,k=false,v=()=>window.scrollY,y=()=>window.innerHeight;function G(){let h=t.getBoundingClientRect(),P=ye({top:h.top,height:h.height},v(),y(),be,N);F=P.tStart,H=P.tEnd;}function I(h){t.textContent=L(s+(o-s)*h),t.style.setProperty("--scroll-draw-progress",String(h));}function W(){if(!C||A)return;let h=te(Z(v(),F,H,1));f&&(w=Math.max(w,h),h=w),$=h,I(h),h>=1&&!k?(k=true,R?.()):h<1&&!f&&(k=false),M=requestAnimationFrame(W);}G();{let h=te(Z(v(),F,H,1));f&&h>0&&(w=h),$=h,I(h);}let U=new IntersectionObserver(h=>{h.forEach(P=>{C=P.isIntersecting,C&&!A?M=requestAnimationFrame(W):cancelAnimationFrame(M);});}),oe;function me(){clearTimeout(oe),oe=setTimeout(G,150);}return window.addEventListener("resize",me),window.addEventListener("orientationchange",me),U.observe(t),De(t,{type:"counter",getProgress:()=>$,getTrigger:()=>({tStart:F,tEnd:H})}),{destroy(){cancelAnimationFrame(M),U.disconnect(),window.removeEventListener("resize",me),window.removeEventListener("orientationchange",me),clearTimeout(oe),Ne(t);},replay(){w=-1,k=false,$=0,A=false,I(0);},pause(){A=true,cancelAnimationFrame(M);},resume(){A&&(A=false,C&&(M=requestAnimationFrame(W)));},seek(h){let P=Math.min(1,Math.max(0,h));$=P,w=P,A=true,cancelAnimationFrame(M),I(P);},getProgress(){return $}}}var Ct={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function $t(e,n={}){if(typeof window>"u")return Ct;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return he("scrollVideo: <video> element not found:",e),Ct;let t=r,{trigger:s={},easing:o="linear",once:a=false,axis:u="y",preload:m="auto",onReady:f,onComplete:E,onProgress:R}=n,L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,te=typeof o=="function"?o:Q[o]??Q.linear,be=ne(s.start??"top top"),N=ne(s.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=m);let q=n.from??0,F=n.to,H=0,M=0,C=0,A=false,w=false,$=-1,k=0,v=false,y=false,G=()=>u==="x"?window.scrollX:window.scrollY,I=()=>u==="x"?window.innerWidth:window.innerHeight;function W(){let d=t.getBoundingClientRect(),z=u==="x"?d.left:d.top,de=u==="x"?d.width:d.height,Ee=ye({top:z,height:de},G(),I(),be,N);H=Ee.tStart,M=Ee.tEnd;}function U(d){if(!y)return;let z=F??t.duration??0;t.currentTime=q+(z-q)*d,t.style.setProperty("--scroll-draw-progress",String(d)),R?.(d);}function oe(){if(!A||w||!y)return;let d=te(Z(G(),H,M,1));a&&($=Math.max($,d),d=$),k=d,U(d),d>=1&&!v?(v=true,E?.()):d<1&&!a&&(v=false),C=requestAnimationFrame(oe);}function me(){if(y=true,F===void 0&&(F=t.duration),L){U(1),f?.();return}W(),f?.(),A&&!w&&(C=requestAnimationFrame(oe));}t.readyState>=1?me():t.addEventListener("loadedmetadata",me,{once:true}),y||W();let h=new IntersectionObserver(d=>{d.forEach(z=>{A=z.isIntersecting,A&&!w&&y?C=requestAnimationFrame(oe):cancelAnimationFrame(C);});}),P;function g(){clearTimeout(P),P=setTimeout(W,150);}return window.addEventListener("resize",g),window.addEventListener("orientationchange",g),h.observe(t),De(t,{type:"video",getProgress:()=>k,getTrigger:()=>({tStart:H,tEnd:M})}),{destroy(){cancelAnimationFrame(C),h.disconnect(),t.removeEventListener("loadedmetadata",me),window.removeEventListener("resize",g),window.removeEventListener("orientationchange",g),clearTimeout(P),Ne(t);},replay(){$=-1,v=false,k=0,w=false,U(0);},pause(){w=true,cancelAnimationFrame(C);},resume(){w&&(w=false,A&&y&&(C=requestAnimationFrame(oe)));},seek(d){let z=Math.min(1,Math.max(0,d));k=z,$=z,w=true,cancelAnimationFrame(C),U(z);},getProgress(){return k}}}function It(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 or(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 Rt(e){let n=It(e),r=new Map;for(let o of n){let a=o.offsetTop;r.has(a)||r.set(a,[]),r.get(a).push(o);}let t=[],s=Array.from(r.keys()).sort((o,a)=>o-a);for(let o of s){let a=r.get(o),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block",a.forEach((m,f)=>{let E=m.nextElementSibling;u.appendChild(m),f<a.length-1&&E&&E.style.whiteSpace==="pre"&&u.appendChild(E);}),t.push(u);}return e.textContent="",t.forEach((o,a)=>{e.appendChild(o),a<t.length-1&&e.appendChild(document.createTextNode(" "));}),t}function sr(e,n,r,t){if(r<=1||t===0)return e;let s=(r-1)*t,o=n*t,a=o+(1-s);return a<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(a-o)))}function ir(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 kt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ot(e,n={}){if(typeof window>"u")return kt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return he("scrollText: element not found:",e),kt;let t=r,{split:s="words",stagger:o=.04,easing:a="ease-out",from:u={opacity:0,y:24},trigger:m={},once:f=true,onComplete:E}=n,R=window.matchMedia("(prefers-reduced-motion: reduce)").matches,L=typeof a=="function"?a:Q[a]??Q["ease-out"],te=ne(m.start??"top 85%"),be=ne(m.end??"top 40%"),N=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let q;s==="chars"?q=or(t):s==="lines"?q=Rt(t):q=It(t);let F=q.length;function H(g,d){u?.opacity!==void 0&&(g.style.opacity=String(u.opacity+(1-u.opacity)*d));let z=ir(d,u);z&&(g.style.transform=z);}function M(g){t.style.setProperty("--scroll-draw-progress",String(g)),q.forEach((d,z)=>{let de=L(sr(g,z,F,o));H(d,de);});}if(R)return M(1),E?.(),{destroy(){t.innerHTML=N,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};M(0);let C=0,A=0,w=0,$=false,k=false,v=-1,y=0,G=false,I=()=>window.scrollY,W=()=>window.innerHeight;function U(){let g=t.getBoundingClientRect(),d=ye({top:g.top,height:g.height},I(),W(),te,be);C=d.tStart,A=d.tEnd;}function oe(){if(!$||k)return;let g=Z(I(),C,A,1);f&&(v=Math.max(v,g),g=v),y=g,M(g),g>=1&&!G?(G=true,E?.()):g<1&&!f&&(G=false),w=requestAnimationFrame(oe);}U();let me=new IntersectionObserver(g=>{g.forEach(d=>{$=d.isIntersecting,$&&!k?w=requestAnimationFrame(oe):cancelAnimationFrame(w);});}),h;function P(){clearTimeout(h),h=setTimeout(()=>{if(s==="lines"){let g=y;t.innerHTML=N,t.setAttribute("aria-label",t.textContent??""),q=Rt(t),M(g);}U();},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),me.observe(t),De(t,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:C,tEnd:A})}),{destroy(){cancelAnimationFrame(w),me.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),clearTimeout(h),t.innerHTML=N,t.removeAttribute("aria-label"),Ne(t);},replay(){v=-1,G=false,y=0,k=false,M(0);},pause(){k=true,cancelAnimationFrame(w);},resume(){k&&(k=false,$&&(w=requestAnimationFrame(oe)));},seek(g){let d=Math.min(1,Math.max(0,g));y=d,v=d,k=true,cancelAnimationFrame(w),M(d);},getProgress(){return y}}}function cr(e,n={}){let[r,t]=ur.useState(0),s=ur.useRef(n);s.current=n;let o=ur.useRef(-1);return ur.useEffect(()=>{if(typeof window>"u")return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t(1);return}let a=typeof e=="string"?document.querySelector(e):e.current;if(!a)return;let u=a,{axis:m="y",scrollContainer:f,trigger:E={}}=s.current,R=typeof f=="string"?document.querySelector(f):f??null,L=ne(E.start??"top bottom"),te=ne(E.end??"bottom top"),be=0,N=0,q=false,F=0;function H(){return R?m==="x"?R.scrollLeft:R.scrollTop:m==="x"?window.scrollX:window.scrollY}function M(){return R?m==="x"?R.clientWidth:R.clientHeight:m==="x"?window.innerWidth:window.innerHeight}function C(){let v=u.getBoundingClientRect(),y=H(),G=m==="x"?v.left:v.top,I=m==="x"?v.width:v.height,W=ye({top:G,height:I},y,M(),L,te);be=W.tStart,N=W.tEnd;}function A(){if(!q)return;let{speed:v=1,easing:y="linear",once:G=false}=s.current,I=typeof y=="function"?y:Q[y]??Q.linear,W=Z(H(),be,N,v),U=I(W);G&&(o.current=Math.max(o.current,U),U=o.current),t(U),F=requestAnimationFrame(A);}let w=new IntersectionObserver(v=>{v.forEach(y=>{q=y.isIntersecting,q?F=requestAnimationFrame(A):cancelAnimationFrame(F);});},{root:R??null,threshold:0});C(),w.observe(u);let $;function k(){clearTimeout($),$=setTimeout(C,150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),()=>{cancelAnimationFrame(F),clearTimeout($),w.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k);}},[]),r}function Xr({children:e,className:n,style:r,...t}){let s=ur.useRef(null);return ur.useEffect(()=>{if(!s.current)return;let o=Et(s.current,t);return ()=>o.destroy()},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:r,children:e})}function Yr({children:e,className:n,style:r,...t}){let s=ur.useRef(null);return ur.useEffect(()=>{if(!s.current)return;let o=Pt(s.current,t);return ()=>o.destroy()},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:r,children:e})}function Qr({className:e,style:n,...r}){let t=ur.useRef(null);return ur.useEffect(()=>{if(!t.current)return;let s=Lt(t.current,r);return ()=>s.destroy()},[]),jsxRuntime.jsx("span",{ref:t,className:e,style:n})}function Zr({src:e,className:n,style:r,muted:t=true,playsInline:s=true,...o}){let a=ur.useRef(null);return ur.useEffect(()=>{if(!a.current)return;let u=$t(a.current,o);return ()=>u.destroy()},[]),jsxRuntime.jsx("video",{ref:a,src:e,className:n,style:r,muted:t,playsInline:s,preload:"auto"})}function Jr({children:e,as:n="p",className:r,style:t,...s}){let o=ur.useRef(null);return ur.useEffect(()=>{if(!o.current)return;let a=Ot(o.current,s);return ()=>a.destroy()},[]),ur__default.default.createElement(n,{ref:o,className:r,style:t},e)}exports.ScrollAnimate=Yr;exports.ScrollCounter=Qr;exports.ScrollDraw=Xr;exports.ScrollText=Jr;exports.ScrollVideo=Zr;exports.useScrollDrawProgress=cr;
|
package/dist/react/index.d.mts
CHANGED
|
@@ -132,6 +132,33 @@ interface ScrollAnimateOptions {
|
|
|
132
132
|
* Higher values = more dramatic speed-up. Default sensitivity: 1.
|
|
133
133
|
*/
|
|
134
134
|
velocityScale?: boolean | number;
|
|
135
|
+
/**
|
|
136
|
+
* Honour `prefers-reduced-motion: reduce` by applying the final state and not
|
|
137
|
+
* animating. Default: `true`.
|
|
138
|
+
*
|
|
139
|
+
* Set to `false` only when the movement is *scroll-linked scrubbing* rather
|
|
140
|
+
* than autonomous motion — it advances solely as the user scrolls, 1:1 with
|
|
141
|
+
* their input, so it is direct manipulation rather than something that plays at
|
|
142
|
+
* them. `scrollHorizontal` sets this, because jumping to the final state there
|
|
143
|
+
* would leave every panel but the last unreachable inside the sticky
|
|
144
|
+
* `overflow: hidden` container.
|
|
145
|
+
*/
|
|
146
|
+
respectReducedMotion?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Element whose geometry defines the trigger window, when that is not the
|
|
149
|
+
* element being animated. Defaults to the animated element.
|
|
150
|
+
*
|
|
151
|
+
* Needed whenever the animated element cannot supply the scroll length itself —
|
|
152
|
+
* the case that matters is a `position: sticky` stage, where the pinned element
|
|
153
|
+
* is exactly one viewport tall and all of the scroll room belongs to its
|
|
154
|
+
* container. Resolving `top top` → `bottom bottom` against the pinned element
|
|
155
|
+
* there yields tStart === tEnd, a zero-length window, and no movement at all.
|
|
156
|
+
*
|
|
157
|
+
* Setting this disables the native CSS fast path: `animation-timeline: view()`
|
|
158
|
+
* always measures the element the animation is attached to, so it cannot express
|
|
159
|
+
* a separate subject.
|
|
160
|
+
*/
|
|
161
|
+
triggerElement?: Element;
|
|
135
162
|
onProgress?: (alpha: number) => void;
|
|
136
163
|
onComplete?: () => void;
|
|
137
164
|
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
package/dist/react/index.d.ts
CHANGED
|
@@ -132,6 +132,33 @@ interface ScrollAnimateOptions {
|
|
|
132
132
|
* Higher values = more dramatic speed-up. Default sensitivity: 1.
|
|
133
133
|
*/
|
|
134
134
|
velocityScale?: boolean | number;
|
|
135
|
+
/**
|
|
136
|
+
* Honour `prefers-reduced-motion: reduce` by applying the final state and not
|
|
137
|
+
* animating. Default: `true`.
|
|
138
|
+
*
|
|
139
|
+
* Set to `false` only when the movement is *scroll-linked scrubbing* rather
|
|
140
|
+
* than autonomous motion — it advances solely as the user scrolls, 1:1 with
|
|
141
|
+
* their input, so it is direct manipulation rather than something that plays at
|
|
142
|
+
* them. `scrollHorizontal` sets this, because jumping to the final state there
|
|
143
|
+
* would leave every panel but the last unreachable inside the sticky
|
|
144
|
+
* `overflow: hidden` container.
|
|
145
|
+
*/
|
|
146
|
+
respectReducedMotion?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Element whose geometry defines the trigger window, when that is not the
|
|
149
|
+
* element being animated. Defaults to the animated element.
|
|
150
|
+
*
|
|
151
|
+
* Needed whenever the animated element cannot supply the scroll length itself —
|
|
152
|
+
* the case that matters is a `position: sticky` stage, where the pinned element
|
|
153
|
+
* is exactly one viewport tall and all of the scroll room belongs to its
|
|
154
|
+
* container. Resolving `top top` → `bottom bottom` against the pinned element
|
|
155
|
+
* there yields tStart === tEnd, a zero-length window, and no movement at all.
|
|
156
|
+
*
|
|
157
|
+
* Setting this disables the native CSS fast path: `animation-timeline: view()`
|
|
158
|
+
* always measures the element the animation is attached to, so it cannot express
|
|
159
|
+
* a separate subject.
|
|
160
|
+
*/
|
|
161
|
+
triggerElement?: Element;
|
|
135
162
|
onProgress?: (alpha: number) => void;
|
|
136
163
|
onComplete?: () => void;
|
|
137
164
|
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
package/dist/react/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${c?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",i,{passive:true}),i(),t}function Je(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,o=>{let l=parseFloat(o),u=t[i++]??l;return String(+(l+(u-l)*r).toFixed(4))})}function at(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,i=r?{...ot[r],...t}:t,o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:l="path, polyline, line, polygon, rect, circle",speed:u=1,fade:c=false,easing:y="linear",trigger:L={},stagger:C=0,direction:S="forward",once:U=false,debug:de=false,axis:F="y",scrollContainer:_,autoReverse:H=false,delay:G=0,strokeColor:x,strokeWidth:M,fillOpacity:P,waypoints:p,velocityScale:v=false,threshold:N=0,rootMargin:I="0px",repeat:E=0,repeatDelay:J=0,morphTo:T,clip:R,autoplay:D=false,duration:K=1e3,native:X=true,onProgress:d,onStart:$,onComplete:b,onEnter:h,onLeave:Y,onEnterBack:Se,onLeaveBack:xe}=i,be=R===true?"left":typeof R=="string"?R:false,we=typeof y=="function"?y:re[y]??re.linear,Ce=ne(L.start??"top bottom"),He=ne(L.end??"bottom top"),oe=typeof _=="string"?document.querySelector(_):_??null,ge=Array.isArray(x)?x[0]:null,ee=Array.isArray(x)?x[1]:typeof x=="string"?x:null,te=Array.isArray(M)?M[0]:null,a=Array.isArray(M)?M[1]:typeof M=="number"?M:null,g=Array.isArray(P)?P[0]:null,z=Array.isArray(P)?P[1]:typeof P=="number"?P:null;function se(s){let m=s*100;switch(be){case "right":return `inset(0 0 0 ${100-m}%)`;case "top":return `inset(0 0 ${100-m}% 0)`;case "bottom":return `inset(${100-m}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-m}% 0 0)`}}let O=be?[]:Array.from(e.querySelectorAll(l)),B=[],V=[],le=0,ce=0,ie=false,ye=false,ae=0,ze=false,ve=-1,Ve=-1,ue=false,$e=0,Te=0,Ae,Ye=null,Me=new Set,qe=-1,Ke=performance.now(),Ne=NaN;function Re(){return oe?F==="x"?oe.scrollLeft:oe.scrollTop:F==="x"?window.scrollX:window.scrollY}function Qe(){return oe?F==="x"?oe.clientWidth:oe.clientHeight:F==="x"?window.innerWidth:window.innerHeight}function et(){let s=e.getBoundingClientRect(),m,A,Q;if(oe){let fe=oe.getBoundingClientRect();m=F==="x"?s.left-fe.left+oe.scrollLeft:s.top-fe.top+oe.scrollTop,A=F==="x"?s.width:s.height,Q=Re();}else m=F==="x"?s.left:s.top,A=F==="x"?s.width:s.height,Q=Re();let me=pe({top:m,height:A},Q,Qe(),Ce,He);le=me.tStart,ce=me.tEnd,de&&process.env.NODE_ENV!=="production"&&(Ye?.remove(),Ye=kt(le,ce,F));}function Et(s,m){if(e.style.setProperty("--scroll-draw-progress",String(s)),be){let A=m==="reverse"?1-s:s;e.style.clipPath=se(A);return}O.forEach((A,Q)=>{A.style.strokeDashoffset=m==="reverse"?`${B[Q]*s}`:`${B[Q]*(1-s)}`,c&&(A.style.opacity=m==="reverse"?`${1-s}`:`${s}`),ge&&ee?A.style.stroke=Oe(ge,ee,s):ee&&(A.style.stroke=ee),te!==null&&a!==null?A.style.strokeWidth=`${te+(a-te)*s}`:a!==null&&(A.style.strokeWidth=`${a}`),g!==null&&z!==null?A.style.fillOpacity=`${g+(z-g)*s}`:z!==null&&(A.style.fillOpacity=`${z}`),T&&A.tagName.toLowerCase()==="path"&&V[Q]&&A.setAttribute("d",Je(V[Q],T,s));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),be){e.style.clipPath=se(0);return}O.forEach((s,m)=>{s.style.strokeDasharray=`${B[m]}`,s.style.strokeDashoffset=S==="reverse"?"0":`${B[m]}`,c?s.style.opacity=S==="reverse"?"1":"0":s.style.opacity="",ge&&(s.style.stroke=ge),te!==null&&(s.style.strokeWidth=`${te}`),g!==null&&(s.style.fillOpacity=`${g}`),T&&s.tagName.toLowerCase()==="path"&&V[m]&&s.setAttribute("d",V[m]);});}if(O.forEach(s=>{$t(s);let m=Ge(s);B.push(m),s.tagName.toLowerCase()==="path"?V.push(s.getAttribute("d")??""):V.push(""),o?(s.style.strokeDasharray=`${m}`,s.style.strokeDashoffset=S==="reverse"?`${m}`:"0",c&&(s.style.opacity="1"),ee&&(s.style.stroke=ee),a!==null&&(s.style.strokeWidth=`${a}`),z!==null&&(s.style.fillOpacity=`${z}`),T&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",T)):(s.style.strokeDasharray=`${m}`,s.style.strokeDashoffset=S==="reverse"?"0":`${m}`,c?s.style.opacity=S==="reverse"?"1":"0":s.style.opacity="",ge&&(s.style.stroke=ge),te!==null&&(s.style.strokeWidth=`${te}`),g!==null&&(s.style.fillOpacity=`${g}`));}),be){if(o)return e.style.clipPath=se(1),b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=se(0);}else if(o)return b?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function St(){return !(X===false||!Ct()||!O.length||typeof y!="string"||!(y in it)||be||F!=="y"||oe||u!==1||C!==0||U||H||v!==false||T||p||E||G>0||d||$||b||h||Y||Se||xe||x!=null||M!=null||P!=null||(L.start??"top bottom").trim()!=="top bottom"||(L.end??"bottom top").trim()!=="bottom top")}function xt(){let s=`svg-scroll-draw-${++Lt}`,m=S==="reverse"?"0":"var(--ssd-len)",A=S==="reverse"?"var(--ssd-len)":"0",Q=`stroke-dashoffset:${m};`,me=`stroke-dashoffset:${A};`;c&&(Q+=`opacity:${S==="reverse"?1:0};`,me+=`opacity:${S==="reverse"?0:1};`);let fe=document.createElement("style");fe.setAttribute("data-svg-scroll-draw",""),fe.textContent=`@keyframes ${s}{from{${Q}}to{${me}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${it[y]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(fe);function he(f,k){f.style.setProperty("--ssd-len",String(B[k])),f.style.strokeDasharray=`${B[k]}`,f.style.strokeDashoffset="",f.style.opacity="",f.style.animationPlayState="",f.classList.add(s);}O.forEach(he);let w=false,q=-1;function W(){if(q>=0)return q;let f=e.getBoundingClientRect(),{tStart:k,tEnd:j}=pe({top:f.top,height:f.height},Re(),Qe(),Ce,He);return we(Z(Re(),k,j,u))}return {destroy(){O.forEach(f=>{f.classList.remove(s),f.style.removeProperty("--ssd-len"),f.style.animationPlayState="";}),fe.remove();},replay(){w=false,q=-1,O.forEach(he);},pause(){w=true,O.forEach(f=>{f.style.animationPlayState="paused";});},resume(){w&&(w=false,O.forEach(f=>{f.style.animationPlayState="running";}));},seek(f){let k=Math.min(1,Math.max(0,f));q=k,w=true,O.forEach((j,ke)=>{j.classList.remove(s),j.style.strokeDashoffset=S==="reverse"?`${B[ke]*k}`:`${B[ke]*(1-k)}`,c&&(j.style.opacity=S==="reverse"?`${1-k}`:`${k}`);});},getProgress(){return W()}}}if(St())return xt();function Tt(){let s=Math.max(1,K),m=0,A=0;function Q(W){let f=true;if(be){let k=Math.min(1,Math.max(0,W/s)),j=we(k);$e=j,e.style.setProperty("--scroll-draw-progress",String(j)),e.style.clipPath=se(S==="reverse"?1-j:j),d?.(j),k<1&&(f=false);}else O.forEach((k,j)=>{let ke=j*C*s,Ie=Math.min(1,Math.max(0,(W-ke)/s)),Ee=we(Ie);k.style.strokeDashoffset=S==="reverse"?`${B[j]*Ee}`:`${B[j]*(1-Ee)}`,c&&(k.style.opacity=S==="reverse"?`${1-Ee}`:`${Ee}`),ge&&ee?k.style.stroke=Oe(ge,ee,Ee):ee&&(k.style.stroke=ee),te!==null&&a!==null?k.style.strokeWidth=`${te+(a-te)*Ee}`:a!==null&&(k.style.strokeWidth=`${a}`),g!==null&&z!==null?k.style.fillOpacity=`${g+(z-g)*Ee}`:z!==null&&(k.style.fillOpacity=`${z}`),T&&k.tagName.toLowerCase()==="path"&&V[j]&&k.setAttribute("d",Je(V[j],T,Ee)),j===0&&(d?.(Ee),e.style.setProperty("--scroll-draw-progress",String(Ee))),Ie<1&&(f=false);});if(p){let k=Math.min(1,Math.max(0,W/s)),j=we(k);for(let ke in p){let Ie=parseFloat(ke);j>=Ie&&!Me.has(Ie)&&(Me.add(Ie),p[ke]?.());}}return f}function me(W){if(ue)return;let f=W-m;ye||(ye=true,$?.());let k=Q(f);if(k&&!ie){ie=true,Q(s*(1+Math.max(0,O.length-1)*C)),b?.(),Te<(E==="infinite"?1/0:E??0)&&(Te++,Ae=setTimeout(()=>{m=performance.now(),ye=false,ie=false,Me.clear(),We(),ae=requestAnimationFrame(me);},J));return}k||(ae=requestAnimationFrame(me));}function fe(){cancelAnimationFrame(ae),clearTimeout(Ae),m=performance.now(),A=0,ue=false,ye=false,ie=false,Te=0,Me.clear(),We(),ae=requestAnimationFrame(me);}let he=new IntersectionObserver(W=>{W.forEach(f=>{f.isIntersecting&&!(U&&ie)?fe():!f.isIntersecting&&!U&&!ie&&(cancelAnimationFrame(ae),clearTimeout(Ae),m=null);});},{root:oe??null,threshold:N,rootMargin:I}),w;function q(){clearTimeout(w),w=setTimeout(()=>{O.forEach((W,f)=>{B[f]=Ge(W),W.style.strokeDasharray=`${B[f]}`;});},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),G>0?setTimeout(()=>he.observe(e),G):he.observe(e),{destroy(){cancelAnimationFrame(ae),clearTimeout(Ae),he.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(w);},replay(){Te=0,fe();},pause(){ue||(ue=true,A=performance.now()-m,cancelAnimationFrame(ae));},resume(){ue&&(ue=false,m=performance.now()-A,ae=requestAnimationFrame(me));},seek(W){let f=Math.min(1,Math.max(0,W));$e=f,ue=true,A=f*s,m=performance.now()-A,cancelAnimationFrame(ae),Q(A);},getProgress(){return $e}}}if(D)return Tt();et();function Be(){if(!ze||ue)return;let s=performance.now(),m=Re(),A=u;if(v!==false){let w=s-Ke,q=w>0?Math.abs(m-(qe<0?m:qe))/w:0;A=u*Math.max(.2,1+q*(typeof v=="number"?v:1)*.04);}qe=m,Ke=s;let Q=H?Ve===-1||m>=Ve?"forward":"reverse":S;Ve=m;let me=ce-le,fe=true,he=me===0?0:(m-le)/me;if(isNaN(Ne)||(Ne<=0&&he>0?h?.():Ne>0&&he<=0&&xe?.(),Ne<1&&he>=1?Y?.():Ne>=1&&he<1&&Se?.()),Ne=he,be){let w=we(Z(m,le,ce,A));U&&!H&&(ve=Math.max(ve,w),w=ve),$e=w,e.style.setProperty("--scroll-draw-progress",String(w));let q=Q==="reverse"?1-w:w;e.style.clipPath=se(q),d?.(w),!ye&&Z(m,le,ce,A)>0&&(ye=true,$?.()),w>=1&&!ie?(ie=true,b?.(),Te<(E==="infinite"?1/0:E??0)&&(Te++,Ae=setTimeout(()=>{ve=-1,ye=false,ie=false,e.style.clipPath=se(0);},J))):w<1&&!U&&(ie=false),ae=requestAnimationFrame(Be);return}if(O.forEach((w,q)=>{let W=q*C*me,f=we(Z(m,le+W,ce+W,A));U&&!H&&(ve=Math.max(ve,f),f=ve),$e=f,w.style.strokeDashoffset=Q==="reverse"?`${B[q]*f}`:`${B[q]*(1-f)}`,c&&(w.style.opacity=Q==="reverse"?`${1-f}`:`${f}`),ge&&ee?w.style.stroke=Oe(ge,ee,f):ee&&(w.style.stroke=ee),te!==null&&a!==null?w.style.strokeWidth=`${te+(a-te)*f}`:a!==null&&(w.style.strokeWidth=`${a}`),g!==null&&z!==null?w.style.fillOpacity=`${g+(z-g)*f}`:z!==null&&(w.style.fillOpacity=`${z}`),T&&w.tagName.toLowerCase()==="path"&&V[q]&&w.setAttribute("d",Je(V[q],T,f)),q===0&&(d?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(fe=false);}),p){let w=we(Z(m,le,ce,A));for(let q in p){let W=parseFloat(q);w>=W&&!Me.has(W)&&(Me.add(W),p[q]?.());}}!ye&&Z(m,le,ce,A)>0&&(ye=true,$?.()),fe&&!ie?(ie=true,b?.(),Te<(E==="infinite"?1/0:E??0)&&(Te++,Ae=setTimeout(()=>{ve=-1,ye=false,ie=false,Me.clear(),We();},J))):!fe&&!U&&(ie=false),ae=requestAnimationFrame(Be);}let je=new IntersectionObserver(s=>{s.forEach(m=>{ze=m.isIntersecting,ze&&!ue?ae=requestAnimationFrame(Be):cancelAnimationFrame(ae);});},{root:oe??null,threshold:N,rootMargin:I}),Ue;function _e(){clearTimeout(Ue),Ue=setTimeout(()=>{O.forEach((s,m)=>{B[m]=Ge(s),s.style.strokeDasharray=`${B[m]}`;}),et();},150);}return window.addEventListener("resize",_e),window.addEventListener("orientationchange",_e),G>0?setTimeout(()=>je.observe(e),G):je.observe(e),{destroy(){cancelAnimationFrame(ae),clearTimeout(Ae),je.disconnect(),window.removeEventListener("resize",_e),window.removeEventListener("orientationchange",_e),clearTimeout(Ue),Ye?.remove();},replay(){ve=-1,Ve=-1,qe=-1,ye=false,ie=false,Te=0,ue=false,Me.clear(),clearTimeout(Ae),We();},pause(){ue=true,cancelAnimationFrame(ae);},resume(){ue&&(ue=false,ze&&(ae=requestAnimationFrame(Be)));},seek(s){let m=Math.min(1,Math.max(0,s));$e=m,ve=m,ue=true,cancelAnimationFrame(ae),Et(m,S);},getProgress(){return $e}}}var lt=new Map;function Pe(e,n){lt.set(e,n);}function Le(e){lt.delete(e);}function Nt(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 i=[],o=[],l=t[2].trim();if(l)for(let u of l.split(/[\s,]+/)){let c=u.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(c?parseFloat(c[1]):0),o.push(c?c[2]:"");}n.push({fn:t[1],nums:i,units:o});}return n}function It(e,n,r){let t=ct(e),i=ct(n);return t.length===0||t.length!==i.length?r<1?e:n:t.map((o,l)=>{let u=i[l];return o.fn!==u.fn||o.nums.length!==u.nums.length?r<1?`${o.fn}(${o.nums.map((c,y)=>`${c}${o.units[y]}`).join(", ")})`:`${u.fn}(${u.nums.map((c,y)=>`${c}${u.units[y]}`).join(", ")})`:`${o.fn}(${o.nums.map((c,y)=>`${c+(u.nums[y]-c)*r}${o.units[y]}`).join(", ")})`}).join(" ")}function ut(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),i=String(n);if(Nt(t))return Oe(t,i,r);if(t.includes("("))return It(t,i,r);let o=t.match(/^([-+]?[\d.]+)(.*)$/),l=i.match(/^([-+]?[\d.]+)(.*)$/);if(o&&l){let u=parseFloat(o[1]),c=parseFloat(l[1]);return `${u+(c-u)*r}${o[2]||l[2]}`}return r<1?t:i}function Ot(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"},Rt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Ft=0;function Dt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function ft(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:i={},easing:o="ease-out",speed:l=1,once:u=false,axis:c="y",scrollContainer:y,native:L=true,velocityScale:C=false,onProgress:S,onComplete:U,onEnter:de,onLeave:F,onEnterBack:_,onLeaveBack:H}=n,G=window.matchMedia("(prefers-reduced-motion: reduce)").matches,x=typeof o=="function"?o:re[o]??re["ease-out"],M=ne(i.start??"top bottom"),P=ne(i.end??"bottom top"),p=typeof y=="string"?document.querySelector(y):y??null,v=Object.entries(t).map(([a,g])=>({prop:Ot(a),from:Array.isArray(g)?g[0]:"",to:Array.isArray(g)?g[1]:g}));function N(){let a=window.getComputedStyle(e);for(let g of v)g.from===""&&(g.from=a.getPropertyValue(g.prop).trim()||"0");}function I(){for(let a of v)e.style.setProperty(a.prop,String(a.to));}if(G)return I(),U?.(),r;N();function E(){if(!L||!Dt()||typeof o!="string"||!(o in mt)||c!=="y"||p||u||l!==1||S||U||de||F||_||H||C!==false||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return false;for(let a of v)if(!Rt.has(a.prop))return false;return true}function J(){let a=`ssd-a-${++Ft}`,g=v.map(V=>`${V.prop}:${V.from}`).join(";"),z=v.map(V=>`${V.prop}:${V.to}`).join(";"),se=document.createElement("style");se.setAttribute("data-ssd-animate",""),se.textContent=`@keyframes ${a}{from{${g}}to{${z}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${mt[o]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(se),e.classList.add(a);let O=()=>c==="x"?window.scrollX:window.scrollY,B=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),se.remove();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(V){let le=Math.min(1,Math.max(0,V));e.classList.remove(a);for(let ce of v)e.style.setProperty(ce.prop,ut(ce.from,ce.to,le));},getProgress(){let V=e.getBoundingClientRect(),le=O(),ce=B(),{tStart:ie,tEnd:ye}=pe({top:V.top,height:V.height},le,ce,M,P);return x(Z(le,ie,ye,l))}}}if(E())return J();let T=0,R=0,D=0,K=false,X=false,d=-1,$=0,b=false,h=NaN,Y=-1,Se=0,xe=()=>p?c==="x"?p.scrollLeft:p.scrollTop:c==="x"?window.scrollX:window.scrollY,be=()=>p?c==="x"?p.clientWidth:p.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function we(){let a=e.getBoundingClientRect(),g,z;if(p){let O=p.getBoundingClientRect();g=c==="x"?a.left-O.left+p.scrollLeft:a.top-O.top+p.scrollTop,z=c==="x"?a.width:a.height;}else g=c==="x"?a.left:a.top,z=c==="x"?a.width:a.height;let se=pe({top:g,height:z},xe(),be(),M,P);T=se.tStart,R=se.tEnd;}function Ce(a){e.style.setProperty("--scroll-draw-progress",String(a));for(let g of v)e.style.setProperty(g.prop,ut(g.from,g.to,a));S?.(a);}function He(a){if(isNaN(h)){h=a;return}h<=0&&a>0?de?.():h>0&&a<=0&&H?.(),h<1&&a>=1?F?.():h>=1&&a<1&&_?.(),h=a;}function oe(){if(!K||X)return;let a=performance.now(),g=xe(),z=l;if(C!==false){let B=a-Se,V=B>0?Math.abs(g-(Y<0?g:Y))/B:0;z=l*Math.max(.2,1+V*(typeof C=="number"?C:1)*.04);}Y=g,Se=a;let se=R===T?0:(g-T)/(R-T);He(se);let O=x(Z(g,T,R,z));u&&(d=Math.max(d,O),O=d),$=O,Ce(O),O>=1&&!b?(b=true,U?.()):O<1&&!u&&(b=false),D=requestAnimationFrame(oe);}we();{let a=x(Z(xe(),T,R,l));u&&a>0&&(d=a),$=a,Ce(a);}let ge=new IntersectionObserver(a=>{a.forEach(g=>{K=g.isIntersecting,K&&!X?D=requestAnimationFrame(oe):cancelAnimationFrame(D);});},{root:p??null}),ee;function te(){clearTimeout(ee),ee=setTimeout(we,150);}return window.addEventListener("resize",te),window.addEventListener("orientationchange",te),ge.observe(e),Pe(e,{type:"animate",getProgress:()=>$,getTrigger:()=>({tStart:T,tEnd:R})}),{destroy(){cancelAnimationFrame(D),ge.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),clearTimeout(ee),Le(e);},replay(){d=-1,b=false,$=0,X=false,Ce(0);},pause(){X=true,cancelAnimationFrame(D);},resume(){X&&(X=false,K&&(D=requestAnimationFrame(oe)));},seek(a){let g=Math.min(1,Math.max(0,a));$=g,d=g,X=true,cancelAnimationFrame(D),Ce(g);},getProgress(){return $}}}var Ze={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function pt(e,n){if(typeof window>"u")return Ze;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),Ze;let t=r,{from:i=0,to:o,format:l,easing:u="ease-out",trigger:c={},once:y=true,decimals:L,onComplete:C}=n,S=L!==void 0?d=>d.toFixed(L):l??(d=>String(Math.round(d))),U=typeof u=="function"?u:re[u]??re["ease-out"],de=ne(c.start??"top 80%"),F=ne(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=S(o),C?.(),Ze;t.textContent=S(i);let H=0,G=0,x=0,M=false,P=false,p=-1,v=0,N=false,I=()=>window.scrollY,E=()=>window.innerHeight;function J(){let d=t.getBoundingClientRect(),$=pe({top:d.top,height:d.height},I(),E(),de,F);H=$.tStart,G=$.tEnd;}function T(d){t.textContent=S(i+(o-i)*d),t.style.setProperty("--scroll-draw-progress",String(d));}function R(){if(!M||P)return;let d=U(Z(I(),H,G,1));y&&(p=Math.max(p,d),d=p),v=d,T(d),d>=1&&!N?(N=true,C?.()):d<1&&!y&&(N=false),x=requestAnimationFrame(R);}J();{let d=U(Z(I(),H,G,1));y&&d>0&&(p=d),v=d,T(d);}let D=new IntersectionObserver(d=>{d.forEach($=>{M=$.isIntersecting,M&&!P?x=requestAnimationFrame(R):cancelAnimationFrame(x);});}),K;function X(){clearTimeout(K),K=setTimeout(J,150);}return window.addEventListener("resize",X),window.addEventListener("orientationchange",X),D.observe(t),Pe(t,{type:"counter",getProgress:()=>v,getTrigger:()=>({tStart:H,tEnd:G})}),{destroy(){cancelAnimationFrame(x),D.disconnect(),window.removeEventListener("resize",X),window.removeEventListener("orientationchange",X),clearTimeout(K),Le(t);},replay(){p=-1,N=false,v=0,P=false,T(0);},pause(){P=true,cancelAnimationFrame(x);},resume(){P&&(P=false,M&&(x=requestAnimationFrame(R)));},seek(d){let $=Math.min(1,Math.max(0,d));v=$,p=$,P=true,cancelAnimationFrame(x),T($);},getProgress(){return v}}}var dt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function gt(e,n={}){if(typeof window>"u")return dt;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollVideo: <video> element not found:",e),dt;let t=r,{trigger:i={},easing:o="linear",once:l=false,axis:u="y",preload:c="auto",onReady:y,onComplete:L,onProgress:C}=n,S=window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=typeof o=="function"?o:re[o]??re.linear,de=ne(i.start??"top top"),F=ne(i.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=c);let _=n.from??0,H=n.to,G=0,x=0,M=0,P=false,p=false,v=-1,N=0,I=false,E=false,J=()=>u==="x"?window.scrollX:window.scrollY,T=()=>u==="x"?window.innerWidth:window.innerHeight;function R(){let h=t.getBoundingClientRect(),Y=u==="x"?h.left:h.top,Se=u==="x"?h.width:h.height,xe=pe({top:Y,height:Se},J(),T(),de,F);G=xe.tStart,x=xe.tEnd;}function D(h){if(!E)return;let Y=H??t.duration??0;t.currentTime=_+(Y-_)*h,t.style.setProperty("--scroll-draw-progress",String(h)),C?.(h);}function K(){if(!P||p||!E)return;let h=U(Z(J(),G,x,1));l&&(v=Math.max(v,h),h=v),N=h,D(h),h>=1&&!I?(I=true,L?.()):h<1&&!l&&(I=false),M=requestAnimationFrame(K);}function X(){if(E=true,H===void 0&&(H=t.duration),S){D(1),y?.();return}R(),y?.(),P&&!p&&(M=requestAnimationFrame(K));}t.readyState>=1?X():t.addEventListener("loadedmetadata",X,{once:true}),E||R();let d=new IntersectionObserver(h=>{h.forEach(Y=>{P=Y.isIntersecting,P&&!p&&E?M=requestAnimationFrame(K):cancelAnimationFrame(M);});}),$;function b(){clearTimeout($),$=setTimeout(R,150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),d.observe(t),Pe(t,{type:"video",getProgress:()=>N,getTrigger:()=>({tStart:G,tEnd:x})}),{destroy(){cancelAnimationFrame(M),d.disconnect(),t.removeEventListener("loadedmetadata",X),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout($),Le(t);},replay(){v=-1,I=false,N=0,p=false,D(0);},pause(){p=true,cancelAnimationFrame(M);},resume(){p&&(p=false,P&&E&&(M=requestAnimationFrame(K)));},seek(h){let Y=Math.min(1,Math.max(0,h));N=Y,v=Y,p=true,cancelAnimationFrame(M),D(Y);},getProgress(){return N}}}function bt(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 Ht(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 yt(e){let n=bt(e),r=new Map;for(let o of n){let l=o.offsetTop;r.has(l)||r.set(l,[]),r.get(l).push(o);}let t=[],i=Array.from(r.keys()).sort((o,l)=>o-l);for(let o of i){let l=r.get(o),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block";for(let c of l)u.appendChild(c);t.push(u);}e.textContent="";for(let o of t)e.appendChild(o),e.appendChild(document.createTextNode(" "));return t}function zt(e,n,r,t){if(r<=1||t===0)return e;let i=(r-1)*t,o=n*t,l=o+(1-i);return l<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(l-o)))}function Vt(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 ht={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function wt(e,n={}){if(typeof window>"u")return ht;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),ht;let t=r,{split:i="words",stagger:o=.04,easing:l="ease-out",from:u={opacity:0,y:24},trigger:c={},once:y=true,onComplete:L}=n,C=window.matchMedia("(prefers-reduced-motion: reduce)").matches,S=typeof l=="function"?l:re[l]??re["ease-out"],U=ne(c.start??"top 85%"),de=ne(c.end??"top 40%"),F=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let _;i==="chars"?_=Ht(t):i==="lines"?_=yt(t):_=bt(t);let H=_.length;function G(b,h){u?.opacity!==void 0&&(b.style.opacity=String(u.opacity+(1-u.opacity)*h));let Y=Vt(h,u);Y&&(b.style.transform=Y);}function x(b){t.style.setProperty("--scroll-draw-progress",String(b)),_.forEach((h,Y)=>{let Se=S(zt(b,Y,H,o));G(h,Se);});}if(C)return x(1),L?.(),{destroy(){t.innerHTML=F,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};x(0);let M=0,P=0,p=0,v=false,N=false,I=-1,E=0,J=false,T=()=>window.scrollY,R=()=>window.innerHeight;function D(){let b=t.getBoundingClientRect(),h=pe({top:b.top,height:b.height},T(),R(),U,de);M=h.tStart,P=h.tEnd;}function K(){if(!v||N)return;let b=Z(T(),M,P,1);y&&(I=Math.max(I,b),b=I),E=b,x(b),b>=1&&!J?(J=true,L?.()):b<1&&!y&&(J=false),p=requestAnimationFrame(K);}D();let X=new IntersectionObserver(b=>{b.forEach(h=>{v=h.isIntersecting,v&&!N?p=requestAnimationFrame(K):cancelAnimationFrame(p);});}),d;function $(){clearTimeout(d),d=setTimeout(()=>{if(i==="lines"){let b=E;t.innerHTML=F,t.setAttribute("aria-label",t.textContent??""),_=yt(t),x(b);}D();},150);}return window.addEventListener("resize",$),window.addEventListener("orientationchange",$),X.observe(t),Pe(t,{type:"text",getProgress:()=>E,getTrigger:()=>({tStart:M,tEnd:P})}),{destroy(){cancelAnimationFrame(p),X.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),clearTimeout(d),t.innerHTML=F,t.removeAttribute("aria-label"),Le(t);},replay(){I=-1,J=false,E=0,N=false,x(0);},pause(){N=true,cancelAnimationFrame(p);},resume(){N&&(N=false,v&&(p=requestAnimationFrame(K)));},seek(b){let h=Math.min(1,Math.max(0,b));E=h,I=h,N=true,cancelAnimationFrame(p),x(h);},getProgress(){return E}}}function Bt(e,n={}){let[r,t]=useState(0),i=useRef(n);i.current=n;let o=useRef(-1);return useEffect(()=>{if(typeof window>"u")return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t(1);return}let l=typeof e=="string"?document.querySelector(e):e.current;if(!l)return;let u=l,{axis:c="y",scrollContainer:y,trigger:L={}}=i.current,C=typeof y=="string"?document.querySelector(y):y??null,S=ne(L.start??"top bottom"),U=ne(L.end??"bottom top"),de=0,F=0,_=false,H=0;function G(){return C?c==="x"?C.scrollLeft:C.scrollTop:c==="x"?window.scrollX:window.scrollY}function x(){return C?c==="x"?C.clientWidth:C.clientHeight:c==="x"?window.innerWidth:window.innerHeight}function M(){let I=u.getBoundingClientRect(),E=G(),J=c==="x"?I.left:I.top,T=c==="x"?I.width:I.height,R=pe({top:J,height:T},E,x(),S,U);de=R.tStart,F=R.tEnd;}function P(){if(!_)return;let{speed:I=1,easing:E="linear",once:J=false}=i.current,T=typeof E=="function"?E:re[E]??re.linear,R=Z(G(),de,F,I),D=T(R);J&&(o.current=Math.max(o.current,D),D=o.current),t(D),H=requestAnimationFrame(P);}let p=new IntersectionObserver(I=>{I.forEach(E=>{_=E.isIntersecting,_?H=requestAnimationFrame(P):cancelAnimationFrame(H);});},{root:C??null,threshold:0});M(),p.observe(u);let v;function N(){clearTimeout(v),v=setTimeout(M,150);}return window.addEventListener("resize",N),window.addEventListener("orientationchange",N),()=>{cancelAnimationFrame(H),clearTimeout(v),p.disconnect(),window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N);}},[]),r}function br({children:e,className:n,style:r,...t}){let i=useRef(null);return useEffect(()=>{if(!i.current)return;let o=at(i.current,t);return ()=>o.destroy()},[]),jsx("div",{ref:i,className:n,style:r,children:e})}function wr({children:e,className:n,style:r,...t}){let i=useRef(null);return useEffect(()=>{if(!i.current)return;let o=ft(i.current,t);return ()=>o.destroy()},[]),jsx("div",{ref:i,className:n,style:r,children:e})}function vr({className:e,style:n,...r}){let t=useRef(null);return useEffect(()=>{if(!t.current)return;let i=pt(t.current,r);return ()=>i.destroy()},[]),jsx("span",{ref:t,className:e,style:n})}function Er({src:e,className:n,style:r,muted:t=true,playsInline:i=true,...o}){let l=useRef(null);return useEffect(()=>{if(!l.current)return;let u=gt(l.current,o);return ()=>u.destroy()},[]),jsx("video",{ref:l,src:e,className:n,style:r,muted:t,playsInline:i,preload:"auto"})}function Sr({children:e,as:n="p",className:r,style:t,...i}){let o=useRef(null);return useEffect(()=>{if(!o.current)return;let l=wt(o.current,i);return ()=>l.destroy()},[]),_t.createElement(n,{ref:o,className:r,style:t},e)}export{wr as ScrollAnimate,vr as ScrollCounter,br as ScrollDraw,Sr as ScrollText,Er as ScrollVideo,Bt as useScrollDrawProgress};
|
|
1
|
+
import ur,{useState,useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';function Vt({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),o=0,a=[];for(let f=0;f<r;f++){let E=Math.pow(s,f);a.push(E),o+=E;}let u=[0],m=0;for(let f=0;f<r;f++)m+=a[f]/o,u.push(m);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let E=0;E<r;E++)if(f<=u[E+1]){let R=(f-u[E])/(u[E+1]-u[E]);if(E===0)return R*(2-R);let L=1-Math.pow(t,E);return L+(1-L)*(2*R-1)*(2*R-1)}return 1}}function _t({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 o=>o<=0?0:o>=1?1:r*Math.pow(2,-10*o)*Math.sin((o-s)*(2*Math.PI)/t)+1}var Q={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Vt(),elastic:_t()};function ne(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 gt(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 yt(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function Ve(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function qt(e,n,r){return Math.min(r,Math.max(n,e))}function Z(e,n,r,t){return r===n?0:qt((e-n)/(r-n)*t,0,1)}function Je(e,n,r){let t=e.getBoundingClientRect(),s=r==="x"?t.width:t.height;return n?{top:r==="x"?t.left-n.getBoundingClientRect().left+n.scrollLeft:t.top-n.getBoundingClientRect().top+n.scrollTop,height:s,scroll:0}:{top:r==="x"?t.left:t.top,height:s,scroll:r==="x"?window.scrollX:window.scrollY}}function ye(e,n,r,t,s){let o=gt(e.top,e.height,n,t.element)-yt(t.viewport,r),a=gt(e.top,e.height,n,s.element)-yt(s.viewport,r);return {tStart:o,tEnd:a}}function ht(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 _e(e,n,r){let t=ht(e),s=ht(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 bt={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}};var Ke=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function he(e,...n){Ke&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var Wt="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Bt="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",wt=33;function Gt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Ut(e){let n=[];for(let r=0;r<wt;r++){let t=r/(wt-1);n.push(String(Math.round(e(t)*1e5)/1e5));}return `linear(${n.join(",")})`}function et(e){switch(e){case "linear":return "linear";case "ease-in":return Wt;case "ease-out":return Bt;case "ease-in-out":return Gt()?Ut(Q["ease-in-out"]):null;default:return null}}var jt=0;function Xt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function Yt(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?he("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&he("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Qt(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 o=r==="x"?window.scrollX:window.scrollY,a=e-o,u=n-o,m=r==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${m?`left:${a}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${a}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;${m?`left:${u}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${u}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",s,{passive:true}),s(),{el:t,destroy(){window.removeEventListener("scroll",s),t.remove();}}}var vt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,St=/[MmLlHhVvCcSsQqTtAaZz]/g;function Zt(e,n,r){if(!Ke)return;let t=(e.match(St)??[]).join("").toUpperCase(),s=(n.match(St)??[]).join("").toUpperCase(),o=(e.match(vt)??[]).length,a=(n.match(vt)??[]).length;if(t!==s){he(`morphTo: command sequence differs (${t||"\u2205"} \u2192 ${s||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}o!==a&&he(`morphTo: coordinate count differs (${o} \u2192 ${a}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function it(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),s=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,o=>{let a=parseFloat(o),u=t[s++]??a;return String(+(a+(u-a)*r).toFixed(4))})}function Et(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,s=r?{...bt[r],...t}:t,o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:a="path, polyline, line, polygon, rect, circle",speed:u=1,fade:m=false,easing:f="linear",trigger:E={},stagger:R=0,direction:L="forward",once:te=false,debug:be=false,axis:N="y",scrollContainer:q,autoReverse:F=false,delay:H=0,strokeColor:M,strokeWidth:C,fillOpacity:A,waypoints:w,velocityScale:$=false,threshold:k=0,rootMargin:v="0px",repeat:y=0,repeatDelay:G=0,morphTo:I,clip:W,autoplay:U=false,duration:oe=1e3,native:me=true,onProgress:h,onStart:P,onComplete:g,onEnter:d,onLeave:z,onEnterBack:de,onLeaveBack:Ee}=s,fe=W===true?"left":typeof W=="string"?W:false,Te=typeof f=="function"?f:Q[f]??Q.linear,Pe=ne(E.start??"top bottom"),He=ne(E.end??"bottom top"),we=typeof q=="string"?document.querySelector(q):q??null,ve=Array.isArray(M)?M[0]:null,ie=Array.isArray(M)?M[1]:typeof M=="string"?M:null,ae=Array.isArray(C)?C[0]:null,J=Array.isArray(C)?C[1]:typeof C=="number"?C:null,pe=Array.isArray(A)?A[0]:null,re=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function Le(i){let c=i*100;switch(fe){case "right":return `inset(0 0 0 ${100-c}%)`;case "top":return `inset(0 0 ${100-c}% 0)`;case "bottom":return `inset(${100-c}% 0 0 0)`;case "center":return `circle(${i*150}% at 50% 50%)`;default:return `inset(0 ${100-c}% 0 0)`}}let B=fe?[]:Array.from(e.querySelectorAll(a)),O=[],l=[],p=0,Se=0,V=false,j=false,X=0,K=false,le=-1,Ce=-1,se=false,xe=0,Re=0,Ie,rt=null;function lt(){rt?.destroy(),rt=null;}let Oe=new Set,ct=NaN,Fe=true,Ue=-1,ut=performance.now(),ze=NaN;function nt(){return we?N==="x"?we.scrollLeft:we.scrollTop:N==="x"?window.scrollX:window.scrollY}function mt(){return we?N==="x"?we.clientWidth:we.clientHeight:N==="x"?window.innerWidth:window.innerHeight}function ft(){let i=Je(e,we,N),c=ye(i,i.scroll,mt(),Pe,He);p=c.tStart,Se=c.tEnd,be&&Ke&&(lt(),rt=Qt(p,Se,N));}function Dt(i,c){if(e.style.setProperty("--scroll-draw-progress",String(i)),fe){let T=c==="reverse"?1-i:i;e.style.clipPath=Le(T);return}B.forEach((T,ce)=>{T.style.strokeDashoffset=c==="reverse"?`${O[ce]*i}`:`${O[ce]*(1-i)}`,m&&(T.style.opacity=c==="reverse"?`${1-i}`:`${i}`),ve&&ie?T.style.stroke=_e(ve,ie,i):ie&&(T.style.stroke=ie),ae!==null&&J!==null?T.style.strokeWidth=`${ae+(J-ae)*i}`:J!==null&&(T.style.strokeWidth=`${J}`),pe!==null&&re!==null?T.style.fillOpacity=`${pe+(re-pe)*i}`:re!==null&&(T.style.fillOpacity=`${re}`),I&&T.tagName.toLowerCase()==="path"&&l[ce]&&T.setAttribute("d",it(l[ce],I,i));});}function je(){if(e.style.setProperty("--scroll-draw-progress","0"),fe){e.style.clipPath=Le(0);return}B.forEach((i,c)=>{i.style.strokeDasharray=`${O[c]}`,i.style.strokeDashoffset=L==="reverse"?"0":`${O[c]}`,m?i.style.opacity=L==="reverse"?"1":"0":i.style.opacity="",ve&&(i.style.stroke=ve),ae!==null&&(i.style.strokeWidth=`${ae}`),pe!==null&&(i.style.fillOpacity=`${pe}`),I&&i.tagName.toLowerCase()==="path"&&l[c]&&i.setAttribute("d",l[c]);});}if(B.forEach(i=>{Yt(i);let c=Ve(i);O.push(c);let T=i.tagName.toLowerCase()==="path";T?l.push(i.getAttribute("d")??""):l.push(""),I&&(T?Zt(l[l.length-1],I,i):he(`morphTo only applies to <path> elements \u2014 ignored on <${i.tagName}>.`,i)),o?(i.style.strokeDasharray=`${c}`,i.style.strokeDashoffset=L==="reverse"?`${c}`:"0",m&&(i.style.opacity="1"),ie&&(i.style.stroke=ie),J!==null&&(i.style.strokeWidth=`${J}`),re!==null&&(i.style.fillOpacity=`${re}`),I&&i.tagName.toLowerCase()==="path"&&i.setAttribute("d",I)):(i.style.strokeDasharray=`${c}`,i.style.strokeDashoffset=L==="reverse"?"0":`${c}`,m?i.style.opacity=L==="reverse"?"1":"0":i.style.opacity="",ve&&(i.style.stroke=ve),ae!==null&&(i.style.strokeWidth=`${ae}`),pe!==null&&(i.style.fillOpacity=`${pe}`));}),fe){if(o)return e.style.clipPath=Le(1),g?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=Le(0);}else if(o)return g?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let pt=typeof f=="string"?et(f):null;function Nt(){return !(me===false||!Xt()||!B.length||!pt||fe||N!=="y"||we||u!==1||R!==0||te||F||$!==false||I||w||y||H>0||h||P||g||d||z||de||Ee||M!=null||C!=null||A!=null||(E.start??"top bottom").trim()!=="top bottom"||(E.end??"bottom top").trim()!=="bottom top")}function Ht(){let i=++jt,c=`svg-scroll-draw-${i}`,T=`svg-scroll-draw-host-${i}`,ce=`--svg-scroll-draw-${i}`,ke=L==="reverse"?"0":"var(--ssd-len)",$e=L==="reverse"?"var(--ssd-len)":"0",Me=`stroke-dashoffset:${ke};`,x=`stroke-dashoffset:${$e};`;m&&(Me+=`opacity:${L==="reverse"?1:0};`,x+=`opacity:${L==="reverse"?0:1};`);let D=document.createElement("style");D.setAttribute("data-svg-scroll-draw",""),D.textContent=`@keyframes ${c}{from{${Me}}to{${x}}}.${T}{view-timeline-name:${ce};view-timeline-axis:block;}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${pt};animation-fill-mode:both;animation-timeline:${ce};animation-range:cover 0% cover 100%;}`,document.head.appendChild(D),e.classList.add(T);function ue(b,ee){b.style.setProperty("--ssd-len",String(O[ee])),b.style.strokeDasharray=`${O[ee]}`,b.style.strokeDashoffset="",b.style.opacity="",b.style.animationPlayState="",b.classList.add(c);}B.forEach(ue);let S=false,_=-1;function Y(){if(_>=0)return _;let b=e.getBoundingClientRect(),{tStart:ee,tEnd:Ae}=ye({top:b.top,height:b.height},nt(),mt(),Pe,He);return Te(Z(nt(),ee,Ae,u))}return {destroy(){e.classList.remove(T),B.forEach(b=>{b.classList.remove(c),b.style.removeProperty("--ssd-len"),b.style.animationPlayState="";}),D.remove();},replay(){S=false,_=-1,B.forEach(ue);},pause(){S=true,B.forEach(b=>{b.style.animationPlayState="paused";});},resume(){S&&(S=false,B.forEach(b=>{b.style.animationPlayState="running";}));},seek(b){let ee=Math.min(1,Math.max(0,b));_=ee,S=true,B.forEach((Ae,ge)=>{Ae.classList.remove(c),Ae.style.strokeDashoffset=L==="reverse"?`${O[ge]*ee}`:`${O[ge]*(1-ee)}`,m&&(Ae.style.opacity=L==="reverse"?`${1-ee}`:`${ee}`);});},getProgress(){return Y()},refresh(){B.forEach((b,ee)=>{O[ee]=Ve(b),b.style.setProperty("--ssd-len",String(O[ee])),b.style.strokeDasharray=`${O[ee]}`;});}}}if(Nt())return Ht();function zt(){let i=Math.max(1,oe),c=0,T=0,ce=false;function ke(S){let _=true;if(fe){let Y=Math.min(1,Math.max(0,S/i)),b=Te(Y);xe=b,e.style.setProperty("--scroll-draw-progress",String(b)),e.style.clipPath=Le(L==="reverse"?1-b:b),h?.(b),Y<1&&(_=false);}else B.forEach((Y,b)=>{let ee=b*R*i,Ae=Math.min(1,Math.max(0,(S-ee)/i)),ge=Te(Ae);Y.style.strokeDashoffset=L==="reverse"?`${O[b]*ge}`:`${O[b]*(1-ge)}`,m&&(Y.style.opacity=L==="reverse"?`${1-ge}`:`${ge}`),ve&&ie?Y.style.stroke=_e(ve,ie,ge):ie&&(Y.style.stroke=ie),ae!==null&&J!==null?Y.style.strokeWidth=`${ae+(J-ae)*ge}`:J!==null&&(Y.style.strokeWidth=`${J}`),pe!==null&&re!==null?Y.style.fillOpacity=`${pe+(re-pe)*ge}`:re!==null&&(Y.style.fillOpacity=`${re}`),I&&Y.tagName.toLowerCase()==="path"&&l[b]&&Y.setAttribute("d",it(l[b],I,ge)),b===0&&(xe=ge,h?.(ge),e.style.setProperty("--scroll-draw-progress",String(ge))),Ae<1&&(_=false);});if(w){let Y=Math.min(1,Math.max(0,S/i)),b=Te(Y);for(let ee in w){let Ae=parseFloat(ee);b>=Ae&&!Oe.has(Ae)&&(Oe.add(Ae),w[ee]?.());}}return _}function $e(S){if(se)return;let _=S-c;j||(j=true,P?.());let Y=ke(_);if(Y&&!V){V=true,ke(i*(1+Math.max(0,B.length-1)*R)),g?.(),Re<(y==="infinite"?1/0:y??0)&&(Re++,Ie=setTimeout(()=>{c=performance.now(),j=false,V=false,Oe.clear(),je(),X=requestAnimationFrame($e);},G));return}Y||(X=requestAnimationFrame($e));}function Me(){cancelAnimationFrame(X),clearTimeout(Ie),c=performance.now(),T=0,se=false,j=false,V=false,Re=0,ce=true,xe=0,Oe.clear(),je(),X=requestAnimationFrame($e);}let x=new IntersectionObserver(S=>{S.forEach(_=>{_.isIntersecting&&!(te&&V)?Me():!_.isIntersecting&&!te&&!V&&(cancelAnimationFrame(X),clearTimeout(Ie),ce=false);});},{root:we??null,threshold:k,rootMargin:v}),D;function ue(){clearTimeout(D),D=setTimeout(()=>{B.forEach((S,_)=>{O[_]=Ve(S),S.style.strokeDasharray=`${O[_]}`;});},150);}return window.addEventListener("resize",ue),window.addEventListener("orientationchange",ue),H>0?setTimeout(()=>x.observe(e),H):x.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(Ie),x.disconnect(),window.removeEventListener("resize",ue),window.removeEventListener("orientationchange",ue),clearTimeout(D);},replay(){Re=0,Me();},pause(){se||!ce||(se=true,T=performance.now()-c,cancelAnimationFrame(X));},resume(){se&&(se=false,ce=true,c=performance.now()-T,X=requestAnimationFrame($e));},seek(S){let _=Math.min(1,Math.max(0,S));xe=_,se=true,T=_*i,c=performance.now()-T,cancelAnimationFrame(X),ke(T);},getProgress(){return xe},refresh(){clearTimeout(D),B.forEach((S,_)=>{O[_]=Ve(S),S.style.strokeDasharray=`${O[_]}`;});}}}if(U)return zt();ft();function Xe(){if(!K||se)return;let i=performance.now(),c=nt();if(!Fe&&$===false&&c===ct){X=requestAnimationFrame(Xe);return}Fe=false,ct=c;let T=u;if($!==false){let x=i-ut,D=x>0?Math.abs(c-(Ue<0?c:Ue))/x:0;T=u*Math.max(.2,1+D*(typeof $=="number"?$:1)*.04);}Ue=c,ut=i;let ce=F?Ce===-1||c>=Ce?"forward":"reverse":L;Ce=c;let ke=Se-p,$e=true,Me=ke===0?0:(c-p)/ke;if(isNaN(ze)||(ze<=0&&Me>0?d?.():ze>0&&Me<=0&&Ee?.(),ze<1&&Me>=1?z?.():ze>=1&&Me<1&&de?.()),ze=Me,fe){let x=Te(Z(c,p,Se,T));te&&!F&&(le=Math.max(le,x),x=le),xe=x,e.style.setProperty("--scroll-draw-progress",String(x));let D=ce==="reverse"?1-x:x;e.style.clipPath=Le(D),h?.(x),!j&&Z(c,p,Se,T)>0&&(j=true,P?.()),x>=1&&!V?(V=true,g?.(),Re<(y==="infinite"?1/0:y??0)&&(Re++,Ie=setTimeout(()=>{le=-1,j=false,V=false,e.style.clipPath=Le(0);},G))):x<1&&!te&&(V=false),X=requestAnimationFrame(Xe);return}if(B.forEach((x,D)=>{let ue=D*R*ke,S=Te(Z(c,p+ue,Se+ue,T));te&&!F&&(le=Math.max(le,S),S=le),xe=S,x.style.strokeDashoffset=ce==="reverse"?`${O[D]*S}`:`${O[D]*(1-S)}`,m&&(x.style.opacity=ce==="reverse"?`${1-S}`:`${S}`),ve&&ie?x.style.stroke=_e(ve,ie,S):ie&&(x.style.stroke=ie),ae!==null&&J!==null?x.style.strokeWidth=`${ae+(J-ae)*S}`:J!==null&&(x.style.strokeWidth=`${J}`),pe!==null&&re!==null?x.style.fillOpacity=`${pe+(re-pe)*S}`:re!==null&&(x.style.fillOpacity=`${re}`),I&&x.tagName.toLowerCase()==="path"&&l[D]&&x.setAttribute("d",it(l[D],I,S)),D===0&&(h?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&($e=false);}),w){let x=Te(Z(c,p,Se,T));for(let D in w){let ue=parseFloat(D);x>=ue&&!Oe.has(ue)&&(Oe.add(ue),w[D]?.());}}!j&&Z(c,p,Se,T)>0&&(j=true,P?.()),$e&&!V?(V=true,g?.(),Re<(y==="infinite"?1/0:y??0)&&(Re++,Ie=setTimeout(()=>{le=-1,j=false,V=false,Oe.clear(),je(),Fe=true;},G))):!$e&&!te&&(V=false),X=requestAnimationFrame(Xe);}let ot=false;function Ye(){ot||(ot=true,X=requestAnimationFrame(function(){Xe();}));}function Qe(){ot=false,cancelAnimationFrame(X);}let st=new IntersectionObserver(i=>{i.forEach(c=>{K=c.isIntersecting,K&&!se?(Fe=true,Ye()):Qe();});},{root:we??null,threshold:k,rootMargin:v});function dt(){B.forEach((i,c)=>{O[c]=Ve(i),i.style.strokeDasharray=`${O[c]}`;}),ft(),Fe=true;}let Ze;function qe(){clearTimeout(Ze),Ze=setTimeout(dt,150);}window.addEventListener("resize",qe),window.addEventListener("orientationchange",qe);let We;return typeof ResizeObserver<"u"&&(We=new ResizeObserver(()=>qe()),We.observe(document.body),We.observe(document.documentElement),We.observe(e)),H>0?setTimeout(()=>st.observe(e),H):st.observe(e),{destroy(){cancelAnimationFrame(X),clearTimeout(Ie),Qe(),st.disconnect(),We?.disconnect(),window.removeEventListener("resize",qe),window.removeEventListener("orientationchange",qe),clearTimeout(Ze),lt();},replay(){le=-1,Ce=-1,Ue=-1,j=false,V=false,Re=0,se=false,xe=0,Oe.clear(),clearTimeout(Ie),je(),Fe=true,K&&Ye();},pause(){se=true,Qe();},resume(){se&&(se=false,Fe=true,K&&Ye());},seek(i){let c=Math.min(1,Math.max(0,i));xe=c,le=c,se=true,Qe(),Dt(c,L),Fe=true;},getProgress(){return xe},refresh(){clearTimeout(Ze),dt(),K&&!se&&Ye();}}}var Tt=new Map;function De(e,n){Tt.set(e,n);}function Ne(e){Tt.delete(e);}function Jt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function xt(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let s=[],o=[],a=t[2].trim();if(a)for(let u of a.split(/[\s,]+/)){let m=u.match(/^([-+]?[\d.eE]+)(.*)$/);s.push(m?parseFloat(m[1]):0),o.push(m?m[2]:"");}n.push({fn:t[1],nums:s,units:o});}return n}function Kt(e,n,r){let t=xt(e),s=xt(n);return t.length===0||t.length!==s.length?r<1?e:n:t.map((o,a)=>{let u=s[a];return o.fn!==u.fn||o.nums.length!==u.nums.length?r<1?`${o.fn}(${o.nums.map((m,f)=>`${m}${o.units[f]}`).join(", ")})`:`${u.fn}(${u.nums.map((m,f)=>`${m}${u.units[f]}`).join(", ")})`:`${o.fn}(${o.nums.map((m,f)=>`${m+(u.nums[f]-m)*r}${o.units[f]}`).join(", ")})`}).join(" ")}function At(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),s=String(n);if(Jt(t))return _e(t,s,r);if(t.includes("("))return Kt(t,s,r);let o=t.match(/^([-+]?[\d.]+)(.*)$/),a=s.match(/^([-+]?[\d.]+)(.*)$/);if(o&&a){let u=parseFloat(o[1]),m=parseFloat(a[1]);return `${u+(m-u)*r}${o[2]||a[2]}`}return r<1?t:s}function er(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var tr=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),rr=0,Mt="--scroll-draw-progress";function nr(){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:s={},easing:o="ease-out",speed:a=1,once:u=false,axis:m="y",scrollContainer:f,native:E=true,velocityScale:R=false,respectReducedMotion:L=true,triggerElement:te,onProgress:be,onComplete:N,onEnter:q,onLeave:F,onEnterBack:H,onLeaveBack:M}=n,C=L&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,A=typeof o=="function"?o:Q[o]??Q["ease-out"],w=ne(s.start??"top bottom"),$=ne(s.end??"bottom top"),k=te??e,v=typeof f=="string"?document.querySelector(f):f??null,y=Object.entries(t).map(([l,p])=>({prop:er(l),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function G(){let l=window.getComputedStyle(e);for(let p of y)p.from===""&&(p.from=l.getPropertyValue(p.prop).trim()||"0");}function I(){for(let l of y)e.style.setProperty(l.prop,String(l.to));}let W=new Map;for(let l of [...y.map(p=>p.prop),Mt])W.set(l,e.style.getPropertyValue(l));function U(){for(let[l,p]of W)p?e.style.setProperty(l,p):e.style.removeProperty(l);}if(C)return I(),N?.(),{...r,destroy:U,getProgress:()=>1};G();let oe=typeof o=="string"?et(o):null;function me(){if(!E||!nr()||!oe||m!=="y"||v||k!==e||u||a!==1||be||N||q||F||H||M||R!==false||(s.start??"top bottom").trim()!=="top bottom"||(s.end??"bottom top").trim()!=="bottom top")return false;for(let l of y)if(!tr.has(l.prop))return false;return true}function h(){let l=`ssd-a-${++rr}`,p=y.map(K=>`${K.prop}:${K.from}`).join(";"),Se=y.map(K=>`${K.prop}:${K.to}`).join(";"),V=document.createElement("style");V.setAttribute("data-ssd-animate",""),V.textContent=`@keyframes ${l}{from{${p}}to{${Se}}}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${oe};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(V),e.classList.add(l);let j=()=>m==="x"?window.scrollX:window.scrollY,X=()=>m==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(l),V.remove(),e.style.animationPlayState="",U();},replay(){e.classList.remove(l),e.offsetWidth,e.classList.add(l);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(K){let le=Math.min(1,Math.max(0,K));e.classList.remove(l);for(let Ce of y)e.style.setProperty(Ce.prop,At(Ce.from,Ce.to,le));},getProgress(){let K=e.getBoundingClientRect(),le=j(),Ce=X(),{tStart:se,tEnd:xe}=ye({top:K.top,height:K.height},le,Ce,w,$);return A(Z(le,se,xe,a))}}}if(me())return h();let P=0,g=0,d=0,z=false,de=false,Ee=-1,fe=0,Te=false,Pe=NaN,He=-1,we=0,ve=()=>v?m==="x"?v.scrollLeft:v.scrollTop:m==="x"?window.scrollX:window.scrollY,ie=()=>v?m==="x"?v.clientWidth:v.clientHeight:m==="x"?window.innerWidth:window.innerHeight;function ae(){let l=Je(k,v,m),p=ye(l,l.scroll,ie(),w,$);P=p.tStart,g=p.tEnd;}function J(l){e.style.setProperty(Mt,String(l));for(let p of y)e.style.setProperty(p.prop,At(p.from,p.to,l));be?.(l);}function pe(l){if(isNaN(Pe)){Pe=l;return}Pe<=0&&l>0?q?.():Pe>0&&l<=0&&M?.(),Pe<1&&l>=1?F?.():Pe>=1&&l<1&&H?.(),Pe=l;}function re(){if(!z||de)return;let l=performance.now(),p=ve(),Se=a;if(R!==false){let X=l-we,K=X>0?Math.abs(p-(He<0?p:He))/X:0;Se=a*Math.max(.2,1+K*(typeof R=="number"?R:1)*.04);}He=p,we=l;let V=g===P?0:(p-P)/(g-P);pe(V);let j=A(Z(p,P,g,Se));u&&(Ee=Math.max(Ee,j),j=Ee),fe=j,J(j),j>=1&&!Te?(Te=true,N?.()):j<1&&!u&&(Te=false),d=requestAnimationFrame(re);}ae(),g===P&&he("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let l=A(Z(ve(),P,g,a));u&&l>0&&(Ee=l),fe=l,J(l);}let Le=new IntersectionObserver(l=>{l.forEach(p=>{z=p.isIntersecting,z&&!de?d=requestAnimationFrame(re):cancelAnimationFrame(d);});},{root:v??null}),B;function O(){clearTimeout(B),B=setTimeout(ae,150);}return window.addEventListener("resize",O),window.addEventListener("orientationchange",O),Le.observe(e),De(e,{type:"animate",getProgress:()=>fe,getTrigger:()=>({tStart:P,tEnd:g})}),{destroy(){cancelAnimationFrame(d),Le.disconnect(),window.removeEventListener("resize",O),window.removeEventListener("orientationchange",O),clearTimeout(B),U(),Ne(e);},replay(){Ee=-1,Te=false,fe=0,de=false,J(0);},pause(){de=true,cancelAnimationFrame(d);},resume(){de&&(de=false,z&&(d=requestAnimationFrame(re)));},seek(l){let p=Math.min(1,Math.max(0,l));fe=p,Ee=p,de=true,cancelAnimationFrame(d),J(p);},getProgress(){return fe}}}var at={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Lt(e,n){if(typeof window>"u")return at;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return he("scrollCounter: element not found:",e),at;let t=r,{from:s=0,to:o,format:a,easing:u="ease-out",trigger:m={},once:f=true,decimals:E,onComplete:R}=n,L=E!==void 0?h=>h.toFixed(E):a??(h=>String(Math.round(h))),te=typeof u=="function"?u:Q[u]??Q["ease-out"],be=ne(m.start??"top 80%"),N=ne(m.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=L(o),R?.(),at;let F=0,H=0,M=0,C=false,A=false,w=-1,$=0,k=false,v=()=>window.scrollY,y=()=>window.innerHeight;function G(){let h=t.getBoundingClientRect(),P=ye({top:h.top,height:h.height},v(),y(),be,N);F=P.tStart,H=P.tEnd;}function I(h){t.textContent=L(s+(o-s)*h),t.style.setProperty("--scroll-draw-progress",String(h));}function W(){if(!C||A)return;let h=te(Z(v(),F,H,1));f&&(w=Math.max(w,h),h=w),$=h,I(h),h>=1&&!k?(k=true,R?.()):h<1&&!f&&(k=false),M=requestAnimationFrame(W);}G();{let h=te(Z(v(),F,H,1));f&&h>0&&(w=h),$=h,I(h);}let U=new IntersectionObserver(h=>{h.forEach(P=>{C=P.isIntersecting,C&&!A?M=requestAnimationFrame(W):cancelAnimationFrame(M);});}),oe;function me(){clearTimeout(oe),oe=setTimeout(G,150);}return window.addEventListener("resize",me),window.addEventListener("orientationchange",me),U.observe(t),De(t,{type:"counter",getProgress:()=>$,getTrigger:()=>({tStart:F,tEnd:H})}),{destroy(){cancelAnimationFrame(M),U.disconnect(),window.removeEventListener("resize",me),window.removeEventListener("orientationchange",me),clearTimeout(oe),Ne(t);},replay(){w=-1,k=false,$=0,A=false,I(0);},pause(){A=true,cancelAnimationFrame(M);},resume(){A&&(A=false,C&&(M=requestAnimationFrame(W)));},seek(h){let P=Math.min(1,Math.max(0,h));$=P,w=P,A=true,cancelAnimationFrame(M),I(P);},getProgress(){return $}}}var Ct={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function $t(e,n={}){if(typeof window>"u")return Ct;let r=typeof e=="string"?document.querySelector(e):e;if(!r||r.tagName.toLowerCase()!=="video")return he("scrollVideo: <video> element not found:",e),Ct;let t=r,{trigger:s={},easing:o="linear",once:a=false,axis:u="y",preload:m="auto",onReady:f,onComplete:E,onProgress:R}=n,L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,te=typeof o=="function"?o:Q[o]??Q.linear,be=ne(s.start??"top top"),N=ne(s.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=m);let q=n.from??0,F=n.to,H=0,M=0,C=0,A=false,w=false,$=-1,k=0,v=false,y=false,G=()=>u==="x"?window.scrollX:window.scrollY,I=()=>u==="x"?window.innerWidth:window.innerHeight;function W(){let d=t.getBoundingClientRect(),z=u==="x"?d.left:d.top,de=u==="x"?d.width:d.height,Ee=ye({top:z,height:de},G(),I(),be,N);H=Ee.tStart,M=Ee.tEnd;}function U(d){if(!y)return;let z=F??t.duration??0;t.currentTime=q+(z-q)*d,t.style.setProperty("--scroll-draw-progress",String(d)),R?.(d);}function oe(){if(!A||w||!y)return;let d=te(Z(G(),H,M,1));a&&($=Math.max($,d),d=$),k=d,U(d),d>=1&&!v?(v=true,E?.()):d<1&&!a&&(v=false),C=requestAnimationFrame(oe);}function me(){if(y=true,F===void 0&&(F=t.duration),L){U(1),f?.();return}W(),f?.(),A&&!w&&(C=requestAnimationFrame(oe));}t.readyState>=1?me():t.addEventListener("loadedmetadata",me,{once:true}),y||W();let h=new IntersectionObserver(d=>{d.forEach(z=>{A=z.isIntersecting,A&&!w&&y?C=requestAnimationFrame(oe):cancelAnimationFrame(C);});}),P;function g(){clearTimeout(P),P=setTimeout(W,150);}return window.addEventListener("resize",g),window.addEventListener("orientationchange",g),h.observe(t),De(t,{type:"video",getProgress:()=>k,getTrigger:()=>({tStart:H,tEnd:M})}),{destroy(){cancelAnimationFrame(C),h.disconnect(),t.removeEventListener("loadedmetadata",me),window.removeEventListener("resize",g),window.removeEventListener("orientationchange",g),clearTimeout(P),Ne(t);},replay(){$=-1,v=false,k=0,w=false,U(0);},pause(){w=true,cancelAnimationFrame(C);},resume(){w&&(w=false,A&&y&&(C=requestAnimationFrame(oe)));},seek(d){let z=Math.min(1,Math.max(0,d));k=z,$=z,w=true,cancelAnimationFrame(C),U(z);},getProgress(){return k}}}function It(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 or(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 Rt(e){let n=It(e),r=new Map;for(let o of n){let a=o.offsetTop;r.has(a)||r.set(a,[]),r.get(a).push(o);}let t=[],s=Array.from(r.keys()).sort((o,a)=>o-a);for(let o of s){let a=r.get(o),u=document.createElement("span");u.setAttribute("aria-hidden","true"),u.style.display="inline-block",a.forEach((m,f)=>{let E=m.nextElementSibling;u.appendChild(m),f<a.length-1&&E&&E.style.whiteSpace==="pre"&&u.appendChild(E);}),t.push(u);}return e.textContent="",t.forEach((o,a)=>{e.appendChild(o),a<t.length-1&&e.appendChild(document.createTextNode(" "));}),t}function sr(e,n,r,t){if(r<=1||t===0)return e;let s=(r-1)*t,o=n*t,a=o+(1-s);return a<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(a-o)))}function ir(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 kt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ot(e,n={}){if(typeof window>"u")return kt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return he("scrollText: element not found:",e),kt;let t=r,{split:s="words",stagger:o=.04,easing:a="ease-out",from:u={opacity:0,y:24},trigger:m={},once:f=true,onComplete:E}=n,R=window.matchMedia("(prefers-reduced-motion: reduce)").matches,L=typeof a=="function"?a:Q[a]??Q["ease-out"],te=ne(m.start??"top 85%"),be=ne(m.end??"top 40%"),N=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let q;s==="chars"?q=or(t):s==="lines"?q=Rt(t):q=It(t);let F=q.length;function H(g,d){u?.opacity!==void 0&&(g.style.opacity=String(u.opacity+(1-u.opacity)*d));let z=ir(d,u);z&&(g.style.transform=z);}function M(g){t.style.setProperty("--scroll-draw-progress",String(g)),q.forEach((d,z)=>{let de=L(sr(g,z,F,o));H(d,de);});}if(R)return M(1),E?.(),{destroy(){t.innerHTML=N,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};M(0);let C=0,A=0,w=0,$=false,k=false,v=-1,y=0,G=false,I=()=>window.scrollY,W=()=>window.innerHeight;function U(){let g=t.getBoundingClientRect(),d=ye({top:g.top,height:g.height},I(),W(),te,be);C=d.tStart,A=d.tEnd;}function oe(){if(!$||k)return;let g=Z(I(),C,A,1);f&&(v=Math.max(v,g),g=v),y=g,M(g),g>=1&&!G?(G=true,E?.()):g<1&&!f&&(G=false),w=requestAnimationFrame(oe);}U();let me=new IntersectionObserver(g=>{g.forEach(d=>{$=d.isIntersecting,$&&!k?w=requestAnimationFrame(oe):cancelAnimationFrame(w);});}),h;function P(){clearTimeout(h),h=setTimeout(()=>{if(s==="lines"){let g=y;t.innerHTML=N,t.setAttribute("aria-label",t.textContent??""),q=Rt(t),M(g);}U();},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),me.observe(t),De(t,{type:"text",getProgress:()=>y,getTrigger:()=>({tStart:C,tEnd:A})}),{destroy(){cancelAnimationFrame(w),me.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),clearTimeout(h),t.innerHTML=N,t.removeAttribute("aria-label"),Ne(t);},replay(){v=-1,G=false,y=0,k=false,M(0);},pause(){k=true,cancelAnimationFrame(w);},resume(){k&&(k=false,$&&(w=requestAnimationFrame(oe)));},seek(g){let d=Math.min(1,Math.max(0,g));y=d,v=d,k=true,cancelAnimationFrame(w),M(d);},getProgress(){return y}}}function cr(e,n={}){let[r,t]=useState(0),s=useRef(n);s.current=n;let o=useRef(-1);return useEffect(()=>{if(typeof window>"u")return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t(1);return}let a=typeof e=="string"?document.querySelector(e):e.current;if(!a)return;let u=a,{axis:m="y",scrollContainer:f,trigger:E={}}=s.current,R=typeof f=="string"?document.querySelector(f):f??null,L=ne(E.start??"top bottom"),te=ne(E.end??"bottom top"),be=0,N=0,q=false,F=0;function H(){return R?m==="x"?R.scrollLeft:R.scrollTop:m==="x"?window.scrollX:window.scrollY}function M(){return R?m==="x"?R.clientWidth:R.clientHeight:m==="x"?window.innerWidth:window.innerHeight}function C(){let v=u.getBoundingClientRect(),y=H(),G=m==="x"?v.left:v.top,I=m==="x"?v.width:v.height,W=ye({top:G,height:I},y,M(),L,te);be=W.tStart,N=W.tEnd;}function A(){if(!q)return;let{speed:v=1,easing:y="linear",once:G=false}=s.current,I=typeof y=="function"?y:Q[y]??Q.linear,W=Z(H(),be,N,v),U=I(W);G&&(o.current=Math.max(o.current,U),U=o.current),t(U),F=requestAnimationFrame(A);}let w=new IntersectionObserver(v=>{v.forEach(y=>{q=y.isIntersecting,q?F=requestAnimationFrame(A):cancelAnimationFrame(F);});},{root:R??null,threshold:0});C(),w.observe(u);let $;function k(){clearTimeout($),$=setTimeout(C,150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),()=>{cancelAnimationFrame(F),clearTimeout($),w.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k);}},[]),r}function Xr({children:e,className:n,style:r,...t}){let s=useRef(null);return useEffect(()=>{if(!s.current)return;let o=Et(s.current,t);return ()=>o.destroy()},[]),jsx("div",{ref:s,className:n,style:r,children:e})}function Yr({children:e,className:n,style:r,...t}){let s=useRef(null);return useEffect(()=>{if(!s.current)return;let o=Pt(s.current,t);return ()=>o.destroy()},[]),jsx("div",{ref:s,className:n,style:r,children:e})}function Qr({className:e,style:n,...r}){let t=useRef(null);return useEffect(()=>{if(!t.current)return;let s=Lt(t.current,r);return ()=>s.destroy()},[]),jsx("span",{ref:t,className:e,style:n})}function Zr({src:e,className:n,style:r,muted:t=true,playsInline:s=true,...o}){let a=useRef(null);return useEffect(()=>{if(!a.current)return;let u=$t(a.current,o);return ()=>u.destroy()},[]),jsx("video",{ref:a,src:e,className:n,style:r,muted:t,playsInline:s,preload:"auto"})}function Jr({children:e,as:n="p",className:r,style:t,...s}){let o=useRef(null);return useEffect(()=>{if(!o.current)return;let a=Ot(o.current,s);return ()=>a.destroy()},[]),ur.createElement(n,{ref:o,className:r,style:t},e)}export{Yr as ScrollAnimate,Qr as ScrollCounter,Xr as ScrollDraw,Jr as ScrollText,Zr as ScrollVideo,cr as useScrollDrawProgress};
|
package/dist/reveal/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function Ee({bounces:e=3,decay:n=.5}={}){let t=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,n)),u=Math.sqrt(r),s=0,m=[];for(let c=0;c<t;c++){let p=Math.pow(u,c);m.push(p),s+=p;}let l=[0],a=0;for(let c=0;c<t;c++)a+=m[c]/s,l.push(a);return c=>{if(c<=0)return 0;if(c>=1)return 1;for(let p=0;p<t;p++)if(c<=l[p+1]){let d=(c-l[p])/(l[p+1]-l[p]);if(p===0)return d*(2-d);let v=1-Math.pow(r,p);return v+(1-v)*(2*d-1)*(2*d-1)}return 1}}function xe({amplitude:e=1,period:n=.4}={}){let t=Math.max(1,e),r=Math.max(.1,n),u=t<=1?r/4:r/(2*Math.PI)*Math.asin(1/t);return s=>s<=0?0:s>=1?1:t*Math.pow(2,-10*s)*Math.sin((s-u)*(2*Math.PI)/r)+1}var j={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:Ee(),elastic:xe()};function G(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[t="top",r="bottom"]=n.split(/\s+/).filter(Boolean);return {element:t,viewport:r}}function te(e,n,t,r){switch(r){case "top":return e+t;case "center":return e+t+n/2;case "bottom":return e+t+n;default:return e+t}}function ne(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 Se(e,n,t){return Math.min(t,Math.max(n,e))}function B(e,n,t,r){return t===n?0:Se((e-n)/(t-n)*r,0,1)}function U(e,n,t,r,u){let s=te(e.top,e.height,n,r.element)-ne(r.viewport,t),m=te(e.top,e.height,n,u.element)-ne(u.viewport,t);return {tStart:s,tEnd:m}}function re(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 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 r=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return r?[parseInt(r[1]),parseInt(r[2]),parseInt(r[3])]:null}function oe(e,n,t){let r=re(e),u=re(n);return !r||!u?e:`rgb(${Math.round(r[0]+(u[0]-r[0])*t)},${Math.round(r[1]+(u[1]-r[1])*t)},${Math.round(r[2]+(u[2]-r[2])*t)})`}var se=new Map;function ie(e,n){se.set(e,n);}function ae(e){se.delete(e);}function Me(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ue(e){let n=[],t=/([\w]+)\(([^)]*)\)/g,r;for(;(r=t.exec(e))!==null;){let u=[],s=[],m=r[2].trim();if(m)for(let l of m.split(/[\s,]+/)){let a=l.match(/^([-+]?[\d.eE]+)(.*)$/);u.push(a?parseFloat(a[1]):0),s.push(a?a[2]:"");}n.push({fn:r[1],nums:u,units:s});}return n}function Pe(e,n,t){let r=ue(e),u=ue(n);return r.length===0||r.length!==u.length?t<1?e:n:r.map((s,m)=>{let l=u[m];return s.fn!==l.fn||s.nums.length!==l.nums.length?t<1?`${s.fn}(${s.nums.map((a,c)=>`${a}${s.units[c]}`).join(", ")})`:`${l.fn}(${l.nums.map((a,c)=>`${a}${l.units[c]}`).join(", ")})`:`${s.fn}(${s.nums.map((a,c)=>`${a+(l.nums[c]-a)*t}${s.units[c]}`).join(", ")})`}).join(" ")}function ce(e,n,t){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*t);let r=String(e),u=String(n);if(Me(r))return oe(r,u,t);if(r.includes("("))return Pe(r,u,t);let s=r.match(/^([-+]?[\d.]+)(.*)$/),m=u.match(/^([-+]?[\d.]+)(.*)$/);if(s&&m){let l=parseFloat(s[1]),a=parseFloat(m[1]);return `${l+(a-l)*t}${s[2]||m[2]}`}return t<1?r:u}function $e(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var le={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ae=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Te=0;function Le(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function me(e,n){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let{props:r,trigger:u={},easing:s="ease-out",speed:m=1,once:l=false,axis:a="y",scrollContainer:c,native:p=true,velocityScale:d=false,onProgress:v,onComplete:R,onEnter:F,onLeave:P,onEnterBack:$,onLeaveBack:I}=n,k=window.matchMedia("(prefers-reduced-motion: reduce)").matches,H=typeof s=="function"?s:j[s]??j["ease-out"],Z=G(u.start??"top bottom"),J=G(u.end??"bottom top"),f=typeof c=="string"?document.querySelector(c):c??null,w=Object.entries(r).map(([o,i])=>({prop:$e(o),from:Array.isArray(i)?i[0]:"",to:Array.isArray(i)?i[1]:i}));function fe(){let o=window.getComputedStyle(e);for(let i of w)i.from===""&&(i.from=o.getPropertyValue(i.prop).trim()||"0");}function ge(){for(let o of w)e.style.setProperty(o.prop,String(o.to));}if(k)return ge(),R?.(),t;fe();function de(){if(!p||!Le()||typeof s!="string"||!(s in le)||a!=="y"||f||l||m!==1||v||R||F||P||$||I||d!==false||(u.start??"top bottom").trim()!=="top bottom"||(u.end??"bottom top").trim()!=="bottom top")return false;for(let o of w)if(!Ae.has(o.prop))return false;return true}function be(){let o=`ssd-a-${++Te}`,i=w.map(g=>`${g.prop}:${g.from}`).join(";"),y=w.map(g=>`${g.prop}:${g.to}`).join(";"),h=document.createElement("style");h.setAttribute("data-ssd-animate",""),h.textContent=`@keyframes ${o}{from{${i}}to{${y}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${le[s]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(h),e.classList.add(o);let b=()=>a==="x"?window.scrollX:window.scrollY,D=()=>a==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(o),h.remove();},replay(){e.classList.remove(o),e.offsetWidth,e.classList.add(o);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(g){let N=Math.min(1,Math.max(0,g));e.classList.remove(o);for(let C of w)e.style.setProperty(C.prop,ce(C.from,C.to,N));},getProgress(){let g=e.getBoundingClientRect(),N=b(),C=D(),{tStart:ve,tEnd:we}=U({top:g.top,height:g.height},N,C,Z,J);return H(B(N,ve,we,m))}}}if(de())return be();let E=0,A=0,x=0,O=false,S=false,T=-1,L=0,V=false,M=NaN,Y=-1,K=0,q=()=>f?a==="x"?f.scrollLeft:f.scrollTop:a==="x"?window.scrollX:window.scrollY,he=()=>f?a==="x"?f.clientWidth:f.clientHeight:a==="x"?window.innerWidth:window.innerHeight;function Q(){let o=e.getBoundingClientRect(),i,y;if(f){let b=f.getBoundingClientRect();i=a==="x"?o.left-b.left+f.scrollLeft:o.top-b.top+f.scrollTop,y=a==="x"?o.width:o.height;}else i=a==="x"?o.left:o.top,y=a==="x"?o.width:o.height;let h=U({top:i,height:y},q(),he(),Z,J);E=h.tStart,A=h.tEnd;}function X(o){e.style.setProperty("--scroll-draw-progress",String(o));for(let i of w)e.style.setProperty(i.prop,ce(i.from,i.to,o));v?.(o);}function ye(o){if(isNaN(M)){M=o;return}M<=0&&o>0?F?.():M>0&&o<=0&&I?.(),M<1&&o>=1?P?.():M>=1&&o<1&&$?.(),M=o;}function z(){if(!O||S)return;let o=performance.now(),i=q(),y=m;if(d!==false){let D=o-K,g=D>0?Math.abs(i-(Y<0?i:Y))/D:0;y=m*Math.max(.2,1+g*(typeof d=="number"?d:1)*.04);}Y=i,K=o;let h=A===E?0:(i-E)/(A-E);ye(h);let b=H(B(i,E,A,y));l&&(T=Math.max(T,b),b=T),L=b,X(b),b>=1&&!V?(V=true,R?.()):b<1&&!l&&(V=false),x=requestAnimationFrame(z);}Q();{let o=H(B(q(),E,A,m));l&&o>0&&(T=o),L=o,X(o);}let ee=new IntersectionObserver(o=>{o.forEach(i=>{O=i.isIntersecting,O&&!S?x=requestAnimationFrame(z):cancelAnimationFrame(x);});},{root:f??null}),W;function _(){clearTimeout(W),W=setTimeout(Q,150);}return window.addEventListener("resize",_),window.addEventListener("orientationchange",_),ee.observe(e),ie(e,{type:"animate",getProgress:()=>L,getTrigger:()=>({tStart:E,tEnd:A})}),{destroy(){cancelAnimationFrame(x),ee.disconnect(),window.removeEventListener("resize",_),window.removeEventListener("orientationchange",_),clearTimeout(W),ae(e);},replay(){T=-1,V=false,L=0,S=false,X(0);},pause(){S=true,cancelAnimationFrame(x);},resume(){S&&(S=false,O&&(x=requestAnimationFrame(z)));},seek(o){let i=Math.min(1,Math.max(0,o));L=i,T=i,S=true,cancelAnimationFrame(x),X(i);},getProgress(){return L}}}var Re={fadeUp:{opacity:0,y:32},fadeDown:{opacity:0,y:-32},fadeLeft:{opacity:0,x:32},fadeRight:{opacity:0,x:-32},scale:{opacity:0,scale:.88},flip:{opacity:0,rotateX:20},flipX:{opacity:0,rotateY:20}};function Ie(e){let n={};e.opacity!==void 0&&(n.opacity=[e.opacity,1]);let t=[],r=[];return e.x!==void 0&&(t.push(`translateX(${e.x}px)`),r.push("translateX(0px)")),e.y!==void 0&&(t.push(`translateY(${e.y}px)`),r.push("translateY(0px)")),e.scale!==void 0&&(t.push(`scale(${e.scale})`),r.push("scale(1)")),e.rotate!==void 0&&(t.push(`rotate(${e.rotate}deg)`),r.push("rotate(0deg)")),e.rotateX!==void 0&&(t.push(`rotateX(${e.rotateX}deg)`),r.push("rotateX(0deg)")),e.rotateY!==void 0&&(t.push(`rotateY(${e.rotateY}deg)`),r.push("rotateY(0deg)")),t.length>0&&(n.transform=[t.join(" "),r.join(" ")]),n}function Ne(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e instanceof NodeList?Array.from(e):e}var pe={destroy:()=>{}};function De(e,n={}){if(typeof window>"u")return pe;let t=Ne(e);if(!t.length)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollReveal: no elements found:",e),pe;let{preset:r="fadeUp",from:u,stagger:s=.08,easing:m="ease-out",once:l=true,trigger:a,onEnter:c,onLeave:p}=n,d={...Re[r],...u},v=Ie(d),R=Math.min(s*4,4),F=t.map((P,$)=>{let I=Math.max(50,88-$*R),k=Math.max(20,I-35);return me(P,{props:v,easing:m,once:l,native:false,trigger:a??{start:`top ${I}%`,end:`top ${k}%`},onEnter:$===0?c:void 0,onLeave:$===t.length-1?p:void 0})});return {destroy(){F.forEach(P=>P.destroy());}}}exports.scrollReveal=De;
|
|
1
|
+
'use strict';function Ie({bounces:e=3,decay:n=.5}={}){let t=Math.max(1,Math.round(e)),r=Math.max(.01,Math.min(.99,n)),a=Math.sqrt(r),i=0,m=[];for(let c=0;c<t;c++){let p=Math.pow(a,c);m.push(p),i+=p;}let l=[0],u=0;for(let c=0;c<t;c++)u+=m[c]/i,l.push(u);return c=>{if(c<=0)return 0;if(c>=1)return 1;for(let p=0;p<t;p++)if(c<=l[p+1]){let g=(c-l[p])/(l[p+1]-l[p]);if(p===0)return g*(2-g);let M=1-Math.pow(r,p);return M+(1-M)*(2*g-1)*(2*g-1)}return 1}}function _e({amplitude:e=1,period:n=.4}={}){let t=Math.max(1,e),r=Math.max(.1,n),a=t<=1?r/4:r/(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)/r)+1}var _={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Ie(),elastic:_e()};function U(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[t="top",r="bottom"]=n.split(/\s+/).filter(Boolean);return {element:t,viewport:r}}function ae(e,n,t,r){switch(r){case "top":return e+t;case "center":return e+t+n/2;case "bottom":return e+t+n;default:return e+t}}function ue(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 Ce(e,n,t){return Math.min(t,Math.max(n,e))}function k(e,n,t,r){return t===n?0:Ce((e-n)/(t-n)*r,0,1)}function le(e,n,t){let r=e.getBoundingClientRect(),a=t==="x"?r.width:r.height;return n?{top:t==="x"?r.left-n.getBoundingClientRect().left+n.scrollLeft:r.top-n.getBoundingClientRect().top+n.scrollTop,height:a,scroll:0}:{top:t==="x"?r.left:r.top,height:a,scroll:t==="x"?window.scrollX:window.scrollY}}function Q(e,n,t,r,a){let i=ae(e.top,e.height,n,r.element)-ue(r.viewport,t),m=ae(e.top,e.height,n,a.element)-ue(a.viewport,t);return {tStart:i,tEnd:m}}function ce(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 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 r=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return r?[parseInt(r[1]),parseInt(r[2]),parseInt(r[3])]:null}function me(e,n,t){let r=ce(e),a=ce(n);return !r||!a?e:`rgb(${Math.round(r[0]+(a[0]-r[0])*t)},${Math.round(r[1]+(a[1]-r[1])*t)},${Math.round(r[2]+(a[2]-r[2])*t)})`}var Ne="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Fe="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",pe=33;function Oe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Ve(e){let n=[];for(let t=0;t<pe;t++){let r=t/(pe-1);n.push(String(Math.round(e(r)*1e5)/1e5));}return `linear(${n.join(",")})`}function fe(e){switch(e){case "linear":return "linear";case "ease-in":return Ne;case "ease-out":return Fe;case "ease-in-out":return Oe()?Ve(_["ease-in-out"]):null;default:return null}}var ge=new Map;function de(e,n){ge.set(e,n);}function be(e){ge.delete(e);}var De=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function B(e,...n){De&&console.warn(`[svg-scroll-draw] ${e}`,...n);}function He(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function he(e){let n=[],t=/([\w]+)\(([^)]*)\)/g,r;for(;(r=t.exec(e))!==null;){let a=[],i=[],m=r[2].trim();if(m)for(let l of m.split(/[\s,]+/)){let u=l.match(/^([-+]?[\d.eE]+)(.*)$/);a.push(u?parseFloat(u[1]):0),i.push(u?u[2]:"");}n.push({fn:r[1],nums:a,units:i});}return n}function Xe(e,n,t){let r=he(e),a=he(n);return r.length===0||r.length!==a.length?t<1?e:n:r.map((i,m)=>{let l=a[m];return i.fn!==l.fn||i.nums.length!==l.nums.length?t<1?`${i.fn}(${i.nums.map((u,c)=>`${u}${i.units[c]}`).join(", ")})`:`${l.fn}(${l.nums.map((u,c)=>`${u}${l.units[c]}`).join(", ")})`:`${i.fn}(${i.nums.map((u,c)=>`${u+(l.nums[c]-u)*t}${i.units[c]}`).join(", ")})`}).join(" ")}function ye(e,n,t){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*t);let r=String(e),a=String(n);if(He(r))return me(r,a,t);if(r.includes("("))return Xe(r,a,t);let i=r.match(/^([-+]?[\d.]+)(.*)$/),m=a.match(/^([-+]?[\d.]+)(.*)$/);if(i&&m){let l=parseFloat(i[1]),u=parseFloat(m[1]);return `${l+(u-l)*t}${i[2]||m[2]}`}return t<1?r:a}function ke(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var Be=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),ze=0,we="--scroll-draw-progress";function We(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ee(e,n){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let{props:r,trigger:a={},easing:i="ease-out",speed:m=1,once:l=false,axis:u="y",scrollContainer:c,native:p=true,velocityScale:g=false,respectReducedMotion:M=true,triggerElement:z,onProgress:C,onComplete:w,onEnter:P,onLeave:A,onEnterBack:N,onLeaveBack:Z}=n,ve=M&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=typeof i=="function"?i:_[i]??_["ease-out"],J=U(a.start??"top bottom"),K=U(a.end??"bottom top"),ee=z??e,d=typeof c=="string"?document.querySelector(c):c??null,b=Object.entries(r).map(([o,s])=>({prop:ke(o),from:Array.isArray(s)?s[0]:"",to:Array.isArray(s)?s[1]:s}));function xe(){let o=window.getComputedStyle(e);for(let s of b)s.from===""&&(s.from=o.getPropertyValue(s.prop).trim()||"0");}function Me(){for(let o of b)e.style.setProperty(o.prop,String(o.to));}let te=new Map;for(let o of [...b.map(s=>s.prop),we])te.set(o,e.style.getPropertyValue(o));function Y(){for(let[o,s]of te)s?e.style.setProperty(o,s):e.style.removeProperty(o);}if(ve)return Me(),w?.(),{...t,destroy:Y,getProgress:()=>1};xe();let ne=typeof i=="string"?fe(i):null;function Pe(){if(!p||!We()||!ne||u!=="y"||d||ee!==e||l||m!==1||C||w||P||A||N||Z||g!==false||(a.start??"top bottom").trim()!=="top bottom"||(a.end??"bottom top").trim()!=="bottom top")return false;for(let o of b)if(!Be.has(o.prop))return false;return true}function Te(){let o=`ssd-a-${++ze}`,s=b.map(f=>`${f.prop}:${f.from}`).join(";"),H=b.map(f=>`${f.prop}:${f.to}`).join(";"),R=document.createElement("style");R.setAttribute("data-ssd-animate",""),R.textContent=`@keyframes ${o}{from{${s}}to{${H}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${ne};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(R),e.classList.add(o);let y=()=>u==="x"?window.scrollX:window.scrollY,X=()=>u==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(o),R.remove(),e.style.animationPlayState="",Y();},replay(){e.classList.remove(o),e.offsetWidth,e.classList.add(o);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(f){let $=Math.min(1,Math.max(0,f));e.classList.remove(o);for(let I of b)e.style.setProperty(I.prop,ye(I.from,I.to,$));},getProgress(){let f=e.getBoundingClientRect(),$=y(),I=X(),{tStart:Ae,tEnd:$e}=Q({top:f.top,height:f.height},$,I,J,K);return W(k($,Ae,$e,m))}}}if(Pe())return Te();let h=0,E=0,S=0,F=false,v=false,T=-1,L=0,O=false,x=NaN,G=-1,re=0,oe=()=>d?u==="x"?d.scrollLeft:d.scrollTop:u==="x"?window.scrollX:window.scrollY,Le=()=>d?u==="x"?d.clientWidth:d.clientHeight:u==="x"?window.innerWidth:window.innerHeight;function se(){let o=le(ee,d,u),s=Q(o,o.scroll,Le(),J,K);h=s.tStart,E=s.tEnd;}function V(o){e.style.setProperty(we,String(o));for(let s of b)e.style.setProperty(s.prop,ye(s.from,s.to,o));C?.(o);}function Re(o){if(isNaN(x)){x=o;return}x<=0&&o>0?P?.():x>0&&o<=0&&Z?.(),x<1&&o>=1?A?.():x>=1&&o<1&&N?.(),x=o;}function j(){if(!F||v)return;let o=performance.now(),s=oe(),H=m;if(g!==false){let X=o-re,f=X>0?Math.abs(s-(G<0?s:G))/X:0;H=m*Math.max(.2,1+f*(typeof g=="number"?g:1)*.04);}G=s,re=o;let R=E===h?0:(s-h)/(E-h);Re(R);let y=W(k(s,h,E,H));l&&(T=Math.max(T,y),y=T),L=y,V(y),y>=1&&!O?(O=true,w?.()):y<1&&!l&&(O=false),S=requestAnimationFrame(j);}se(),E===h&&B("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let o=W(k(oe(),h,E,m));l&&o>0&&(T=o),L=o,V(o);}let ie=new IntersectionObserver(o=>{o.forEach(s=>{F=s.isIntersecting,F&&!v?S=requestAnimationFrame(j):cancelAnimationFrame(S);});},{root:d??null}),q;function D(){clearTimeout(q),q=setTimeout(se,150);}return window.addEventListener("resize",D),window.addEventListener("orientationchange",D),ie.observe(e),de(e,{type:"animate",getProgress:()=>L,getTrigger:()=>({tStart:h,tEnd:E})}),{destroy(){cancelAnimationFrame(S),ie.disconnect(),window.removeEventListener("resize",D),window.removeEventListener("orientationchange",D),clearTimeout(q),Y(),be(e);},replay(){T=-1,O=false,L=0,v=false,V(0);},pause(){v=true,cancelAnimationFrame(S);},resume(){v&&(v=false,F&&(S=requestAnimationFrame(j)));},seek(o){let s=Math.min(1,Math.max(0,o));L=s,T=s,v=true,cancelAnimationFrame(S),V(s);},getProgress(){return L}}}var Ye={fadeUp:{opacity:0,y:32},fadeDown:{opacity:0,y:-32},fadeLeft:{opacity:0,x:32},fadeRight:{opacity:0,x:-32},scale:{opacity:0,scale:.88},flip:{opacity:0,rotateX:20},flipX:{opacity:0,rotateY:20}};function Ge(e){let n={};e.opacity!==void 0&&(n.opacity=[e.opacity,1]);let t=[],r=[];return e.x!==void 0&&(t.push(`translateX(${e.x}px)`),r.push("translateX(0px)")),e.y!==void 0&&(t.push(`translateY(${e.y}px)`),r.push("translateY(0px)")),e.scale!==void 0&&(t.push(`scale(${e.scale})`),r.push("scale(1)")),e.rotate!==void 0&&(t.push(`rotate(${e.rotate}deg)`),r.push("rotate(0deg)")),e.rotateX!==void 0&&(t.push(`rotateX(${e.rotateX}deg)`),r.push("rotateX(0deg)")),e.rotateY!==void 0&&(t.push(`rotateY(${e.rotateY}deg)`),r.push("rotateY(0deg)")),t.length>0&&(n.transform=[t.join(" "),r.join(" ")]),n}function je(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e instanceof NodeList?Array.from(e):e}var Se={destroy:()=>{}};function it(e,n={}){if(typeof window>"u")return Se;let t=je(e);if(!t.length)return B("scrollReveal: no elements found:",e),Se;let{preset:r="fadeUp",from:a,stagger:i=.08,easing:m="ease-out",once:l=true,trigger:u,onEnter:c,onLeave:p}=n,g={...Ye[r],...a},M=Ge(g),z=Math.min(i*4,4),C=t.map((w,P)=>{let A=Math.max(50,88-P*z),N=Math.max(20,A-35);return Ee(w,{props:M,easing:m,once:l,native:false,trigger:u??{start:`top ${A}%`,end:`top ${N}%`},onEnter:P===0?c:void 0,onLeave:P===t.length-1?p:void 0})});return {destroy(){C.forEach(w=>w.destroy());}}}exports.scrollReveal=it;
|