svg-scroll-draw 2.10.0 → 2.10.1
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/README.md +17 -10
- package/dist/angular/index.cjs +2 -2
- package/dist/angular/index.mjs +2 -2
- package/dist/astro/index.cjs +2 -2
- package/dist/astro/index.mjs +2 -2
- package/dist/cdn/svg-scroll-draw.dev.global.js +54 -29
- package/dist/cdn/svg-scroll-draw.global.js +2 -2
- package/dist/cinematic/index.cjs +2 -2
- package/dist/cinematic/index.mjs +2 -2
- package/dist/devtools/index.cjs +1 -1
- package/dist/devtools/index.mjs +1 -1
- package/dist/group/index.cjs +2 -2
- package/dist/group/index.mjs +2 -2
- package/dist/horizontal/index.cjs +1 -1
- package/dist/horizontal/index.mjs +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/nuxt/index.cjs +2 -2
- package/dist/nuxt/index.mjs +2 -2
- 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.mjs +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.mjs +2 -2
- 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.mjs +1 -1
- package/dist/solid/index.cjs +2 -2
- package/dist/solid/index.mjs +2 -2
- package/dist/svelte/index.cjs +2 -2
- package/dist/svelte/index.mjs +2 -2
- package/dist/text/index.cjs +1 -1
- package/dist/text/index.mjs +1 -1
- package/dist/timeline/index.cjs +8 -8
- package/dist/timeline/index.mjs +8 -8
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.mjs +1 -1
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.mjs +2 -2
- package/dist/web-component/index.cjs +3 -3
- package/dist/web-component/index.mjs +3 -3
- package/package.json +19 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var SvgScrollDraw=(()=>{var
|
|
1
|
+
"use strict";var SvgScrollDraw=(()=>{var lt=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var jt=Object.prototype.hasOwnProperty;var Yt=(e,t)=>{for(var r in t)lt(e,r,{get:t[r],enumerable:!0})},Ut=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gt(t))!jt.call(e,i)&&i!==r&<(e,i,{get:()=>t[i],enumerable:!(n=Bt(t,i))||n.enumerable});return e};var Xt=e=>Ut(lt({},"__esModule",{value:!0}),e);var yr={};Yt(yr,{Cinematic:()=>rt,PRESETS:()=>Ze,createBounce:()=>ct,createElastic:()=>ut,createSpring:()=>At,scrollAnimate:()=>Ft,scrollCounter:()=>Ht,scrollDraw:()=>gr,scrollParallax:()=>Nt});function At({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function ct({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),i=Math.sqrt(n),a=0,f=[];for(let p=0;p<r;p++){let x=Math.pow(i,p);f.push(x),a+=x}let m=[0],c=0;for(let p=0;p<r;p++)c+=f[p]/a,m.push(c);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let x=0;x<r;x++)if(p<=m[x+1]){let I=(p-m[x])/(m[x+1]-m[x]);if(x===0)return I*(2-I);let A=1-Math.pow(n,x);return A+(1-A)*(2*I-1)*(2*I-1)}return 1}}function ut({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),i=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return a=>a<=0?0:a>=1?1:r*Math.pow(2,-10*a)*Math.sin((a-i)*(2*Math.PI)/n)+1}var Z={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:ct(),elastic:ut()};function $e(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 Et(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 xt(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 Ve(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(r+n)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function Qt(e,t,r){return Math.min(r,Math.max(t,e))}function le(e,t,r,n){return r===t?0:Qt((e-t)/(r-t)*n,0,1)}function Qe(e,t,r){let n=e.getBoundingClientRect(),i=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:i,scroll:0}:{top:r==="x"?n.left:n.top,height:i,scroll:r==="x"?window.scrollX:window.scrollY}}function Fe(e,t,r,n,i){let a=Et(e.top,e.height,t,n.element)-xt(n.viewport,r),f=Et(e.top,e.height,t,i.element)-xt(i.viewport,r);return{tStart:a,tEnd:f}}function Tt(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[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 n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function ze(e,t,r){let n=Tt(e),i=Tt(t);return!n||!i?e:`rgb(${Math.round(n[0]+(i[0]-n[0])*r)},${Math.round(n[1]+(i[1]-n[1])*r)},${Math.round(n[2]+(i[2]-n[2])*r)})`}var Ze={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:!1},reveal:{easing:"ease-out",fade:!0,speed:1.2,once:!0},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:!0,speed:.75},spring:{easing:"spring",speed:1.1}};function K(e,...t){}var Zt="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Kt="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",$t=33;function Jt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function er(e){let t=[];for(let r=0;r<$t;r++){let n=r/($t-1);t.push(String(Math.round(e(n)*1e5)/1e5))}return`linear(${t.join(",")})`}function Ke(e){switch(e){case"linear":return"linear";case"ease-in":return Zt;case"ease-out":return Kt;case"ease-in-out":return Jt()?er(Z["ease-in-out"]):null;default:return null}}var Mt=Symbol.for("svg-scroll-draw.registry");function Pt(){let e=globalThis;return e[Mt]||(e[Mt]=new Map)}function Me(e,t){Pt().set(e,t)}function Pe(e){Pt().delete(e)}var tr=0;function rr(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function nr(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?K("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&K("Element has a fill \u2014 it may obscure the stroke animation.",e)}function or(e,t,r){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function i(){let a=r==="x"?window.scrollX:window.scrollY,f=e-a,m=t-a,c=r==="x";n.innerHTML=`
|
|
2
2
|
<div style="position:absolute;${c?`left:${f}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${f}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
-
<div style="position:absolute;${c?`left:${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(n),window.addEventListener("scroll",i,{passive:!0}),i(),{el:n,destroy(){window.removeEventListener("scroll",i),n.remove()}}}var Tt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,$t=/[MmLlHhVvCcSsQqTtAaZz]/g;function rr(e,t,r){if(!!1)return;let n=(e.match($t)??[]).join("").toUpperCase(),i=(t.match($t)??[]).join("").toUpperCase(),l=(e.match(Tt)??[]).length,f=(t.match(Tt)??[]).length;if(n!==i){K(`morphTo: command sequence differs (${n||"\u2205"} \u2192 ${i||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}l!==f&&K(`morphTo: coordinate count differs (${l} \u2192 ${f}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r)}function ut(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,l=>{let f=parseFloat(l),u=n[i++]??f;return String(+(f+(u-f)*r).toFixed(4))})}function Ze(e,t={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,i=r?{...Ye[r],...n}:n,l=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:f="path, polyline, line, polygon, rect, circle",speed:u=1,fade:c=!1,easing:p="linear",trigger:E={},stagger:D=0,direction:A="forward",once:ee=!1,debug:Ee=!1,axis:T="y",scrollContainer:$,autoReverse:g=!1,delay:S=0,strokeColor:h,strokeWidth:z,fillOpacity:R,waypoints:B,velocityScale:te=!1,threshold:de=0,rootMargin:j="0px",repeat:q=0,repeatDelay:Me=0,morphTo:N,clip:ge,autoplay:Pe=!1,duration:ke=1e3,native:Le=!0,onProgress:b,onStart:P,onComplete:oe,onEnter:ye,onLeave:Fe,onEnterBack:he,onLeaveBack:xe}=i,re=ge===!0?"left":typeof ge=="string"?ge:!1,ue=typeof p=="function"?p:J[p]??J.linear,be=$e(E.start??"top bottom"),Re=$e(E.end??"bottom top"),ae=typeof $=="string"?document.querySelector($):$??null,le=Array.isArray(h)?h[0]:null,U=Array.isArray(h)?h[1]:typeof h=="string"?h:null,X=Array.isArray(z)?z[0]:null,H=Array.isArray(z)?z[1]:typeof z=="number"?z:null,ne=Array.isArray(R)?R[0]:null,W=Array.isArray(R)?R[1]:typeof R=="number"?R:null;function we(o){let a=o*100;switch(re){case"right":return`inset(0 0 0 ${100-a}%)`;case"top":return`inset(0 0 ${100-a}% 0)`;case"bottom":return`inset(${100-a}% 0 0 0)`;case"center":return`circle(${o*150}% at 50% 50%)`;default:return`inset(0 ${100-a}% 0 0)`}}let C=re?[]:Array.from(e.querySelectorAll(f)),x=[],s=[],m=0,ce=0,k=!1,I=!1,O=0,_=!1,Y=-1,ve=-1,G=!1,me=0,Ae=0,Ce,nt=null;function pt(){nt?.destroy(),nt=null}let De=new Set,dt=NaN,Ie=!0,qe=-1,gt=performance.now(),Ne=NaN;function ot(){return ae?T==="x"?ae.scrollLeft:ae.scrollTop:T==="x"?window.scrollX:window.scrollY}function yt(){return ae?T==="x"?ae.clientWidth:ae.clientHeight:T==="x"?window.innerWidth:window.innerHeight}function ht(){let o=Xe(e,ae,T),a=Oe(o,o.scroll,yt(),be,Re);m=a.tStart,ce=a.tEnd,Ee&&!1&&(pt(),nt=tr(m,ce,T))}function Nt(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),re){let w=a==="reverse"?1-o:o;e.style.clipPath=we(w);return}C.forEach((w,Q)=>{w.style.strokeDashoffset=a==="reverse"?`${x[Q]*o}`:`${x[Q]*(1-o)}`,c&&(w.style.opacity=a==="reverse"?`${1-o}`:`${o}`),le&&U?w.style.stroke=_e(le,U,o):U&&(w.style.stroke=U),X!==null&&H!==null?w.style.strokeWidth=`${X+(H-X)*o}`:H!==null&&(w.style.strokeWidth=`${H}`),ne!==null&&W!==null?w.style.fillOpacity=`${ne+(W-ne)*o}`:W!==null&&(w.style.fillOpacity=`${W}`),N&&w.tagName.toLowerCase()==="path"&&s[Q]&&w.setAttribute("d",ut(s[Q],N,o))})}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),re){e.style.clipPath=we(0);return}C.forEach((o,a)=>{o.style.strokeDasharray=`${x[a]}`,o.style.strokeDashoffset=A==="reverse"?"0":`${x[a]}`,c?o.style.opacity=A==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),X!==null&&(o.style.strokeWidth=`${X}`),ne!==null&&(o.style.fillOpacity=`${ne}`),N&&o.tagName.toLowerCase()==="path"&&s[a]&&o.setAttribute("d",s[a])})}if(C.forEach(o=>{er(o);let a=He(o);x.push(a);let w=o.tagName.toLowerCase()==="path";w?s.push(o.getAttribute("d")??""):s.push(""),N&&(w?rr(s[s.length-1],N,o):K(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),l?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=A==="reverse"?`${a}`:"0",c&&(o.style.opacity="1"),U&&(o.style.stroke=U),H!==null&&(o.style.strokeWidth=`${H}`),W!==null&&(o.style.fillOpacity=`${W}`),N&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",N)):(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=A==="reverse"?"0":`${a}`,c?o.style.opacity=A==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),X!==null&&(o.style.strokeWidth=`${X}`),ne!==null&&(o.style.fillOpacity=`${ne}`))}),re){if(l)return e.style.clipPath=we(1),oe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=we(0)}else if(l)return oe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let bt=typeof p=="string"?Qe(p):null;function Ht(){return!(Le===!1||!Kt()||!C.length||!bt||re||T!=="y"||ae||u!==1||D!==0||ee||g||te!==!1||N||B||q||S>0||b||P||oe||ye||Fe||he||xe||h!=null||z!=null||R!=null||(E.start??"top bottom").trim()!=="top bottom"||(E.end??"bottom top").trim()!=="bottom top")}function _t(){let o=++Jt,a=`svg-scroll-draw-${o}`,w=`svg-scroll-draw-host-${o}`,Q=`--svg-scroll-draw-${o}`,Te=A==="reverse"?"0":"var(--ssd-len)",Se=A==="reverse"?"var(--ssd-len)":"0",pe=`stroke-dashoffset:${Te};`,v=`stroke-dashoffset:${Se};`;c&&(pe+=`opacity:${A==="reverse"?1:0};`,v+=`opacity:${A==="reverse"?0:1};`);let M=document.createElement("style");M.setAttribute("data-svg-scroll-draw",""),M.textContent=`@keyframes ${a}{from{${pe}}to{${v}}}.${w}{view-timeline-name:${Q};view-timeline-axis:block;}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${bt};animation-fill-mode:both;animation-timeline:${Q};animation-range:cover 0% cover 100%;}`,document.head.appendChild(M),e.classList.add(w);function Z(d,V){d.style.setProperty("--ssd-len",String(x[V])),d.style.strokeDasharray=`${x[V]}`,d.style.strokeDashoffset="",d.style.opacity="",d.style.animationPlayState="",d.classList.add(a)}C.forEach(Z);let y=!1,L=-1;function F(){if(L>=0)return L;let d=e.getBoundingClientRect(),{tStart:V,tEnd:fe}=Oe({top:d.top,height:d.height},ot(),yt(),be,Re);return ue(ie(ot(),V,fe,u))}return{destroy(){e.classList.remove(w),C.forEach(d=>{d.classList.remove(a),d.style.removeProperty("--ssd-len"),d.style.animationPlayState=""}),M.remove()},replay(){y=!1,L=-1,C.forEach(Z)},pause(){y=!0,C.forEach(d=>{d.style.animationPlayState="paused"})},resume(){y&&(y=!1,C.forEach(d=>{d.style.animationPlayState="running"}))},seek(d){let V=Math.min(1,Math.max(0,d));L=V,y=!0,C.forEach((fe,se)=>{fe.classList.remove(a),fe.style.strokeDashoffset=A==="reverse"?`${x[se]*V}`:`${x[se]*(1-V)}`,c&&(fe.style.opacity=A==="reverse"?`${1-V}`:`${V}`)})},getProgress(){return F()},refresh(){C.forEach((d,V)=>{x[V]=He(d),d.style.setProperty("--ssd-len",String(x[V])),d.style.strokeDasharray=`${x[V]}`})}}}if(Ht())return _t();function Vt(){let o=Math.max(1,ke),a=0,w=0,Q=!1;function Te(y){let L=!0;if(re){let F=Math.min(1,Math.max(0,y/o)),d=ue(F);me=d,e.style.setProperty("--scroll-draw-progress",String(d)),e.style.clipPath=we(A==="reverse"?1-d:d),b?.(d),F<1&&(L=!1)}else C.forEach((F,d)=>{let V=d*D*o,fe=Math.min(1,Math.max(0,(y-V)/o)),se=ue(fe);F.style.strokeDashoffset=A==="reverse"?`${x[d]*se}`:`${x[d]*(1-se)}`,c&&(F.style.opacity=A==="reverse"?`${1-se}`:`${se}`),le&&U?F.style.stroke=_e(le,U,se):U&&(F.style.stroke=U),X!==null&&H!==null?F.style.strokeWidth=`${X+(H-X)*se}`:H!==null&&(F.style.strokeWidth=`${H}`),ne!==null&&W!==null?F.style.fillOpacity=`${ne+(W-ne)*se}`:W!==null&&(F.style.fillOpacity=`${W}`),N&&F.tagName.toLowerCase()==="path"&&s[d]&&F.setAttribute("d",ut(s[d],N,se)),d===0&&(me=se,b?.(se),e.style.setProperty("--scroll-draw-progress",String(se))),fe<1&&(L=!1)});if(B){let F=Math.min(1,Math.max(0,y/o)),d=ue(F);for(let V in B){let fe=parseFloat(V);d>=fe&&!De.has(fe)&&(De.add(fe),B[V]?.())}}return L}function Se(y){if(G)return;let L=y-a;I||(I=!0,P?.());let F=Te(L);if(F&&!k){k=!0,Te(o*(1+Math.max(0,C.length-1)*D)),oe?.(),Ae<(q==="infinite"?1/0:q??0)&&(Ae++,Ce=setTimeout(()=>{a=performance.now(),I=!1,k=!1,De.clear(),We(),O=requestAnimationFrame(Se)},Me));return}F||(O=requestAnimationFrame(Se))}function pe(){cancelAnimationFrame(O),clearTimeout(Ce),a=performance.now(),w=0,G=!1,I=!1,k=!1,Ae=0,Q=!0,me=0,De.clear(),We(),O=requestAnimationFrame(Se)}let v=new IntersectionObserver(y=>{y.forEach(L=>{L.isIntersecting&&!(ee&&k)?pe():!L.isIntersecting&&!ee&&!k&&(cancelAnimationFrame(O),clearTimeout(Ce),Q=!1)})},{root:ae??null,threshold:de,rootMargin:j}),M;function Z(){clearTimeout(M),M=setTimeout(()=>{C.forEach((y,L)=>{x[L]=He(y),y.style.strokeDasharray=`${x[L]}`})},150)}return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),S>0?setTimeout(()=>v.observe(e),S):v.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ce),v.disconnect(),window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z),clearTimeout(M)},replay(){Ae=0,pe()},pause(){G||!Q||(G=!0,w=performance.now()-a,cancelAnimationFrame(O))},resume(){G&&(G=!1,Q=!0,a=performance.now()-w,O=requestAnimationFrame(Se))},seek(y){let L=Math.min(1,Math.max(0,y));me=L,G=!0,w=L*o,a=performance.now()-w,cancelAnimationFrame(O),Te(w)},getProgress(){return me},refresh(){clearTimeout(M),C.forEach((y,L)=>{x[L]=He(y),y.style.strokeDasharray=`${x[L]}`})}}}if(Pe)return Vt();ht();function Be(){if(!_||G)return;let o=performance.now(),a=ot();if(!Ie&&te===!1&&a===dt){O=requestAnimationFrame(Be);return}Ie=!1,dt=a;let w=u;if(te!==!1){let v=o-gt,M=v>0?Math.abs(a-(qe<0?a:qe))/v:0;w=u*Math.max(.2,1+M*(typeof te=="number"?te:1)*.04)}qe=a,gt=o;let Q=g?ve===-1||a>=ve?"forward":"reverse":A;ve=a;let Te=ce-m,Se=!0,pe=Te===0?0:(a-m)/Te;if(isNaN(Ne)||(Ne<=0&&pe>0?ye?.():Ne>0&&pe<=0&&xe?.(),Ne<1&&pe>=1?Fe?.():Ne>=1&&pe<1&&he?.()),Ne=pe,re){let v=ue(ie(a,m,ce,w));ee&&!g&&(Y=Math.max(Y,v),v=Y),me=v,e.style.setProperty("--scroll-draw-progress",String(v));let M=Q==="reverse"?1-v:v;e.style.clipPath=we(M),b?.(v),!I&&ie(a,m,ce,w)>0&&(I=!0,P?.()),v>=1&&!k?(k=!0,oe?.(),Ae<(q==="infinite"?1/0:q??0)&&(Ae++,Ce=setTimeout(()=>{Y=-1,I=!1,k=!1,e.style.clipPath=we(0)},Me))):v<1&&!ee&&(k=!1),O=requestAnimationFrame(Be);return}if(C.forEach((v,M)=>{let Z=M*D*Te,y=ue(ie(a,m+Z,ce+Z,w));ee&&!g&&(Y=Math.max(Y,y),y=Y),me=y,v.style.strokeDashoffset=Q==="reverse"?`${x[M]*y}`:`${x[M]*(1-y)}`,c&&(v.style.opacity=Q==="reverse"?`${1-y}`:`${y}`),le&&U?v.style.stroke=_e(le,U,y):U&&(v.style.stroke=U),X!==null&&H!==null?v.style.strokeWidth=`${X+(H-X)*y}`:H!==null&&(v.style.strokeWidth=`${H}`),ne!==null&&W!==null?v.style.fillOpacity=`${ne+(W-ne)*y}`:W!==null&&(v.style.fillOpacity=`${W}`),N&&v.tagName.toLowerCase()==="path"&&s[M]&&v.setAttribute("d",ut(s[M],N,y)),M===0&&(b?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(Se=!1)}),B){let v=ue(ie(a,m,ce,w));for(let M in B){let Z=parseFloat(M);v>=Z&&!De.has(Z)&&(De.add(Z),B[M]?.())}}!I&&ie(a,m,ce,w)>0&&(I=!0,P?.()),Se&&!k?(k=!0,oe?.(),Ae<(q==="infinite"?1/0:q??0)&&(Ae++,Ce=setTimeout(()=>{Y=-1,I=!1,k=!1,De.clear(),We(),Ie=!0},Me))):!Se&&!ee&&(k=!1),O=requestAnimationFrame(Be)}let st=!1;function Ge(){st||(st=!0,O=requestAnimationFrame(function(){Be()}))}function je(){st=!1,cancelAnimationFrame(O)}let it=new IntersectionObserver(o=>{o.forEach(a=>{_=a.isIntersecting,_&&!G?(Ie=!0,Ge()):je()})},{root:ae??null,threshold:de,rootMargin:j});function wt(){C.forEach((o,a)=>{x[a]=He(o),o.style.strokeDasharray=`${x[a]}`}),ht(),Ie=!0}let Ue;function Ve(){clearTimeout(Ue),Ue=setTimeout(wt,150)}window.addEventListener("resize",Ve),window.addEventListener("orientationchange",Ve);let ze;return typeof ResizeObserver<"u"&&(ze=new ResizeObserver(()=>Ve()),ze.observe(document.body),ze.observe(document.documentElement),ze.observe(e)),S>0?setTimeout(()=>it.observe(e),S):it.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ce),je(),it.disconnect(),ze?.disconnect(),window.removeEventListener("resize",Ve),window.removeEventListener("orientationchange",Ve),clearTimeout(Ue),pt()},replay(){Y=-1,ve=-1,qe=-1,I=!1,k=!1,Ae=0,G=!1,me=0,De.clear(),clearTimeout(Ce),We(),Ie=!0,_&&Ge()},pause(){G=!0,je()},resume(){G&&(G=!1,Ie=!0,_&&Ge())},seek(o){let a=Math.min(1,Math.max(0,o));me=a,Y=a,G=!0,je(),Nt(a,A),Ie=!0},getProgress(){return me},refresh(){clearTimeout(Ue),wt(),_&&!G&&Ge()}}}var Pt=new Map;function Je(e,t){Pt.set(e,t)}function Ke(e){Pt.delete(e)}function nr(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function kt(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let i=[],l=[],f=n[2].trim();if(f)for(let u of f.split(/[\s,]+/)){let c=u.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(c?parseFloat(c[1]):0),l.push(c?c[2]:"")}t.push({fn:n[1],nums:i,units:l})}return t}function or(e,t,r){let n=kt(e),i=kt(t);return n.length===0||n.length!==i.length?r<1?e:t:n.map((l,f)=>{let u=i[f];return l.fn!==u.fn||l.nums.length!==u.nums.length?r<1?`${l.fn}(${l.nums.map((c,p)=>`${c}${l.units[p]}`).join(", ")})`:`${u.fn}(${u.nums.map((c,p)=>`${c}${u.units[p]}`).join(", ")})`:`${l.fn}(${l.nums.map((c,p)=>`${c+(u.nums[p]-c)*r}${l.units[p]}`).join(", ")})`}).join(" ")}function Lt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),i=String(t);if(nr(n))return _e(n,i,r);if(n.includes("("))return or(n,i,r);let l=n.match(/^([-+]?[\d.]+)(.*)$/),f=i.match(/^([-+]?[\d.]+)(.*)$/);if(l&&f){let u=parseFloat(l[1]),c=parseFloat(f[1]);return`${u+(c-u)*r}${l[2]||f[2]}`}return r<1?n:i}function sr(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var ir=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),ar=0,Ct="--scroll-draw-progress";function lr(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Dt(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:i={},easing:l="ease-out",speed:f=1,once:u=!1,axis:c="y",scrollContainer:p,native:E=!0,velocityScale:D=!1,respectReducedMotion:A=!0,triggerElement:ee,onProgress:Ee,onComplete:T,onEnter:$,onLeave:g,onEnterBack:S,onLeaveBack:h}=t,z=A&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,R=typeof l=="function"?l:J[l]??J["ease-out"],B=$e(i.start??"top bottom"),te=$e(i.end??"bottom top"),de=ee??e,j=typeof p=="string"?document.querySelector(p):p??null,q=Object.entries(n).map(([s,m])=>({prop:sr(s),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function Me(){let s=window.getComputedStyle(e);for(let m of q)m.from===""&&(m.from=s.getPropertyValue(m.prop).trim()||"0")}function N(){for(let s of q)e.style.setProperty(s.prop,String(s.to))}let ge=new Map;for(let s of[...q.map(m=>m.prop),Ct])ge.set(s,e.style.getPropertyValue(s));function Pe(){for(let[s,m]of ge)m?e.style.setProperty(s,m):e.style.removeProperty(s)}if(z)return N(),T?.(),{...r,destroy:Pe,getProgress:()=>1};Me();let ke=typeof l=="string"?Qe(l):null;function Le(){if(!E||!lr()||!ke||c!=="y"||j||de!==e||u||f!==1||Ee||T||$||g||S||h||D!==!1||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return!1;for(let s of q)if(!ir.has(s.prop))return!1;return!0}function b(){let s=`ssd-a-${++ar}`,m=q.map(_=>`${_.prop}:${_.from}`).join(";"),ce=q.map(_=>`${_.prop}:${_.to}`).join(";"),k=document.createElement("style");k.setAttribute("data-ssd-animate",""),k.textContent=`@keyframes ${s}{from{${m}}to{${ce}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${ke};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(k),e.classList.add(s);let I=()=>c==="x"?window.scrollX:window.scrollY,O=()=>c==="x"?window.innerWidth:window.innerHeight;return{destroy(){e.classList.remove(s),k.remove(),e.style.animationPlayState="",Pe()},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(_){let Y=Math.min(1,Math.max(0,_));e.classList.remove(s);for(let ve of q)e.style.setProperty(ve.prop,Lt(ve.from,ve.to,Y))},getProgress(){let _=e.getBoundingClientRect(),Y=I(),ve=O(),{tStart:G,tEnd:me}=Oe({top:_.top,height:_.height},Y,ve,B,te);return R(ie(Y,G,me,f))}}}if(Le())return b();let P=0,oe=0,ye=0,Fe=!1,he=!1,xe=-1,re=0,ue=!1,be=NaN,Re=-1,ae=0,le=()=>j?c==="x"?j.scrollLeft:j.scrollTop:c==="x"?window.scrollX:window.scrollY,U=()=>j?c==="x"?j.clientWidth:j.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function X(){let s=Xe(de,j,c),m=Oe(s,s.scroll,U(),B,te);P=m.tStart,oe=m.tEnd}function H(s){e.style.setProperty(Ct,String(s));for(let m of q)e.style.setProperty(m.prop,Lt(m.from,m.to,s));Ee?.(s)}function ne(s){if(isNaN(be)){be=s;return}be<=0&&s>0?$?.():be>0&&s<=0&&h?.(),be<1&&s>=1?g?.():be>=1&&s<1&&S?.(),be=s}function W(){if(!Fe||he)return;let s=performance.now(),m=le(),ce=f;if(D!==!1){let O=s-ae,_=O>0?Math.abs(m-(Re<0?m:Re))/O:0;ce=f*Math.max(.2,1+_*(typeof D=="number"?D:1)*.04)}Re=m,ae=s;let k=oe===P?0:(m-P)/(oe-P);ne(k);let I=R(ie(m,P,oe,ce));u&&(xe=Math.max(xe,I),I=xe),re=I,H(I),I>=1&&!ue?(ue=!0,T?.()):I<1&&!u&&(ue=!1),ye=requestAnimationFrame(W)}X(),oe===P&&K("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 s=R(ie(le(),P,oe,f));u&&s>0&&(xe=s),re=s,H(s)}let we=new IntersectionObserver(s=>{s.forEach(m=>{Fe=m.isIntersecting,Fe&&!he?ye=requestAnimationFrame(W):cancelAnimationFrame(ye)})},{root:j??null}),C;function x(){clearTimeout(C),C=setTimeout(X,150)}return window.addEventListener("resize",x),window.addEventListener("orientationchange",x),we.observe(e),Je(e,{type:"animate",getProgress:()=>re,getTrigger:()=>({tStart:P,tEnd:oe})}),{destroy(){cancelAnimationFrame(ye),we.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("orientationchange",x),clearTimeout(C),Pe(),Ke(e)},replay(){xe=-1,ue=!1,re=0,he=!1,H(0)},pause(){he=!0,cancelAnimationFrame(ye)},resume(){he&&(he=!1,Fe&&(ye=requestAnimationFrame(W)))},seek(s){let m=Math.min(1,Math.max(0,s));re=m,xe=m,he=!0,cancelAnimationFrame(ye),H(m)},getProgress(){return re}}}var et={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function It(e,t){if(typeof window>"u")return et;let r=typeof e=="string"?document.querySelector(e):e;return r?Dt(r,t):(K("scrollAnimate: element not found:",e),et)}function Ot(e,t={}){if(typeof window>"u")return et;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollParallax: element not found:",e),et;let{speed:n=.3,axis:i="y",easing:l="linear",trigger:f,onProgress:u}=t,c=r.getBoundingClientRect(),p=i==="x"?c.width:c.height,E=n*p;return Dt(r,{props:i==="x"?{transform:["translateX(0px)",`translateX(${-E}px)`]}:{transform:["translateY(0px)",`translateY(${-E}px)`]},trigger:f??{start:"top bottom",end:"bottom top"},easing:l,native:!1,onProgress:u})}var mt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ft(e,t){if(typeof window>"u")return mt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollCounter: element not found:",e),mt;let n=r,{from:i=0,to:l,format:f,easing:u="ease-out",trigger:c={},once:p=!0,decimals:E,onComplete:D}=t,A=E!==void 0?b=>b.toFixed(E):f??(b=>String(Math.round(b))),ee=typeof u=="function"?u:J[u]??J["ease-out"],Ee=$e(c.start??"top 80%"),T=$e(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=A(l),D?.(),mt;let g=0,S=0,h=0,z=!1,R=!1,B=-1,te=0,de=!1,j=()=>window.scrollY,q=()=>window.innerHeight;function Me(){let b=n.getBoundingClientRect(),P=Oe({top:b.top,height:b.height},j(),q(),Ee,T);g=P.tStart,S=P.tEnd}function N(b){n.textContent=A(i+(l-i)*b),n.style.setProperty("--scroll-draw-progress",String(b))}function ge(){if(!z||R)return;let b=ee(ie(j(),g,S,1));p&&(B=Math.max(B,b),b=B),te=b,N(b),b>=1&&!de?(de=!0,D?.()):b<1&&!p&&(de=!1),h=requestAnimationFrame(ge)}Me();{let b=ee(ie(j(),g,S,1));p&&b>0&&(B=b),te=b,N(b)}let Pe=new IntersectionObserver(b=>{b.forEach(P=>{z=P.isIntersecting,z&&!R?h=requestAnimationFrame(ge):cancelAnimationFrame(h)})}),ke;function Le(){clearTimeout(ke),ke=setTimeout(Me,150)}return window.addEventListener("resize",Le),window.addEventListener("orientationchange",Le),Pe.observe(n),Je(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:g,tEnd:S})}),{destroy(){cancelAnimationFrame(h),Pe.disconnect(),window.removeEventListener("resize",Le),window.removeEventListener("orientationchange",Le),clearTimeout(ke),Ke(n)},replay(){B=-1,de=!1,te=0,R=!1,N(0)},pause(){R=!0,cancelAnimationFrame(h)},resume(){R&&(R=!1,z&&(h=requestAnimationFrame(ge)))},seek(b){let P=Math.min(1,Math.max(0,b));te=P,B=P,R=!0,cancelAnimationFrame(h),N(P)},getProgress(){return te}}}var Rt="http://www.w3.org/2000/svg",cr="cinematic-photo",ft=e=>e<0?0:e>1?1:e;function tt(e){let t=parseFloat(e);return Number.isFinite(t)?ft(t/100):0}function ur(e){return J[e]??J.linear}var mr={destroy:()=>{},getProgress:()=>0},rt=class{constructor(t){if(typeof document>"u"){this.mount=null;return}this.mount=typeof t.wrapper=="string"?document.querySelector(t.wrapper):t.wrapper,this.mount||K("Cinematic: wrapper not found:",t.wrapper)}loadStory(t){let r=this.mount;if(typeof window>"u"||!r)return mr;r.style.position="relative",r.style.height=t.totalHeight,r.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(n);let i=[];for(let T of t.scenes){if(T.background){let g=document.createElement("img");g.id=cr,g.src=T.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g)}let $=T.animations.filter(g=>g.type==="draw");if($.length){let g=document.createElementNS(Rt,"svg");g.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let S of $){let h=document.createElementNS(Rt,"path");h.id=S.target.replace(/^#/,""),h.setAttribute("d",S.d),h.setAttribute("fill","none"),h.setAttribute("stroke",S.stroke),h.setAttribute("stroke-width",String(S.strokeWidth)),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round");let z=S.length||h.getTotalLength?.()||0;h.style.strokeDasharray=String(z),h.style.strokeDashoffset=String(z),g.appendChild(h),i.push({kind:"draw",el:h,start:tt(S.start),end:tt(S.end),ease:ur(S.easing),length:z})}}for(let g of T.animations){if(g.type!=="fade")continue;let S=n.querySelector(g.target)??document.querySelector(g.target);S&&(S.style.opacity=String(g.from),i.push({kind:"fade",el:S,start:tt(g.start),end:tt(g.end),ease:J["ease-in-out"]??J.linear,from:g.from,to:g.to}))}}let l=0,f=()=>{let T=r.offsetHeight-window.innerHeight;return T<=0?r.getBoundingClientRect().top<=0?1:0:ft(-r.getBoundingClientRect().top/T)},u=T=>{for(let $ of i){let g=$.end-$.start,S=g<=0?T>=$.end?1:0:ft((T-$.start)/g),h=$.ease(S);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-h)):$.el.style.opacity=String($.from+($.to-$.from)*h)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return u(1),{destroy:()=>{},getProgress:()=>1};let c=0,p=!1,E=!1,D=()=>{l=f(),u(l),p&&(c=requestAnimationFrame(D))},A=()=>{p||(p=!0,c=requestAnimationFrame(D))},ee=()=>{p=!1,cancelAnimationFrame(c)},Ee=new IntersectionObserver(T=>{for(let $ of T)E=$.isIntersecting,E?A():ee()},{threshold:0});return Ee.observe(n),l=f(),u(l),{destroy(){ee(),Ee.disconnect()},getProgress:()=>l}}};function fr(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let n=typeof e=="string"?document.querySelector(e):e;return n?Ze(n,t):(K("Container not found:",e),r)}if(typeof HTMLElement<"u"&&typeof customElements<"u"&&!customElements.get("scroll-draw")){class e extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let n={},i=this.getAttribute("speed"),l=this.getAttribute("easing"),f=this.getAttribute("stagger"),u=this.getAttribute("direction"),c=this.getAttribute("selector");i&&(n.speed=parseFloat(i)),l&&(n.easing=l),f&&(n.stagger=parseFloat(f)),u&&(n.direction=u),c&&(n.selector=c),this.hasAttribute("fade")&&(n.fade=this.getAttribute("fade")!=="false"),this.instance=Ze(this,n)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}}customElements.define("scroll-draw",e)}return jt(pr);})();
|
|
3
|
+
<div style="position:absolute;${c?`left:${m}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${m}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`}return document.body.appendChild(n),window.addEventListener("scroll",i,{passive:!0}),i(),{el:n,destroy(){window.removeEventListener("scroll",i),n.remove()}}}var kt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Lt=/[MmLlHhVvCcSsQqTtAaZz]/g;function sr(e,t,r){if(!!1)return;let n=(e.match(Lt)??[]).join("").toUpperCase(),i=(t.match(Lt)??[]).join("").toUpperCase(),a=(e.match(kt)??[]).length,f=(t.match(kt)??[]).length;if(n!==i){K(`morphTo: command sequence differs (${n||"\u2205"} \u2192 ${i||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}a!==f&&K(`morphTo: coordinate count differs (${a} \u2192 ${f}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r)}function mt(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,a=>{let f=parseFloat(a),m=n[i++]??f;return String(+(f+(m-f)*r).toFixed(4))})}function Je(e,t={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,i=r?{...Ze[r],...n}:n,a=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:f="path, polyline, line, polygon, rect, circle",speed:m=1,fade:c=!1,easing:p="linear",trigger:x={},stagger:I=0,direction:A="forward",once:J=!1,debug:Ee=!1,axis:S="y",scrollContainer:$,autoReverse:g=!1,delay:E=0,strokeColor:b,strokeWidth:z,fillOpacity:F,waypoints:B,velocityScale:ee=!1,threshold:ge=0,rootMargin:j="0px",repeat:q=0,repeatDelay:ke=0,morphTo:N,clip:ye,autoplay:Le=!1,duration:Ce=1e3,native:De=!0,onProgress:w,onStart:P,onComplete:ne,onEnter:he,onLeave:Ne,onEnterBack:be,onLeaveBack:xe}=i,te=ye===!0?"left":typeof ye=="string"?ye:!1,me=typeof p=="function"?p:Z[p]??Z.linear,we=$e(x.start??"top bottom"),He=$e(x.end??"bottom top"),ce=typeof $=="string"?document.querySelector($):$??null,ue=Array.isArray(b)?b[0]:null,Y=Array.isArray(b)?b[1]:typeof b=="string"?b:null,U=Array.isArray(z)?z[0]:null,H=Array.isArray(z)?z[1]:typeof z=="number"?z:null,re=Array.isArray(F)?F[0]:null,W=Array.isArray(F)?F[1]:typeof F=="number"?F:null;function ve(o){let l=o*100;switch(te){case"right":return`inset(0 0 0 ${100-l}%)`;case"top":return`inset(0 0 ${100-l}% 0)`;case"bottom":return`inset(${100-l}% 0 0 0)`;case"center":return`circle(${o*150}% at 50% 50%)`;default:return`inset(0 ${100-l}% 0 0)`}}let C=te?[]:Array.from(e.querySelectorAll(f)),T=[],s=[],u=0,oe=0,k=!1,D=!1,O=0,pe=!1,se=-1,G=-1,_=!1,ie=0,Te=0,Ie,nt=null;function dt(){nt?.destroy(),nt=null}let Oe=new Set,gt=NaN,Re=!0,Be=-1,yt=performance.now(),_e=NaN;function ot(){return ce?S==="x"?ce.scrollLeft:ce.scrollTop:S==="x"?window.scrollX:window.scrollY}function ht(){return ce?S==="x"?ce.clientWidth:ce.clientHeight:S==="x"?window.innerWidth:window.innerHeight}function bt(){let o=Qe(e,ce,S);return Fe(o,o.scroll,ht(),we,He)}function wt(){({tStart:u,tEnd:oe}=bt()),Ee&&!1&&(dt(),nt=or(u,oe,S))}function st(o,l=bt){Me(e,{type:"draw",getProgress:()=>o.getProgress(),getTrigger:l});let h=o.destroy;return o.destroy=()=>{h.call(o),Pe(e)},o}function Vt(o,l){if(e.style.setProperty("--scroll-draw-progress",String(o)),te){let h=l==="reverse"?1-o:o;e.style.clipPath=ve(h);return}C.forEach((h,X)=>{h.style.strokeDashoffset=l==="reverse"?`${T[X]*o}`:`${T[X]*(1-o)}`,c&&(h.style.opacity=l==="reverse"?`${1-o}`:`${o}`),ue&&Y?h.style.stroke=ze(ue,Y,o):Y&&(h.style.stroke=Y),U!==null&&H!==null?h.style.strokeWidth=`${U+(H-U)*o}`:H!==null&&(h.style.strokeWidth=`${H}`),re!==null&&W!==null?h.style.fillOpacity=`${re+(W-re)*o}`:W!==null&&(h.style.fillOpacity=`${W}`),N&&h.tagName.toLowerCase()==="path"&&s[X]&&h.setAttribute("d",mt(s[X],N,o))})}function Ge(){if(e.style.setProperty("--scroll-draw-progress","0"),te){e.style.clipPath=ve(0);return}C.forEach((o,l)=>{o.style.strokeDasharray=`${T[l]}`,o.style.strokeDashoffset=A==="reverse"?"0":`${T[l]}`,c?o.style.opacity=A==="reverse"?"1":"0":o.style.opacity="",ue&&(o.style.stroke=ue),U!==null&&(o.style.strokeWidth=`${U}`),re!==null&&(o.style.fillOpacity=`${re}`),N&&o.tagName.toLowerCase()==="path"&&s[l]&&o.setAttribute("d",s[l])})}if(C.forEach(o=>{nr(o);let l=Ve(o);T.push(l);let h=o.tagName.toLowerCase()==="path";h?s.push(o.getAttribute("d")??""):s.push(""),N&&(h?sr(s[s.length-1],N,o):K(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),a?(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=A==="reverse"?`${l}`:"0",c&&(o.style.opacity="1"),Y&&(o.style.stroke=Y),H!==null&&(o.style.strokeWidth=`${H}`),W!==null&&(o.style.fillOpacity=`${W}`),N&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",N)):(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=A==="reverse"?"0":`${l}`,c?o.style.opacity=A==="reverse"?"1":"0":o.style.opacity="",ue&&(o.style.stroke=ue),U!==null&&(o.style.strokeWidth=`${U}`),re!==null&&(o.style.fillOpacity=`${re}`))}),te){if(a)return e.style.clipPath=ve(1),ne?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ve(0)}else if(a)return ne?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let vt=typeof p=="string"?Ke(p):null;function zt(){return!(De===!1||!rr()||!C.length||!vt||te||S!=="y"||ce||m!==1||I!==0||J||g||ee!==!1||N||B||q||E>0||w||P||ne||he||Ne||be||xe||b!=null||z!=null||F!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function qt(){let o=++tr,l=`svg-scroll-draw-${o}`,h=`svg-scroll-draw-host-${o}`,X=`--svg-scroll-draw-${o}`,Ae=A==="reverse"?"0":"var(--ssd-len)",Se=A==="reverse"?"var(--ssd-len)":"0",de=`stroke-dashoffset:${Ae};`,v=`stroke-dashoffset:${Se};`;c&&(de+=`opacity:${A==="reverse"?1:0};`,v+=`opacity:${A==="reverse"?0:1};`);let M=document.createElement("style");M.setAttribute("data-svg-scroll-draw",""),M.textContent=`@keyframes ${l}{from{${de}}to{${v}}}.${h}{view-timeline-name:${X};view-timeline-axis:block;}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${vt};animation-fill-mode:both;animation-timeline:${X};animation-range:cover 0% cover 100%;}`,document.head.appendChild(M),e.classList.add(h);function Q(d,V){d.style.setProperty("--ssd-len",String(T[V])),d.style.strokeDasharray=`${T[V]}`,d.style.strokeDashoffset="",d.style.opacity="",d.style.animationPlayState="",d.classList.add(l)}C.forEach(Q);let y=!1,L=-1;function R(){if(L>=0)return L;let d=e.getBoundingClientRect(),{tStart:V,tEnd:fe}=Fe({top:d.top,height:d.height},ot(),ht(),we,He);return me(le(ot(),V,fe,m))}return{destroy(){e.classList.remove(h),C.forEach(d=>{d.classList.remove(l),d.style.removeProperty("--ssd-len"),d.style.animationPlayState=""}),M.remove()},replay(){y=!1,L=-1,C.forEach(Q)},pause(){y=!0,C.forEach(d=>{d.style.animationPlayState="paused"})},resume(){y&&(y=!1,C.forEach(d=>{d.style.animationPlayState="running"}))},seek(d){let V=Math.min(1,Math.max(0,d));L=V,y=!0,C.forEach((fe,ae)=>{fe.classList.remove(l),fe.style.strokeDashoffset=A==="reverse"?`${T[ae]*V}`:`${T[ae]*(1-V)}`,c&&(fe.style.opacity=A==="reverse"?`${1-V}`:`${V}`)})},getProgress(){return R()},refresh(){C.forEach((d,V)=>{T[V]=Ve(d),d.style.setProperty("--ssd-len",String(T[V])),d.style.strokeDasharray=`${T[V]}`})}}}if(zt())return st(qt());function Wt(){let o=Math.max(1,Ce),l=0,h=0,X=!1;function Ae(y){let L=!0;if(te){let R=Math.min(1,Math.max(0,y/o)),d=me(R);ie=d,e.style.setProperty("--scroll-draw-progress",String(d)),e.style.clipPath=ve(A==="reverse"?1-d:d),w?.(d),R<1&&(L=!1)}else C.forEach((R,d)=>{let V=d*I*o,fe=Math.min(1,Math.max(0,(y-V)/o)),ae=me(fe);R.style.strokeDashoffset=A==="reverse"?`${T[d]*ae}`:`${T[d]*(1-ae)}`,c&&(R.style.opacity=A==="reverse"?`${1-ae}`:`${ae}`),ue&&Y?R.style.stroke=ze(ue,Y,ae):Y&&(R.style.stroke=Y),U!==null&&H!==null?R.style.strokeWidth=`${U+(H-U)*ae}`:H!==null&&(R.style.strokeWidth=`${H}`),re!==null&&W!==null?R.style.fillOpacity=`${re+(W-re)*ae}`:W!==null&&(R.style.fillOpacity=`${W}`),N&&R.tagName.toLowerCase()==="path"&&s[d]&&R.setAttribute("d",mt(s[d],N,ae)),d===0&&(ie=ae,w?.(ae),e.style.setProperty("--scroll-draw-progress",String(ae))),fe<1&&(L=!1)});if(B){let R=Math.min(1,Math.max(0,y/o)),d=me(R);for(let V in B){let fe=parseFloat(V);d>=fe&&!Oe.has(fe)&&(Oe.add(fe),B[V]?.())}}return L}function Se(y){if(_)return;let L=y-l;D||(D=!0,P?.());let R=Ae(L);if(R&&!k){k=!0,Ae(o*(1+Math.max(0,C.length-1)*I)),ne?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ie=setTimeout(()=>{l=performance.now(),D=!1,k=!1,Oe.clear(),Ge(),O=requestAnimationFrame(Se)},ke));return}R||(O=requestAnimationFrame(Se))}function de(){cancelAnimationFrame(O),clearTimeout(Ie),l=performance.now(),h=0,_=!1,D=!1,k=!1,Te=0,X=!0,ie=0,Oe.clear(),Ge(),O=requestAnimationFrame(Se)}let v=new IntersectionObserver(y=>{y.forEach(L=>{L.isIntersecting&&!(J&&k)?de():!L.isIntersecting&&!J&&!k&&(cancelAnimationFrame(O),clearTimeout(Ie),X=!1)})},{root:ce??null,threshold:ge,rootMargin:j}),M;function Q(){clearTimeout(M),M=setTimeout(()=>{C.forEach((y,L)=>{T[L]=Ve(y),y.style.strokeDasharray=`${T[L]}`})},150)}return window.addEventListener("resize",Q),window.addEventListener("orientationchange",Q),E>0?setTimeout(()=>v.observe(e),E):v.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ie),v.disconnect(),window.removeEventListener("resize",Q),window.removeEventListener("orientationchange",Q),clearTimeout(M)},replay(){Te=0,de()},pause(){_||!X||(_=!0,h=performance.now()-l,cancelAnimationFrame(O))},resume(){_&&(_=!1,X=!0,l=performance.now()-h,O=requestAnimationFrame(Se))},seek(y){let L=Math.min(1,Math.max(0,y));ie=L,_=!0,h=L*o,l=performance.now()-h,cancelAnimationFrame(O),Ae(h)},getProgress(){return ie},refresh(){clearTimeout(M),C.forEach((y,L)=>{T[L]=Ve(y),y.style.strokeDasharray=`${T[L]}`})}}}if(Le)return st(Wt());wt();function je(){if(!pe||_)return;let o=performance.now(),l=ot();if(!Re&&ee===!1&&l===gt){O=requestAnimationFrame(je);return}Re=!1,gt=l;let h=m;if(ee!==!1){let v=o-yt,M=v>0?Math.abs(l-(Be<0?l:Be))/v:0;h=m*Math.max(.2,1+M*(typeof ee=="number"?ee:1)*.04)}Be=l,yt=o;let X=g?G===-1||l>=G?"forward":"reverse":A;G=l;let Ae=oe-u,Se=!0,de=Ae===0?0:(l-u)/Ae;if(isNaN(_e)||(_e<=0&&de>0?he?.():_e>0&&de<=0&&xe?.(),_e<1&&de>=1?Ne?.():_e>=1&&de<1&&be?.()),_e=de,te){let v=me(le(l,u,oe,h));J&&!g&&(se=Math.max(se,v),v=se),ie=v,e.style.setProperty("--scroll-draw-progress",String(v));let M=X==="reverse"?1-v:v;e.style.clipPath=ve(M),w?.(v),!D&&le(l,u,oe,h)>0&&(D=!0,P?.()),v>=1&&!k?(k=!0,ne?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ie=setTimeout(()=>{se=-1,D=!1,k=!1,e.style.clipPath=ve(0)},ke))):v<1&&!J&&(k=!1),O=requestAnimationFrame(je);return}if(C.forEach((v,M)=>{let Q=M*I*Ae,y=me(le(l,u+Q,oe+Q,h));J&&!g&&(se=Math.max(se,y),y=se),ie=y,v.style.strokeDashoffset=X==="reverse"?`${T[M]*y}`:`${T[M]*(1-y)}`,c&&(v.style.opacity=X==="reverse"?`${1-y}`:`${y}`),ue&&Y?v.style.stroke=ze(ue,Y,y):Y&&(v.style.stroke=Y),U!==null&&H!==null?v.style.strokeWidth=`${U+(H-U)*y}`:H!==null&&(v.style.strokeWidth=`${H}`),re!==null&&W!==null?v.style.fillOpacity=`${re+(W-re)*y}`:W!==null&&(v.style.fillOpacity=`${W}`),N&&v.tagName.toLowerCase()==="path"&&s[M]&&v.setAttribute("d",mt(s[M],N,y)),M===0&&(w?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(Se=!1)}),B){let v=me(le(l,u,oe,h));for(let M in B){let Q=parseFloat(M);v>=Q&&!Oe.has(Q)&&(Oe.add(Q),B[M]?.())}}!D&&le(l,u,oe,h)>0&&(D=!0,P?.()),Se&&!k?(k=!0,ne?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ie=setTimeout(()=>{se=-1,D=!1,k=!1,Oe.clear(),Ge(),Re=!0},ke))):!Se&&!J&&(k=!1),O=requestAnimationFrame(je)}let it=!1;function Ye(){it||(it=!0,O=requestAnimationFrame(function(){je()}))}function Ue(){it=!1,cancelAnimationFrame(O)}let at=new IntersectionObserver(o=>{o.forEach(l=>{pe=l.isIntersecting,pe&&!_?(Re=!0,Ye()):Ue()})},{root:ce??null,threshold:ge,rootMargin:j});function St(){C.forEach((o,l)=>{T[l]=Ve(o),o.style.strokeDasharray=`${T[l]}`}),wt(),Re=!0}let Xe;function qe(){clearTimeout(Xe),Xe=setTimeout(St,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)),E>0?setTimeout(()=>at.observe(e),E):at.observe(e),st({destroy(){cancelAnimationFrame(O),clearTimeout(Ie),Ue(),at.disconnect(),We?.disconnect(),window.removeEventListener("resize",qe),window.removeEventListener("orientationchange",qe),clearTimeout(Xe),dt()},replay(){se=-1,G=-1,Be=-1,D=!1,k=!1,Te=0,_=!1,ie=0,Oe.clear(),clearTimeout(Ie),Ge(),Re=!0,pe&&Ye()},pause(){_=!0,Ue()},resume(){_&&(_=!1,Re=!0,pe&&Ye())},seek(o){let l=Math.min(1,Math.max(0,o));ie=l,se=l,_=!0,Ue(),Vt(l,A),Re=!0},getProgress(){return ie},refresh(){clearTimeout(Xe),St(),pe&&!_&&Ye()}},()=>({tStart:u,tEnd:oe}))}function ir(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Dt(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let i=[],a=[],f=n[2].trim();if(f)for(let m of f.split(/[\s,]+/)){let c=m.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(c?parseFloat(c[1]):0),a.push(c?c[2]:"")}t.push({fn:n[1],nums:i,units:a})}return t}function ar(e,t,r){let n=Dt(e),i=Dt(t);return n.length===0||n.length!==i.length?r<1?e:t:n.map((a,f)=>{let m=i[f];return a.fn!==m.fn||a.nums.length!==m.nums.length?r<1?`${a.fn}(${a.nums.map((c,p)=>`${c}${a.units[p]}`).join(", ")})`:`${m.fn}(${m.nums.map((c,p)=>`${c}${m.units[p]}`).join(", ")})`:`${a.fn}(${a.nums.map((c,p)=>`${c+(m.nums[p]-c)*r}${a.units[p]}`).join(", ")})`}).join(" ")}function It(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),i=String(t);if(ir(n))return ze(n,i,r);if(n.includes("("))return ar(n,i,r);let a=n.match(/^([-+]?[\d.]+)(.*)$/),f=i.match(/^([-+]?[\d.]+)(.*)$/);if(a&&f){let m=parseFloat(a[1]),c=parseFloat(f[1]);return`${m+(c-m)*r}${a[2]||f[2]}`}return r<1?n:i}function lr(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var cr=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),ur=0,Ot="--scroll-draw-progress";function mr(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Rt(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:i={},easing:a="ease-out",speed:f=1,once:m=!1,axis:c="y",scrollContainer:p,native:x=!0,velocityScale:I=!1,respectReducedMotion:A=!0,triggerElement:J,onProgress:Ee,onComplete:S,onEnter:$,onLeave:g,onEnterBack:E,onLeaveBack:b}=t,z=A&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,F=typeof a=="function"?a:Z[a]??Z["ease-out"],B=$e(i.start??"top bottom"),ee=$e(i.end??"bottom top"),ge=J??e,j=typeof p=="string"?document.querySelector(p):p??null,q=Object.entries(n).map(([s,u])=>({prop:lr(s),from:Array.isArray(u)?u[0]:"",to:Array.isArray(u)?u[1]:u}));function ke(){let s=window.getComputedStyle(e);for(let u of q)u.from===""&&(u.from=s.getPropertyValue(u.prop).trim()||"0")}function N(){for(let s of q)e.style.setProperty(s.prop,String(s.to))}let ye=new Map;for(let s of[...q.map(u=>u.prop),Ot])ye.set(s,e.style.getPropertyValue(s));function Le(){for(let[s,u]of ye)u?e.style.setProperty(s,u):e.style.removeProperty(s)}if(z)return N(),S?.(),{...r,destroy:Le,getProgress:()=>1};ke();let Ce=typeof a=="string"?Ke(a):null;function De(){if(!x||!mr()||!Ce||c!=="y"||j||ge!==e||m||f!==1||Ee||S||$||g||E||b||I!==!1||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return!1;for(let s of q)if(!cr.has(s.prop))return!1;return!0}function w(){let s=`ssd-a-${++ur}`,u=q.map(G=>`${G.prop}:${G.from}`).join(";"),oe=q.map(G=>`${G.prop}:${G.to}`).join(";"),k=document.createElement("style");k.setAttribute("data-ssd-animate",""),k.textContent=`@keyframes ${s}{from{${u}}to{${oe}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${Ce};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(k),e.classList.add(s);let D=()=>c==="x"?window.scrollX:window.scrollY,O=()=>c==="x"?window.innerWidth:window.innerHeight,pe=()=>{let G=e.getBoundingClientRect();return Fe({top:G.top,height:G.height},D(),O(),B,ee)};Me(e,{type:"animate",getProgress:()=>se.getProgress(),getTrigger:pe});let se={destroy(){e.classList.remove(s),k.remove(),e.style.animationPlayState="",Le(),Pe(e)},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(G){let _=Math.min(1,Math.max(0,G));e.classList.remove(s);for(let ie of q)e.style.setProperty(ie.prop,It(ie.from,ie.to,_))},getProgress(){let{tStart:G,tEnd:_}=pe();return F(le(D(),G,_,f))}};return se}if(De())return w();let P=0,ne=0,he=0,Ne=!1,be=!1,xe=-1,te=0,me=!1,we=NaN,He=-1,ce=0,ue=()=>j?c==="x"?j.scrollLeft:j.scrollTop:c==="x"?window.scrollX:window.scrollY,Y=()=>j?c==="x"?j.clientWidth:j.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function U(){let s=Qe(ge,j,c),u=Fe(s,s.scroll,Y(),B,ee);P=u.tStart,ne=u.tEnd}function H(s){e.style.setProperty(Ot,String(s));for(let u of q)e.style.setProperty(u.prop,It(u.from,u.to,s));Ee?.(s)}function re(s){if(isNaN(we)){we=s;return}we<=0&&s>0?$?.():we>0&&s<=0&&b?.(),we<1&&s>=1?g?.():we>=1&&s<1&&E?.(),we=s}function W(){if(!Ne||be)return;let s=performance.now(),u=ue(),oe=f;if(I!==!1){let O=s-ce,pe=O>0?Math.abs(u-(He<0?u:He))/O:0;oe=f*Math.max(.2,1+pe*(typeof I=="number"?I:1)*.04)}He=u,ce=s;let k=ne===P?0:(u-P)/(ne-P);re(k);let D=F(le(u,P,ne,oe));m&&(xe=Math.max(xe,D),D=xe),te=D,H(D),D>=1&&!me?(me=!0,S?.()):D<1&&!m&&(me=!1),he=requestAnimationFrame(W)}U(),ne===P&&K("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 s=F(le(ue(),P,ne,f));m&&s>0&&(xe=s),te=s,H(s)}let ve=new IntersectionObserver(s=>{s.forEach(u=>{Ne=u.isIntersecting,Ne&&!be?he=requestAnimationFrame(W):cancelAnimationFrame(he)})},{root:j??null}),C;function T(){clearTimeout(C),C=setTimeout(U,150)}return window.addEventListener("resize",T),window.addEventListener("orientationchange",T),ve.observe(e),Me(e,{type:"animate",getProgress:()=>te,getTrigger:()=>({tStart:P,tEnd:ne})}),{destroy(){cancelAnimationFrame(he),ve.disconnect(),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T),clearTimeout(C),Le(),Pe(e)},replay(){xe=-1,me=!1,te=0,be=!1,H(0)},pause(){be=!0,cancelAnimationFrame(he)},resume(){be&&(be=!1,Ne&&(he=requestAnimationFrame(W)))},seek(s){let u=Math.min(1,Math.max(0,s));te=u,xe=u,be=!0,cancelAnimationFrame(he),H(u)},getProgress(){return te}}}var et={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ft(e,t){if(typeof window>"u")return et;let r=typeof e=="string"?document.querySelector(e):e;return r?Rt(r,t):(K("scrollAnimate: element not found:",e),et)}function Nt(e,t={}){if(typeof window>"u")return et;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollParallax: element not found:",e),et;let{speed:n=.3,axis:i="y",easing:a="linear",trigger:f,onProgress:m}=t,c=r.getBoundingClientRect(),p=i==="x"?c.width:c.height,x=n*p;return Rt(r,{props:i==="x"?{transform:["translateX(0px)",`translateX(${-x}px)`]}:{transform:["translateY(0px)",`translateY(${-x}px)`]},trigger:f??{start:"top bottom",end:"bottom top"},easing:a,native:!1,onProgress:m})}var ft={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ht(e,t){if(typeof window>"u")return ft;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollCounter: element not found:",e),ft;let n=r,{from:i=0,to:a,format:f,easing:m="ease-out",trigger:c={},once:p=!0,decimals:x,onComplete:I}=t,A=x!==void 0?w=>w.toFixed(x):f??(w=>String(Math.round(w))),J=typeof m=="function"?m:Z[m]??Z["ease-out"],Ee=$e(c.start??"top 80%"),S=$e(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=A(a),I?.(),ft;let g=0,E=0,b=0,z=!1,F=!1,B=-1,ee=0,ge=!1,j=()=>window.scrollY,q=()=>window.innerHeight;function ke(){let w=n.getBoundingClientRect(),P=Fe({top:w.top,height:w.height},j(),q(),Ee,S);g=P.tStart,E=P.tEnd}function N(w){n.textContent=A(i+(a-i)*w),n.style.setProperty("--scroll-draw-progress",String(w))}function ye(){if(!z||F)return;let w=J(le(j(),g,E,1));p&&(B=Math.max(B,w),w=B),ee=w,N(w),w>=1&&!ge?(ge=!0,I?.()):w<1&&!p&&(ge=!1),b=requestAnimationFrame(ye)}ke();{let w=J(le(j(),g,E,1));p&&w>0&&(B=w),ee=w,N(w)}let Le=new IntersectionObserver(w=>{w.forEach(P=>{z=P.isIntersecting,z&&!F?b=requestAnimationFrame(ye):cancelAnimationFrame(b)})}),Ce;function De(){clearTimeout(Ce),Ce=setTimeout(ke,150)}return window.addEventListener("resize",De),window.addEventListener("orientationchange",De),Le.observe(n),Me(n,{type:"counter",getProgress:()=>ee,getTrigger:()=>({tStart:g,tEnd:E})}),{destroy(){cancelAnimationFrame(b),Le.disconnect(),window.removeEventListener("resize",De),window.removeEventListener("orientationchange",De),clearTimeout(Ce),Pe(n)},replay(){B=-1,ge=!1,ee=0,F=!1,N(0)},pause(){F=!0,cancelAnimationFrame(b)},resume(){F&&(F=!1,z&&(b=requestAnimationFrame(ye)))},seek(w){let P=Math.min(1,Math.max(0,w));ee=P,B=P,F=!0,cancelAnimationFrame(b),N(P)},getProgress(){return ee}}}var _t="http://www.w3.org/2000/svg",fr="cinematic-photo",pt=e=>e<0?0:e>1?1:e;function tt(e){let t=parseFloat(e);return Number.isFinite(t)?pt(t/100):0}function pr(e){return Z[e]??Z.linear}var dr={destroy:()=>{},getProgress:()=>0},rt=class{constructor(t){if(typeof document>"u"){this.mount=null;return}this.mount=typeof t.wrapper=="string"?document.querySelector(t.wrapper):t.wrapper,this.mount||K("Cinematic: wrapper not found:",t.wrapper)}loadStory(t){let r=this.mount;if(typeof window>"u"||!r)return dr;r.style.position="relative",r.style.height=t.totalHeight,r.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(n);let i=[];for(let S of t.scenes){if(S.background){let g=document.createElement("img");g.id=fr,g.src=S.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g)}let $=S.animations.filter(g=>g.type==="draw");if($.length){let g=document.createElementNS(_t,"svg");g.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let E of $){let b=document.createElementNS(_t,"path");b.id=E.target.replace(/^#/,""),b.setAttribute("d",E.d),b.setAttribute("fill","none"),b.setAttribute("stroke",E.stroke),b.setAttribute("stroke-width",String(E.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let z=E.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(z),b.style.strokeDashoffset=String(z),g.appendChild(b),i.push({kind:"draw",el:b,start:tt(E.start),end:tt(E.end),ease:pr(E.easing),length:z})}}for(let g of S.animations){if(g.type!=="fade")continue;let E=n.querySelector(g.target)??document.querySelector(g.target);E&&(E.style.opacity=String(g.from),i.push({kind:"fade",el:E,start:tt(g.start),end:tt(g.end),ease:Z["ease-in-out"]??Z.linear,from:g.from,to:g.to}))}}let a=0,f=()=>{let S=r.offsetHeight-window.innerHeight;return S<=0?r.getBoundingClientRect().top<=0?1:0:pt(-r.getBoundingClientRect().top/S)},m=S=>{for(let $ of i){let g=$.end-$.start,E=g<=0?S>=$.end?1:0:pt((S-$.start)/g),b=$.ease(E);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-b)):$.el.style.opacity=String($.from+($.to-$.from)*b)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(1),{destroy:()=>{},getProgress:()=>1};let c=0,p=!1,x=!1,I=()=>{a=f(),m(a),p&&(c=requestAnimationFrame(I))},A=()=>{p||(p=!0,c=requestAnimationFrame(I))},J=()=>{p=!1,cancelAnimationFrame(c)},Ee=new IntersectionObserver(S=>{for(let $ of S)x=$.isIntersecting,x?A():J()},{threshold:0});return Ee.observe(n),a=f(),m(a),Me(r,{type:"draw",getProgress:()=>a,getTrigger:()=>{let S=r.getBoundingClientRect().top+window.scrollY;return{tStart:S,tEnd:S+Math.max(0,r.offsetHeight-window.innerHeight)}}}),{destroy(){J(),Ee.disconnect(),Pe(r)},getProgress:()=>a}}};function gr(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let n=typeof e=="string"?document.querySelector(e):e;return n?Je(n,t):(K("Container not found:",e),r)}if(typeof HTMLElement<"u"&&typeof customElements<"u"&&!customElements.get("scroll-draw")){class e extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let n={},i=this.getAttribute("speed"),a=this.getAttribute("easing"),f=this.getAttribute("stagger"),m=this.getAttribute("direction"),c=this.getAttribute("selector");i&&(n.speed=parseFloat(i)),a&&(n.easing=a),f&&(n.stagger=parseFloat(f)),m&&(n.direction=m),c&&(n.selector=c),this.hasAttribute("fade")&&(n.fade=this.getAttribute("fade")!=="false"),this.instance=Je(this,n)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}}customElements.define("scroll-draw",e)}return Xt(yr);})();
|
package/dist/cinematic/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';function
|
|
2
|
-
exports.Cinematic=
|
|
1
|
+
'use strict';function C({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),u=Math.max(.01,Math.min(.99,n)),d=Math.sqrt(u),c=0,b=[];for(let o=0;o<r;o++){let m=Math.pow(d,o);b.push(m),c+=m;}let l=[0],f=0;for(let o=0;o<r;o++)f+=b[o]/c,l.push(f);return o=>{if(o<=0)return 0;if(o>=1)return 1;for(let m=0;m<r;m++)if(o<=l[m+1]){let g=(o-l[m])/(l[m+1]-l[m]);if(m===0)return g*(2-g);let y=1-Math.pow(u,m);return y+(1-y)*(2*g-1)*(2*g-1)}return 1}}function L({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),u=Math.max(.1,n),d=r<=1?u/4:u/(2*Math.PI)*Math.asin(1/r);return c=>c<=0?0:c>=1?1:r*Math.pow(2,-10*c)*Math.sin((c-d)*(2*Math.PI)/u)+1}var h={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:C(),elastic:L()};var P=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function v(e,...n){P&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var A=Symbol.for("svg-scroll-draw.registry");function _(){let e=globalThis;return e[A]||(e[A]=new Map)}function I(e,n){_().set(e,n);}function R(e){_().delete(e);}var k="http://www.w3.org/2000/svg",D="cinematic-photo",x=e=>e<0?0:e>1?1:e;function w(e){let n=parseFloat(e);return Number.isFinite(n)?x(n/100):0}function V(e){return h[e]??h.linear}var F={destroy:()=>{},getProgress:()=>0},T=class{constructor(n){if(typeof document>"u"){this.mount=null;return}this.mount=typeof n.wrapper=="string"?document.querySelector(n.wrapper):n.wrapper,this.mount||v("Cinematic: wrapper not found:",n.wrapper);}loadStory(n){let r=this.mount;if(typeof window>"u"||!r)return F;r.style.position="relative",r.style.height=n.totalHeight,r.style.display="block";let u=document.createElement("div");u.setAttribute("data-cinematic-stage",""),u.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(u);let d=[];for(let s of n.scenes){if(s.background){let t=document.createElement("img");t.id=D,t.src=s.background,t.alt="",t.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",u.appendChild(t);}let i=s.animations.filter(t=>t.type==="draw");if(i.length){let t=document.createElementNS(k,"svg");t.setAttribute("viewBox",`0 0 ${n.canvas.width} ${n.canvas.height}`),t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",u.appendChild(t);for(let p of i){let a=document.createElementNS(k,"path");a.id=p.target.replace(/^#/,""),a.setAttribute("d",p.d),a.setAttribute("fill","none"),a.setAttribute("stroke",p.stroke),a.setAttribute("stroke-width",String(p.strokeWidth)),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round");let S=p.length||a.getTotalLength?.()||0;a.style.strokeDasharray=String(S),a.style.strokeDashoffset=String(S),t.appendChild(a),d.push({kind:"draw",el:a,start:w(p.start),end:w(p.end),ease:V(p.easing),length:S});}}for(let t of s.animations){if(t.type!=="fade")continue;let p=u.querySelector(t.target)??document.querySelector(t.target);p&&(p.style.opacity=String(t.from),d.push({kind:"fade",el:p,start:w(t.start),end:w(t.end),ease:h["ease-in-out"]??h.linear,from:t.from,to:t.to}));}}let c=0,b=()=>{let s=r.offsetHeight-window.innerHeight;return s<=0?r.getBoundingClientRect().top<=0?1:0:x(-r.getBoundingClientRect().top/s)},l=s=>{for(let i of d){let t=i.end-i.start,p=t<=0?s>=i.end?1:0:x((s-i.start)/t),a=i.ease(p);i.kind==="draw"?i.el.style.strokeDashoffset=String(i.length*(1-a)):i.el.style.opacity=String(i.from+(i.to-i.from)*a);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return l(1),{destroy:()=>{},getProgress:()=>1};let f=0,o=false,m=false,g=()=>{c=b(),l(c),o&&(f=requestAnimationFrame(g));},y=()=>{o||(o=true,f=requestAnimationFrame(g));},E=()=>{o=false,cancelAnimationFrame(f);},M=new IntersectionObserver(s=>{for(let i of s)m=i.isIntersecting,m?y():E();},{threshold:0});return M.observe(u),c=b(),l(c),I(r,{type:"draw",getProgress:()=>c,getTrigger:()=>{let s=r.getBoundingClientRect().top+window.scrollY;return {tStart:s,tEnd:s+Math.max(0,r.offsetHeight-window.innerHeight)}}}),{destroy(){E(),M.disconnect(),R(r);},getProgress:()=>c}}};
|
|
2
|
+
exports.Cinematic=T;
|
package/dist/cinematic/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
export{
|
|
1
|
+
function C({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),u=Math.max(.01,Math.min(.99,n)),d=Math.sqrt(u),c=0,b=[];for(let o=0;o<r;o++){let m=Math.pow(d,o);b.push(m),c+=m;}let l=[0],f=0;for(let o=0;o<r;o++)f+=b[o]/c,l.push(f);return o=>{if(o<=0)return 0;if(o>=1)return 1;for(let m=0;m<r;m++)if(o<=l[m+1]){let g=(o-l[m])/(l[m+1]-l[m]);if(m===0)return g*(2-g);let y=1-Math.pow(u,m);return y+(1-y)*(2*g-1)*(2*g-1)}return 1}}function L({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),u=Math.max(.1,n),d=r<=1?u/4:u/(2*Math.PI)*Math.asin(1/r);return c=>c<=0?0:c>=1?1:r*Math.pow(2,-10*c)*Math.sin((c-d)*(2*Math.PI)/u)+1}var h={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:C(),elastic:L()};var P=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function v(e,...n){P&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var A=Symbol.for("svg-scroll-draw.registry");function _(){let e=globalThis;return e[A]||(e[A]=new Map)}function I(e,n){_().set(e,n);}function R(e){_().delete(e);}var k="http://www.w3.org/2000/svg",D="cinematic-photo",x=e=>e<0?0:e>1?1:e;function w(e){let n=parseFloat(e);return Number.isFinite(n)?x(n/100):0}function V(e){return h[e]??h.linear}var F={destroy:()=>{},getProgress:()=>0},T=class{constructor(n){if(typeof document>"u"){this.mount=null;return}this.mount=typeof n.wrapper=="string"?document.querySelector(n.wrapper):n.wrapper,this.mount||v("Cinematic: wrapper not found:",n.wrapper);}loadStory(n){let r=this.mount;if(typeof window>"u"||!r)return F;r.style.position="relative",r.style.height=n.totalHeight,r.style.display="block";let u=document.createElement("div");u.setAttribute("data-cinematic-stage",""),u.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(u);let d=[];for(let s of n.scenes){if(s.background){let t=document.createElement("img");t.id=D,t.src=s.background,t.alt="",t.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",u.appendChild(t);}let i=s.animations.filter(t=>t.type==="draw");if(i.length){let t=document.createElementNS(k,"svg");t.setAttribute("viewBox",`0 0 ${n.canvas.width} ${n.canvas.height}`),t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",u.appendChild(t);for(let p of i){let a=document.createElementNS(k,"path");a.id=p.target.replace(/^#/,""),a.setAttribute("d",p.d),a.setAttribute("fill","none"),a.setAttribute("stroke",p.stroke),a.setAttribute("stroke-width",String(p.strokeWidth)),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round");let S=p.length||a.getTotalLength?.()||0;a.style.strokeDasharray=String(S),a.style.strokeDashoffset=String(S),t.appendChild(a),d.push({kind:"draw",el:a,start:w(p.start),end:w(p.end),ease:V(p.easing),length:S});}}for(let t of s.animations){if(t.type!=="fade")continue;let p=u.querySelector(t.target)??document.querySelector(t.target);p&&(p.style.opacity=String(t.from),d.push({kind:"fade",el:p,start:w(t.start),end:w(t.end),ease:h["ease-in-out"]??h.linear,from:t.from,to:t.to}));}}let c=0,b=()=>{let s=r.offsetHeight-window.innerHeight;return s<=0?r.getBoundingClientRect().top<=0?1:0:x(-r.getBoundingClientRect().top/s)},l=s=>{for(let i of d){let t=i.end-i.start,p=t<=0?s>=i.end?1:0:x((s-i.start)/t),a=i.ease(p);i.kind==="draw"?i.el.style.strokeDashoffset=String(i.length*(1-a)):i.el.style.opacity=String(i.from+(i.to-i.from)*a);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return l(1),{destroy:()=>{},getProgress:()=>1};let f=0,o=false,m=false,g=()=>{c=b(),l(c),o&&(f=requestAnimationFrame(g));},y=()=>{o||(o=true,f=requestAnimationFrame(g));},E=()=>{o=false,cancelAnimationFrame(f);},M=new IntersectionObserver(s=>{for(let i of s)m=i.isIntersecting,m?y():E();},{threshold:0});return M.observe(u),c=b(),l(c),I(r,{type:"draw",getProgress:()=>c,getTrigger:()=>{let s=r.getBoundingClientRect().top+window.scrollY;return {tStart:s,tEnd:s+Math.max(0,r.offsetHeight-window.innerHeight)}}}),{destroy(){E(),M.disconnect(),R(r);},getProgress:()=>c}}};
|
|
2
|
+
export{T as Cinematic};
|
package/dist/devtools/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var E=Symbol.for("svg-scroll-draw.registry");function L(){let e=globalThis;return e[E]||(e[E]=new Map)}function g(){return L()}var h=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c",pin:"#f43f5e",snap:"#22d3ee"},n=null,o=null,b=0,p=false,m=null;function R(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function M(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of g()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let x=document.createElement("span");return x.textContent=y,x.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(x),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function $(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function S(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=g();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function w(){M(),S(),b=requestAnimationFrame(w);}function T(){h&&(p||(p=true,R(),$(),b=requestAnimationFrame(w),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),C());},window.addEventListener("keydown",m)));}function _(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function C(){p?_():T();}function k(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=g().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var A={enable:T,disable:_,toggle:C,highlight:k};exports.devtools=A;
|
package/dist/devtools/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Symbol.for("svg-scroll-draw.registry");function L(){let e=globalThis;return e[E]||(e[E]=new Map)}function g(){return L()}var h=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c",pin:"#f43f5e",snap:"#22d3ee"},n=null,o=null,b=0,p=false,m=null;function R(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function M(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of g()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let x=document.createElement("span");return x.textContent=y,x.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(x),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function $(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function S(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=g();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function w(){M(),S(),b=requestAnimationFrame(w);}function T(){h&&(p||(p=true,R(),$(),b=requestAnimationFrame(w),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),C());},window.addEventListener("keydown",m)));}function _(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function C(){p?_():T();}function k(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=g().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var A={enable:T,disable:_,toggle:C,highlight:k};export{A as devtools};
|
package/dist/group/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function Rt({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),o=Math.sqrt(t),c=0,m=[];for(let h=0;h<r;h++){let S=Math.pow(o,h);m.push(S),c+=S;}let i=[0],u=0;for(let h=0;h<r;h++)u+=m[h]/c,i.push(u);return h=>{if(h<=0)return 0;if(h>=1)return 1;for(let S=0;S<r;S++)if(h<=i[S+1]){let V=(h-i[S])/(i[S+1]-i[S]);if(S===0)return V*(2-V);let x=1-Math.pow(t,S);return x+(1-x)*(2*V-1)*(2*V-1)}return 1}}function Ft({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),o=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return c=>c<=0?0:c>=1?1:r*Math.pow(2,-10*c)*Math.sin((c-o)*(2*Math.PI)/t)+1}var Se={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:Rt(),elastic:Ft()};function De(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",t="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:t}}function ht(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 bt(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 Ie(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 Nt(e,n,r){return Math.min(r,Math.max(n,e))}function ne(e,n,r,t){return r===n?0:Nt((e-n)/(r-n)*t,0,1)}function Ze(e,n,r){let t=e.getBoundingClientRect(),o=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:o,scroll:0}:{top:r==="x"?t.left:t.top,height:o,scroll:r==="x"?window.scrollX:window.scrollY}}function Ce(e,n,r,t,o){let c=ht(e.top,e.height,n,t.element)-bt(t.viewport,r),m=ht(e.top,e.height,n,o.element)-bt(o.viewport,r);return {tStart:c,tEnd:m}}function wt(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let t=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return t?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]:null}function Oe(e,n,r){let t=wt(e),o=wt(n);return !t||!o?e:`rgb(${Math.round(t[0]+(o[0]-t[0])*r)},${Math.round(t[1]+(o[1]-t[1])*r)},${Math.round(t[2]+(o[2]-t[2])*r)})`}var vt={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 ye(e,...n){Ke&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var _t="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Ht="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",Et=33;function Vt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function zt(e){let n=[];for(let r=0;r<Et;r++){let t=r/(Et-1);n.push(String(Math.round(e(t)*1e5)/1e5));}return `linear(${n.join(",")})`}function Je(e){switch(e){case "linear":return "linear";case "ease-in":return _t;case "ease-out":return Ht;case "ease-in-out":return Vt()?zt(Se["ease-in-out"]):null;default:return null}}var St=Symbol.for("svg-scroll-draw.registry");function xt(){let e=globalThis;return e[St]||(e[St]=new Map)}function Ve(e,n){xt().set(e,n);}function ze(e){xt().delete(e);}var Wt=0;function qt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function Bt(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?ye("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&ye("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Gt(e,n,r){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function o(){let c=r==="x"?window.scrollX:window.scrollY,m=e-c,i=n-c,u=r==="x";t.innerHTML=`
|
|
2
2
|
<div style="position:absolute;${u?`left:${m}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${m}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
-
<div style="position:absolute;${u?`left:${i}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${i}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",o,{passive:true}),o(),{el:t,destroy(){window.removeEventListener("scroll",o),t.remove();}}}var bt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,wt=/[MmLlHhVvCcSsQqTtAaZz]/g;function qt(e,n,r){if(!Qe)return;let t=(e.match(wt)??[]).join("").toUpperCase(),o=(n.match(wt)??[]).join("").toUpperCase(),c=(e.match(bt)??[]).length,m=(n.match(bt)??[]).length;if(t!==o){ye(`morphTo: command sequence differs (${t||"\u2205"} \u2192 ${o||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}c!==m&&ye(`morphTo: coordinate count differs (${c} \u2192 ${m}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function ot(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),o=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let m=parseFloat(c),i=t[o++]??m;return String(+(m+(i-m)*r).toFixed(4))})}function st(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,o=r?{...yt[r],...t}:t,c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:m="path, polyline, line, polygon, rect, circle",speed:i=1,fade:u=false,easing:h="linear",trigger:S={},stagger:z=0,direction:x="forward",once:fe=false,debug:ze=false,axis:K="y",scrollContainer:Pe,autoReverse:xe=false,delay:he=0,strokeColor:ne,strokeWidth:me,fillOpacity:ee,waypoints:oe,velocityScale:be=false,threshold:Re=0,rootMargin:Y="0px",repeat:I=0,repeatDelay:Fe=0,morphTo:W,clip:Me,autoplay:Ne=false,duration:We=1e3,native:Ke=true,onProgress:Te,onStart:G,onComplete:q,onEnter:se,onLeave:$e,onEnterBack:ie,onLeaveBack:pe}=o,H=Me===true?"left":typeof Me=="string"?Me:false,Q=typeof h=="function"?h:Se[h]??Se.linear,ae=De(S.start??"top bottom"),ke=De(S.end??"bottom top"),j=typeof Pe=="string"?document.querySelector(Pe):Pe??null,U=Array.isArray(ne)?ne[0]:null,O=Array.isArray(ne)?ne[1]:typeof ne=="string"?ne:null,R=Array.isArray(me)?me[0]:null,M=Array.isArray(me)?me[1]:typeof me=="number"?me:null,V=Array.isArray(ee)?ee[0]:null,D=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null;function le(s){let l=s*100;switch(H){case "right":return `inset(0 0 0 ${100-l}%)`;case "top":return `inset(0 0 ${100-l}% 0)`;case "bottom":return `inset(${100-l}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-l}% 0 0)`}}let T=H?[]:Array.from(e.querySelectorAll(m)),b=[],a=[],f=0,X=0,v=false,$=false,A=0,k=false,F=-1,ce=-1,C=false,Z=0,de=0,we,et=null;function it(){et?.destroy(),et=null;}let ve=new Set,at=NaN,Ee=true,qe=-1,lt=performance.now(),Le=NaN;function tt(){return j?K==="x"?j.scrollLeft:j.scrollTop:K==="x"?window.scrollX:window.scrollY}function ct(){return j?K==="x"?j.clientWidth:j.clientHeight:K==="x"?window.innerWidth:window.innerHeight}function ut(){let s=Ye(e,j,K),l=Ie(s,s.scroll,ct(),ae,ke);f=l.tStart,X=l.tEnd,ze&&Qe&&(it(),et=Wt(f,X,K));}function Mt(s,l){if(e.style.setProperty("--scroll-draw-progress",String(s)),H){let g=l==="reverse"?1-s:s;e.style.clipPath=le(g);return}T.forEach((g,N)=>{g.style.strokeDashoffset=l==="reverse"?`${b[N]*s}`:`${b[N]*(1-s)}`,u&&(g.style.opacity=l==="reverse"?`${1-s}`:`${s}`),U&&O?g.style.stroke=Oe(U,O,s):O&&(g.style.stroke=O),R!==null&&M!==null?g.style.strokeWidth=`${R+(M-R)*s}`:M!==null&&(g.style.strokeWidth=`${M}`),V!==null&&D!==null?g.style.fillOpacity=`${V+(D-V)*s}`:D!==null&&(g.style.fillOpacity=`${D}`),W&&g.tagName.toLowerCase()==="path"&&a[N]&&g.setAttribute("d",ot(a[N],W,s));});}function Be(){if(e.style.setProperty("--scroll-draw-progress","0"),H){e.style.clipPath=le(0);return}T.forEach((s,l)=>{s.style.strokeDasharray=`${b[l]}`,s.style.strokeDashoffset=x==="reverse"?"0":`${b[l]}`,u?s.style.opacity=x==="reverse"?"1":"0":s.style.opacity="",U&&(s.style.stroke=U),R!==null&&(s.style.strokeWidth=`${R}`),V!==null&&(s.style.fillOpacity=`${V}`),W&&s.tagName.toLowerCase()==="path"&&a[l]&&s.setAttribute("d",a[l]);});}if(T.forEach(s=>{zt(s);let l=Ce(s);b.push(l);let g=s.tagName.toLowerCase()==="path";g?a.push(s.getAttribute("d")??""):a.push(""),W&&(g?qt(a[a.length-1],W,s):ye(`morphTo only applies to <path> elements \u2014 ignored on <${s.tagName}>.`,s)),c?(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=x==="reverse"?`${l}`:"0",u&&(s.style.opacity="1"),O&&(s.style.stroke=O),M!==null&&(s.style.strokeWidth=`${M}`),D!==null&&(s.style.fillOpacity=`${D}`),W&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",W)):(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=x==="reverse"?"0":`${l}`,u?s.style.opacity=x==="reverse"?"1":"0":s.style.opacity="",U&&(s.style.stroke=U),R!==null&&(s.style.strokeWidth=`${R}`),V!==null&&(s.style.fillOpacity=`${V}`));}),H){if(c)return e.style.clipPath=le(1),q?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=le(0);}else if(c)return q?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let ft=typeof h=="string"?Ze(h):null;function kt(){return !(Ke===false||!Vt()||!T.length||!ft||H||K!=="y"||j||i!==1||z!==0||fe||xe||be!==false||W||oe||I||he>0||Te||G||q||se||$e||ie||pe||ne!=null||me!=null||ee!=null||(S.start??"top bottom").trim()!=="top bottom"||(S.end??"bottom top").trim()!=="bottom top")}function Lt(){let s=++Ht,l=`svg-scroll-draw-${s}`,g=`svg-scroll-draw-host-${s}`,N=`--svg-scroll-draw-${s}`,ge=x==="reverse"?"0":"var(--ssd-len)",ue=x==="reverse"?"var(--ssd-len)":"0",te=`stroke-dashoffset:${ge};`,y=`stroke-dashoffset:${ue};`;u&&(te+=`opacity:${x==="reverse"?1:0};`,y+=`opacity:${x==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${l}{from{${te}}to{${y}}}.${g}{view-timeline-name:${N};view-timeline-axis:block;}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${ft};animation-fill-mode:both;animation-timeline:${N};animation-range:cover 0% cover 100%;}`,document.head.appendChild(w),e.classList.add(g);function _(p,L){p.style.setProperty("--ssd-len",String(b[L])),p.style.strokeDasharray=`${b[L]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(l);}T.forEach(_);let d=false,E=-1;function P(){if(E>=0)return E;let p=e.getBoundingClientRect(),{tStart:L,tEnd:J}=Ie({top:p.top,height:p.height},tt(),ct(),ae,ke);return Q(re(tt(),L,J,i))}return {destroy(){e.classList.remove(g),T.forEach(p=>{p.classList.remove(l),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),w.remove();},replay(){d=false,E=-1,T.forEach(_);},pause(){d=true,T.forEach(p=>{p.style.animationPlayState="paused";});},resume(){d&&(d=false,T.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let L=Math.min(1,Math.max(0,p));E=L,d=true,T.forEach((J,B)=>{J.classList.remove(l),J.style.strokeDashoffset=x==="reverse"?`${b[B]*L}`:`${b[B]*(1-L)}`,u&&(J.style.opacity=x==="reverse"?`${1-L}`:`${L}`);});},getProgress(){return P()},refresh(){T.forEach((p,L)=>{b[L]=Ce(p),p.style.setProperty("--ssd-len",String(b[L])),p.style.strokeDasharray=`${b[L]}`;});}}}if(kt())return Lt();function Dt(){let s=Math.max(1,We),l=0,g=0,N=false;function ge(d){let E=true;if(H){let P=Math.min(1,Math.max(0,d/s)),p=Q(P);Z=p,e.style.setProperty("--scroll-draw-progress",String(p)),e.style.clipPath=le(x==="reverse"?1-p:p),Te?.(p),P<1&&(E=false);}else T.forEach((P,p)=>{let L=p*z*s,J=Math.min(1,Math.max(0,(d-L)/s)),B=Q(J);P.style.strokeDashoffset=x==="reverse"?`${b[p]*B}`:`${b[p]*(1-B)}`,u&&(P.style.opacity=x==="reverse"?`${1-B}`:`${B}`),U&&O?P.style.stroke=Oe(U,O,B):O&&(P.style.stroke=O),R!==null&&M!==null?P.style.strokeWidth=`${R+(M-R)*B}`:M!==null&&(P.style.strokeWidth=`${M}`),V!==null&&D!==null?P.style.fillOpacity=`${V+(D-V)*B}`:D!==null&&(P.style.fillOpacity=`${D}`),W&&P.tagName.toLowerCase()==="path"&&a[p]&&P.setAttribute("d",ot(a[p],W,B)),p===0&&(Z=B,Te?.(B),e.style.setProperty("--scroll-draw-progress",String(B))),J<1&&(E=false);});if(oe){let P=Math.min(1,Math.max(0,d/s)),p=Q(P);for(let L in oe){let J=parseFloat(L);p>=J&&!ve.has(J)&&(ve.add(J),oe[L]?.());}}return E}function ue(d){if(C)return;let E=d-l;$||($=true,G?.());let P=ge(E);if(P&&!v){v=true,ge(s*(1+Math.max(0,T.length-1)*z)),q?.(),de<(I==="infinite"?1/0:I??0)&&(de++,we=setTimeout(()=>{l=performance.now(),$=false,v=false,ve.clear(),Be(),A=requestAnimationFrame(ue);},Fe));return}P||(A=requestAnimationFrame(ue));}function te(){cancelAnimationFrame(A),clearTimeout(we),l=performance.now(),g=0,C=false,$=false,v=false,de=0,N=true,Z=0,ve.clear(),Be(),A=requestAnimationFrame(ue);}let y=new IntersectionObserver(d=>{d.forEach(E=>{E.isIntersecting&&!(fe&&v)?te():!E.isIntersecting&&!fe&&!v&&(cancelAnimationFrame(A),clearTimeout(we),N=false);});},{root:j??null,threshold:Re,rootMargin:Y}),w;function _(){clearTimeout(w),w=setTimeout(()=>{T.forEach((d,E)=>{b[E]=Ce(d),d.style.strokeDasharray=`${b[E]}`;});},150);}return window.addEventListener("resize",_),window.addEventListener("orientationchange",_),he>0?setTimeout(()=>y.observe(e),he):y.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(we),y.disconnect(),window.removeEventListener("resize",_),window.removeEventListener("orientationchange",_),clearTimeout(w);},replay(){de=0,te();},pause(){C||!N||(C=true,g=performance.now()-l,cancelAnimationFrame(A));},resume(){C&&(C=false,N=true,l=performance.now()-g,A=requestAnimationFrame(ue));},seek(d){let E=Math.min(1,Math.max(0,d));Z=E,C=true,g=E*s,l=performance.now()-g,cancelAnimationFrame(A),ge(g);},getProgress(){return Z},refresh(){clearTimeout(w),T.forEach((d,E)=>{b[E]=Ce(d),d.style.strokeDasharray=`${b[E]}`;});}}}if(Ne)return Dt();ut();function Ge(){if(!k||C)return;let s=performance.now(),l=tt();if(!Ee&&be===false&&l===at){A=requestAnimationFrame(Ge);return}Ee=false,at=l;let g=i;if(be!==false){let y=s-lt,w=y>0?Math.abs(l-(qe<0?l:qe))/y:0;g=i*Math.max(.2,1+w*(typeof be=="number"?be:1)*.04);}qe=l,lt=s;let N=xe?ce===-1||l>=ce?"forward":"reverse":x;ce=l;let ge=X-f,ue=true,te=ge===0?0:(l-f)/ge;if(isNaN(Le)||(Le<=0&&te>0?se?.():Le>0&&te<=0&&pe?.(),Le<1&&te>=1?$e?.():Le>=1&&te<1&&ie?.()),Le=te,H){let y=Q(re(l,f,X,g));fe&&!xe&&(F=Math.max(F,y),y=F),Z=y,e.style.setProperty("--scroll-draw-progress",String(y));let w=N==="reverse"?1-y:y;e.style.clipPath=le(w),Te?.(y),!$&&re(l,f,X,g)>0&&($=true,G?.()),y>=1&&!v?(v=true,q?.(),de<(I==="infinite"?1/0:I??0)&&(de++,we=setTimeout(()=>{F=-1,$=false,v=false,e.style.clipPath=le(0);},Fe))):y<1&&!fe&&(v=false),A=requestAnimationFrame(Ge);return}if(T.forEach((y,w)=>{let _=w*z*ge,d=Q(re(l,f+_,X+_,g));fe&&!xe&&(F=Math.max(F,d),d=F),Z=d,y.style.strokeDashoffset=N==="reverse"?`${b[w]*d}`:`${b[w]*(1-d)}`,u&&(y.style.opacity=N==="reverse"?`${1-d}`:`${d}`),U&&O?y.style.stroke=Oe(U,O,d):O&&(y.style.stroke=O),R!==null&&M!==null?y.style.strokeWidth=`${R+(M-R)*d}`:M!==null&&(y.style.strokeWidth=`${M}`),V!==null&&D!==null?y.style.fillOpacity=`${V+(D-V)*d}`:D!==null&&(y.style.fillOpacity=`${D}`),W&&y.tagName.toLowerCase()==="path"&&a[w]&&y.setAttribute("d",ot(a[w],W,d)),w===0&&(Te?.(d),e.style.setProperty("--scroll-draw-progress",String(d))),d<1&&(ue=false);}),oe){let y=Q(re(l,f,X,g));for(let w in oe){let _=parseFloat(w);y>=_&&!ve.has(_)&&(ve.add(_),oe[w]?.());}}!$&&re(l,f,X,g)>0&&($=true,G?.()),ue&&!v?(v=true,q?.(),de<(I==="infinite"?1/0:I??0)&&(de++,we=setTimeout(()=>{F=-1,$=false,v=false,ve.clear(),Be(),Ee=true;},Fe))):!ue&&!fe&&(v=false),A=requestAnimationFrame(Ge);}let rt=false;function je(){rt||(rt=true,A=requestAnimationFrame(function(){Ge();}));}function Ue(){rt=false,cancelAnimationFrame(A);}let nt=new IntersectionObserver(s=>{s.forEach(l=>{k=l.isIntersecting,k&&!C?(Ee=true,je()):Ue();});},{root:j??null,threshold:Re,rootMargin:Y});function mt(){T.forEach((s,l)=>{b[l]=Ce(s),s.style.strokeDasharray=`${b[l]}`;}),ut(),Ee=true;}let Xe;function _e(){clearTimeout(Xe),Xe=setTimeout(mt,150);}window.addEventListener("resize",_e),window.addEventListener("orientationchange",_e);let He;return typeof ResizeObserver<"u"&&(He=new ResizeObserver(()=>_e()),He.observe(document.body),He.observe(document.documentElement),He.observe(e)),he>0?setTimeout(()=>nt.observe(e),he):nt.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(we),Ue(),nt.disconnect(),He?.disconnect(),window.removeEventListener("resize",_e),window.removeEventListener("orientationchange",_e),clearTimeout(Xe),it();},replay(){F=-1,ce=-1,qe=-1,$=false,v=false,de=0,C=false,Z=0,ve.clear(),clearTimeout(we),Be(),Ee=true,k&&je();},pause(){C=true,Ue();},resume(){C&&(C=false,Ee=true,k&&je());},seek(s){let l=Math.min(1,Math.max(0,s));Z=l,F=l,C=true,Ue(),Mt(l,x),Ee=true;},getProgress(){return Z},refresh(){clearTimeout(Xe),mt(),k&&!C&&je();}}}var vt=new Map;function Et(e,n){vt.set(e,n);}function St(e){vt.delete(e);}function Bt(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 o=[],c=[],m=t[2].trim();if(m)for(let i of m.split(/[\s,]+/)){let u=i.match(/^([-+]?[\d.eE]+)(.*)$/);o.push(u?parseFloat(u[1]):0),c.push(u?u[2]:"");}n.push({fn:t[1],nums:o,units:c});}return n}function Gt(e,n,r){let t=xt(e),o=xt(n);return t.length===0||t.length!==o.length?r<1?e:n:t.map((c,m)=>{let i=o[m];return c.fn!==i.fn||c.nums.length!==i.nums.length?r<1?`${c.fn}(${c.nums.map((u,h)=>`${u}${c.units[h]}`).join(", ")})`:`${i.fn}(${i.nums.map((u,h)=>`${u}${i.units[h]}`).join(", ")})`:`${c.fn}(${c.nums.map((u,h)=>`${u+(i.nums[h]-u)*r}${c.units[h]}`).join(", ")})`}).join(" ")}function Tt(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),o=String(n);if(Bt(t))return Oe(t,o,r);if(t.includes("("))return Gt(t,o,r);let c=t.match(/^([-+]?[\d.]+)(.*)$/),m=o.match(/^([-+]?[\d.]+)(.*)$/);if(c&&m){let i=parseFloat(c[1]),u=parseFloat(m[1]);return `${i+(u-i)*r}${c[2]||m[2]}`}return r<1?t:o}function jt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var Ut=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Xt=0,$t="--scroll-draw-progress";function Yt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Je(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:o={},easing:c="ease-out",speed:m=1,once:i=false,axis:u="y",scrollContainer:h,native:S=true,velocityScale:z=false,respectReducedMotion:x=true,triggerElement:fe,onProgress:ze,onComplete:K,onEnter:Pe,onLeave:xe,onEnterBack:he,onLeaveBack:ne}=n,me=x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,ee=typeof c=="function"?c:Se[c]??Se["ease-out"],oe=De(o.start??"top bottom"),be=De(o.end??"bottom top"),Re=fe??e,Y=typeof h=="string"?document.querySelector(h):h??null,I=Object.entries(t).map(([a,f])=>({prop:jt(a),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function Fe(){let a=window.getComputedStyle(e);for(let f of I)f.from===""&&(f.from=a.getPropertyValue(f.prop).trim()||"0");}function W(){for(let a of I)e.style.setProperty(a.prop,String(a.to));}let Me=new Map;for(let a of [...I.map(f=>f.prop),$t])Me.set(a,e.style.getPropertyValue(a));function Ne(){for(let[a,f]of Me)f?e.style.setProperty(a,f):e.style.removeProperty(a);}if(me)return W(),K?.(),{...r,destroy:Ne,getProgress:()=>1};Fe();let We=typeof c=="string"?Ze(c):null;function Ke(){if(!S||!Yt()||!We||u!=="y"||Y||Re!==e||i||m!==1||ze||K||Pe||xe||he||ne||z!==false||(o.start??"top bottom").trim()!=="top bottom"||(o.end??"bottom top").trim()!=="bottom top")return false;for(let a of I)if(!Ut.has(a.prop))return false;return true}function Te(){let a=`ssd-a-${++Xt}`,f=I.map(k=>`${k.prop}:${k.from}`).join(";"),X=I.map(k=>`${k.prop}:${k.to}`).join(";"),v=document.createElement("style");v.setAttribute("data-ssd-animate",""),v.textContent=`@keyframes ${a}{from{${f}}to{${X}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${We};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(v),e.classList.add(a);let $=()=>u==="x"?window.scrollX:window.scrollY,A=()=>u==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),v.remove(),e.style.animationPlayState="",Ne();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(k){let F=Math.min(1,Math.max(0,k));e.classList.remove(a);for(let ce of I)e.style.setProperty(ce.prop,Tt(ce.from,ce.to,F));},getProgress(){let k=e.getBoundingClientRect(),F=$(),ce=A(),{tStart:C,tEnd:Z}=Ie({top:k.top,height:k.height},F,ce,oe,be);return ee(re(F,C,Z,m))}}}if(Ke())return Te();let G=0,q=0,se=0,$e=false,ie=false,pe=-1,H=0,Q=false,ae=NaN,ke=-1,j=0,U=()=>Y?u==="x"?Y.scrollLeft:Y.scrollTop:u==="x"?window.scrollX:window.scrollY,O=()=>Y?u==="x"?Y.clientWidth:Y.clientHeight:u==="x"?window.innerWidth:window.innerHeight;function R(){let a=Ye(Re,Y,u),f=Ie(a,a.scroll,O(),oe,be);G=f.tStart,q=f.tEnd;}function M(a){e.style.setProperty($t,String(a));for(let f of I)e.style.setProperty(f.prop,Tt(f.from,f.to,a));ze?.(a);}function V(a){if(isNaN(ae)){ae=a;return}ae<=0&&a>0?Pe?.():ae>0&&a<=0&&ne?.(),ae<1&&a>=1?xe?.():ae>=1&&a<1&&he?.(),ae=a;}function D(){if(!$e||ie)return;let a=performance.now(),f=U(),X=m;if(z!==false){let A=a-j,k=A>0?Math.abs(f-(ke<0?f:ke))/A:0;X=m*Math.max(.2,1+k*(typeof z=="number"?z:1)*.04);}ke=f,j=a;let v=q===G?0:(f-G)/(q-G);V(v);let $=ee(re(f,G,q,X));i&&(pe=Math.max(pe,$),$=pe),H=$,M($),$>=1&&!Q?(Q=true,K?.()):$<1&&!i&&(Q=false),se=requestAnimationFrame(D);}R(),q===G&&ye("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 a=ee(re(U(),G,q,m));i&&a>0&&(pe=a),H=a,M(a);}let le=new IntersectionObserver(a=>{a.forEach(f=>{$e=f.isIntersecting,$e&&!ie?se=requestAnimationFrame(D):cancelAnimationFrame(se);});},{root:Y??null}),T;function b(){clearTimeout(T),T=setTimeout(R,150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),le.observe(e),Et(e,{type:"animate",getProgress:()=>H,getTrigger:()=>({tStart:G,tEnd:q})}),{destroy(){cancelAnimationFrame(se),le.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(T),Ne(),St(e);},replay(){pe=-1,Q=false,H=0,ie=false,M(0);},pause(){ie=true,cancelAnimationFrame(se);},resume(){ie&&(ie=false,$e&&(se=requestAnimationFrame(D)));},seek(a){let f=Math.min(1,Math.max(0,a));H=f,pe=f,ie=true,cancelAnimationFrame(se),M(f);},getProgress(){return H}}}var At={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Pt(e,n={}){if(typeof window>"u")return At;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return ye("scrollParallax: element not found:",e),At;let{speed:t=.3,axis:o="y",easing:c="linear",trigger:m,onProgress:i}=n,u=r.getBoundingClientRect(),h=o==="x"?u.width:u.height,S=t*h;return Je(r,{props:o==="x"?{transform:["translateX(0px)",`translateX(${-S}px)`]}:{transform:["translateY(0px)",`translateY(${-S}px)`]},trigger:m??{start:"top bottom",end:"bottom top"},easing:c,native:false,onProgress:i})}function Ve(e){return e.map(n=>typeof n=="string"?document.querySelector(n):n).filter(n=>n!==null)}var Ae={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function dr(e,n={}){if(typeof window>"u")return Ae;let r=Ve(e).map(t=>st(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0},refresh(){r.forEach(t=>t.refresh?.());}}}function gr(e,n={}){if(typeof window>"u")return Ae;let r=Ve(e);if(r.length===0)return Ae;let t=0,o=[];function c(i){return st(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=Math.min(i+1,r.length-1),t>i&&o[t]?.resume();}})}function m(){r.forEach((i,u)=>{o[u]=c(u);});for(let i=1;i<o.length;i++)o[i].pause();}return m(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,m();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0},refresh(){o.forEach(i=>i.refresh?.());}}}function yr(e,n){if(typeof window>"u")return Ae;let r=Ve(e).map(t=>Je(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0},refresh(){r.forEach(t=>t.refresh?.());}}}function hr(e,n){if(typeof window>"u")return Ae;let r=Ve(e);if(r.length===0)return Ae;let t=0,o=[];function c(i){return Je(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=Math.min(i+1,r.length-1),t>i&&o[t]?.resume();}})}function m(){r.forEach((i,u)=>{o[u]=c(u);});for(let i=1;i<o.length;i++)o[i].pause();}return m(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,m();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0},refresh(){o.forEach(i=>i.refresh?.());}}}function br(e,n={}){if(typeof window>"u")return Ae;let r=Ve(e).map(t=>Pt(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0},refresh(){r.forEach(t=>t.refresh?.());}}}exports.scrollAnimateGroup=yr;exports.scrollAnimateSequence=hr;exports.scrollDrawGroup=dr;exports.scrollDrawSequence=gr;exports.scrollParallaxGroup=br;
|
|
3
|
+
<div style="position:absolute;${u?`left:${i}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${i}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",o,{passive:true}),o(),{el:t,destroy(){window.removeEventListener("scroll",o),t.remove();}}}var Tt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,$t=/[MmLlHhVvCcSsQqTtAaZz]/g;function jt(e,n,r){if(!Ke)return;let t=(e.match($t)??[]).join("").toUpperCase(),o=(n.match($t)??[]).join("").toUpperCase(),c=(e.match(Tt)??[]).length,m=(n.match(Tt)??[]).length;if(t!==o){ye(`morphTo: command sequence differs (${t||"\u2205"} \u2192 ${o||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}c!==m&&ye(`morphTo: coordinate count differs (${c} \u2192 ${m}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function at(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),o=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,c=>{let m=parseFloat(c),i=t[o++]??m;return String(+(m+(i-m)*r).toFixed(4))})}function lt(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,o=r?{...vt[r],...t}:t,c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:m="path, polyline, line, polygon, rect, circle",speed:i=1,fade:u=false,easing:h="linear",trigger:S={},stagger:V=0,direction:x="forward",once:fe=false,debug:qe=false,axis:J="y",scrollContainer:Pe,autoReverse:xe=false,delay:he=0,strokeColor:oe,strokeWidth:me,fillOpacity:ee,waypoints:se,velocityScale:be=false,threshold:Re=0,rootMargin:Q="0px",repeat:C=0,repeatDelay:Fe=0,morphTo:z,clip:Me,autoplay:Ne=false,duration:Be=1e3,native:tt=true,onProgress:Te,onStart:U,onComplete:W,onEnter:ie,onLeave:$e,onEnterBack:ae,onLeaveBack:pe}=o,_=Me===true?"left":typeof Me=="string"?Me:false,Z=typeof h=="function"?h:Se[h]??Se.linear,le=De(S.start??"top bottom"),ke=De(S.end??"bottom top"),X=typeof Pe=="string"?document.querySelector(Pe):Pe??null,Y=Array.isArray(oe)?oe[0]:null,O=Array.isArray(oe)?oe[1]:typeof oe=="string"?oe:null,R=Array.isArray(me)?me[0]:null,M=Array.isArray(me)?me[1]:typeof me=="number"?me:null,H=Array.isArray(ee)?ee[0]:null,D=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null;function ce(s){let l=s*100;switch(_){case "right":return `inset(0 0 0 ${100-l}%)`;case "top":return `inset(0 0 ${100-l}% 0)`;case "bottom":return `inset(${100-l}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-l}% 0 0)`}}let T=_?[]:Array.from(e.querySelectorAll(m)),b=[],a=[],f=0,q=0,v=false,$=false,A=0,te=false,B=-1,I=-1,k=false,G=0,de=0,we,rt=null;function ct(){rt?.destroy(),rt=null;}let ve=new Set,ut=NaN,Ee=true,Ge=-1,ft=performance.now(),Le=NaN;function nt(){return X?J==="x"?X.scrollLeft:X.scrollTop:J==="x"?window.scrollX:window.scrollY}function mt(){return X?J==="x"?X.clientWidth:X.clientHeight:J==="x"?window.innerWidth:window.innerHeight}function pt(){let s=Ze(e,X,J);return Ce(s,s.scroll,mt(),le,ke)}function dt(){(({tStart:f,tEnd:q}=pt())),qe&&Ke&&(ct(),rt=Gt(f,q,J));}function ot(s,l=pt){Ve(e,{type:"draw",getProgress:()=>s.getProgress(),getTrigger:l});let g=s.destroy;return s.destroy=()=>{g.call(s),ze(e);},s}function Dt(s,l){if(e.style.setProperty("--scroll-draw-progress",String(s)),_){let g=l==="reverse"?1-s:s;e.style.clipPath=ce(g);return}T.forEach((g,F)=>{g.style.strokeDashoffset=l==="reverse"?`${b[F]*s}`:`${b[F]*(1-s)}`,u&&(g.style.opacity=l==="reverse"?`${1-s}`:`${s}`),Y&&O?g.style.stroke=Oe(Y,O,s):O&&(g.style.stroke=O),R!==null&&M!==null?g.style.strokeWidth=`${R+(M-R)*s}`:M!==null&&(g.style.strokeWidth=`${M}`),H!==null&&D!==null?g.style.fillOpacity=`${H+(D-H)*s}`:D!==null&&(g.style.fillOpacity=`${D}`),z&&g.tagName.toLowerCase()==="path"&&a[F]&&g.setAttribute("d",at(a[F],z,s));});}function je(){if(e.style.setProperty("--scroll-draw-progress","0"),_){e.style.clipPath=ce(0);return}T.forEach((s,l)=>{s.style.strokeDasharray=`${b[l]}`,s.style.strokeDashoffset=x==="reverse"?"0":`${b[l]}`,u?s.style.opacity=x==="reverse"?"1":"0":s.style.opacity="",Y&&(s.style.stroke=Y),R!==null&&(s.style.strokeWidth=`${R}`),H!==null&&(s.style.fillOpacity=`${H}`),z&&s.tagName.toLowerCase()==="path"&&a[l]&&s.setAttribute("d",a[l]);});}if(T.forEach(s=>{Bt(s);let l=Ie(s);b.push(l);let g=s.tagName.toLowerCase()==="path";g?a.push(s.getAttribute("d")??""):a.push(""),z&&(g?jt(a[a.length-1],z,s):ye(`morphTo only applies to <path> elements \u2014 ignored on <${s.tagName}>.`,s)),c?(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=x==="reverse"?`${l}`:"0",u&&(s.style.opacity="1"),O&&(s.style.stroke=O),M!==null&&(s.style.strokeWidth=`${M}`),D!==null&&(s.style.fillOpacity=`${D}`),z&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",z)):(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=x==="reverse"?"0":`${l}`,u?s.style.opacity=x==="reverse"?"1":"0":s.style.opacity="",Y&&(s.style.stroke=Y),R!==null&&(s.style.strokeWidth=`${R}`),H!==null&&(s.style.fillOpacity=`${H}`));}),_){if(c)return e.style.clipPath=ce(1),W?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ce(0);}else if(c)return W?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let gt=typeof h=="string"?Je(h):null;function It(){return !(tt===false||!qt()||!T.length||!gt||_||J!=="y"||X||i!==1||V!==0||fe||xe||be!==false||z||se||C||he>0||Te||U||W||ie||$e||ae||pe||oe!=null||me!=null||ee!=null||(S.start??"top bottom").trim()!=="top bottom"||(S.end??"bottom top").trim()!=="bottom top")}function Ct(){let s=++Wt,l=`svg-scroll-draw-${s}`,g=`svg-scroll-draw-host-${s}`,F=`--svg-scroll-draw-${s}`,ge=x==="reverse"?"0":"var(--ssd-len)",ue=x==="reverse"?"var(--ssd-len)":"0",re=`stroke-dashoffset:${ge};`,y=`stroke-dashoffset:${ue};`;u&&(re+=`opacity:${x==="reverse"?1:0};`,y+=`opacity:${x==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${l}{from{${re}}to{${y}}}.${g}{view-timeline-name:${F};view-timeline-axis:block;}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${gt};animation-fill-mode:both;animation-timeline:${F};animation-range:cover 0% cover 100%;}`,document.head.appendChild(w),e.classList.add(g);function N(p,L){p.style.setProperty("--ssd-len",String(b[L])),p.style.strokeDasharray=`${b[L]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(l);}T.forEach(N);let d=false,E=-1;function P(){if(E>=0)return E;let p=e.getBoundingClientRect(),{tStart:L,tEnd:K}=Ce({top:p.top,height:p.height},nt(),mt(),le,ke);return Z(ne(nt(),L,K,i))}return {destroy(){e.classList.remove(g),T.forEach(p=>{p.classList.remove(l),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),w.remove();},replay(){d=false,E=-1,T.forEach(N);},pause(){d=true,T.forEach(p=>{p.style.animationPlayState="paused";});},resume(){d&&(d=false,T.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let L=Math.min(1,Math.max(0,p));E=L,d=true,T.forEach((K,j)=>{K.classList.remove(l),K.style.strokeDashoffset=x==="reverse"?`${b[j]*L}`:`${b[j]*(1-L)}`,u&&(K.style.opacity=x==="reverse"?`${1-L}`:`${L}`);});},getProgress(){return P()},refresh(){T.forEach((p,L)=>{b[L]=Ie(p),p.style.setProperty("--ssd-len",String(b[L])),p.style.strokeDasharray=`${b[L]}`;});}}}if(It())return ot(Ct());function Ot(){let s=Math.max(1,Be),l=0,g=0,F=false;function ge(d){let E=true;if(_){let P=Math.min(1,Math.max(0,d/s)),p=Z(P);G=p,e.style.setProperty("--scroll-draw-progress",String(p)),e.style.clipPath=ce(x==="reverse"?1-p:p),Te?.(p),P<1&&(E=false);}else T.forEach((P,p)=>{let L=p*V*s,K=Math.min(1,Math.max(0,(d-L)/s)),j=Z(K);P.style.strokeDashoffset=x==="reverse"?`${b[p]*j}`:`${b[p]*(1-j)}`,u&&(P.style.opacity=x==="reverse"?`${1-j}`:`${j}`),Y&&O?P.style.stroke=Oe(Y,O,j):O&&(P.style.stroke=O),R!==null&&M!==null?P.style.strokeWidth=`${R+(M-R)*j}`:M!==null&&(P.style.strokeWidth=`${M}`),H!==null&&D!==null?P.style.fillOpacity=`${H+(D-H)*j}`:D!==null&&(P.style.fillOpacity=`${D}`),z&&P.tagName.toLowerCase()==="path"&&a[p]&&P.setAttribute("d",at(a[p],z,j)),p===0&&(G=j,Te?.(j),e.style.setProperty("--scroll-draw-progress",String(j))),K<1&&(E=false);});if(se){let P=Math.min(1,Math.max(0,d/s)),p=Z(P);for(let L in se){let K=parseFloat(L);p>=K&&!ve.has(K)&&(ve.add(K),se[L]?.());}}return E}function ue(d){if(k)return;let E=d-l;$||($=true,U?.());let P=ge(E);if(P&&!v){v=true,ge(s*(1+Math.max(0,T.length-1)*V)),W?.(),de<(C==="infinite"?1/0:C??0)&&(de++,we=setTimeout(()=>{l=performance.now(),$=false,v=false,ve.clear(),je(),A=requestAnimationFrame(ue);},Fe));return}P||(A=requestAnimationFrame(ue));}function re(){cancelAnimationFrame(A),clearTimeout(we),l=performance.now(),g=0,k=false,$=false,v=false,de=0,F=true,G=0,ve.clear(),je(),A=requestAnimationFrame(ue);}let y=new IntersectionObserver(d=>{d.forEach(E=>{E.isIntersecting&&!(fe&&v)?re():!E.isIntersecting&&!fe&&!v&&(cancelAnimationFrame(A),clearTimeout(we),F=false);});},{root:X??null,threshold:Re,rootMargin:Q}),w;function N(){clearTimeout(w),w=setTimeout(()=>{T.forEach((d,E)=>{b[E]=Ie(d),d.style.strokeDasharray=`${b[E]}`;});},150);}return window.addEventListener("resize",N),window.addEventListener("orientationchange",N),he>0?setTimeout(()=>y.observe(e),he):y.observe(e),{destroy(){cancelAnimationFrame(A),clearTimeout(we),y.disconnect(),window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N),clearTimeout(w);},replay(){de=0,re();},pause(){k||!F||(k=true,g=performance.now()-l,cancelAnimationFrame(A));},resume(){k&&(k=false,F=true,l=performance.now()-g,A=requestAnimationFrame(ue));},seek(d){let E=Math.min(1,Math.max(0,d));G=E,k=true,g=E*s,l=performance.now()-g,cancelAnimationFrame(A),ge(g);},getProgress(){return G},refresh(){clearTimeout(w),T.forEach((d,E)=>{b[E]=Ie(d),d.style.strokeDasharray=`${b[E]}`;});}}}if(Ne)return ot(Ot());dt();function Ue(){if(!te||k)return;let s=performance.now(),l=nt();if(!Ee&&be===false&&l===ut){A=requestAnimationFrame(Ue);return}Ee=false,ut=l;let g=i;if(be!==false){let y=s-ft,w=y>0?Math.abs(l-(Ge<0?l:Ge))/y:0;g=i*Math.max(.2,1+w*(typeof be=="number"?be:1)*.04);}Ge=l,ft=s;let F=xe?I===-1||l>=I?"forward":"reverse":x;I=l;let ge=q-f,ue=true,re=ge===0?0:(l-f)/ge;if(isNaN(Le)||(Le<=0&&re>0?ie?.():Le>0&&re<=0&&pe?.(),Le<1&&re>=1?$e?.():Le>=1&&re<1&&ae?.()),Le=re,_){let y=Z(ne(l,f,q,g));fe&&!xe&&(B=Math.max(B,y),y=B),G=y,e.style.setProperty("--scroll-draw-progress",String(y));let w=F==="reverse"?1-y:y;e.style.clipPath=ce(w),Te?.(y),!$&&ne(l,f,q,g)>0&&($=true,U?.()),y>=1&&!v?(v=true,W?.(),de<(C==="infinite"?1/0:C??0)&&(de++,we=setTimeout(()=>{B=-1,$=false,v=false,e.style.clipPath=ce(0);},Fe))):y<1&&!fe&&(v=false),A=requestAnimationFrame(Ue);return}if(T.forEach((y,w)=>{let N=w*V*ge,d=Z(ne(l,f+N,q+N,g));fe&&!xe&&(B=Math.max(B,d),d=B),G=d,y.style.strokeDashoffset=F==="reverse"?`${b[w]*d}`:`${b[w]*(1-d)}`,u&&(y.style.opacity=F==="reverse"?`${1-d}`:`${d}`),Y&&O?y.style.stroke=Oe(Y,O,d):O&&(y.style.stroke=O),R!==null&&M!==null?y.style.strokeWidth=`${R+(M-R)*d}`:M!==null&&(y.style.strokeWidth=`${M}`),H!==null&&D!==null?y.style.fillOpacity=`${H+(D-H)*d}`:D!==null&&(y.style.fillOpacity=`${D}`),z&&y.tagName.toLowerCase()==="path"&&a[w]&&y.setAttribute("d",at(a[w],z,d)),w===0&&(Te?.(d),e.style.setProperty("--scroll-draw-progress",String(d))),d<1&&(ue=false);}),se){let y=Z(ne(l,f,q,g));for(let w in se){let N=parseFloat(w);y>=N&&!ve.has(N)&&(ve.add(N),se[w]?.());}}!$&&ne(l,f,q,g)>0&&($=true,U?.()),ue&&!v?(v=true,W?.(),de<(C==="infinite"?1/0:C??0)&&(de++,we=setTimeout(()=>{B=-1,$=false,v=false,ve.clear(),je(),Ee=true;},Fe))):!ue&&!fe&&(v=false),A=requestAnimationFrame(Ue);}let st=false;function Xe(){st||(st=true,A=requestAnimationFrame(function(){Ue();}));}function Ye(){st=false,cancelAnimationFrame(A);}let it=new IntersectionObserver(s=>{s.forEach(l=>{te=l.isIntersecting,te&&!k?(Ee=true,Xe()):Ye();});},{root:X??null,threshold:Re,rootMargin:Q});function yt(){T.forEach((s,l)=>{b[l]=Ie(s),s.style.strokeDasharray=`${b[l]}`;}),dt(),Ee=true;}let Qe;function _e(){clearTimeout(Qe),Qe=setTimeout(yt,150);}window.addEventListener("resize",_e),window.addEventListener("orientationchange",_e);let He;return typeof ResizeObserver<"u"&&(He=new ResizeObserver(()=>_e()),He.observe(document.body),He.observe(document.documentElement),He.observe(e)),he>0?setTimeout(()=>it.observe(e),he):it.observe(e),ot({destroy(){cancelAnimationFrame(A),clearTimeout(we),Ye(),it.disconnect(),He?.disconnect(),window.removeEventListener("resize",_e),window.removeEventListener("orientationchange",_e),clearTimeout(Qe),ct();},replay(){B=-1,I=-1,Ge=-1,$=false,v=false,de=0,k=false,G=0,ve.clear(),clearTimeout(we),je(),Ee=true,te&&Xe();},pause(){k=true,Ye();},resume(){k&&(k=false,Ee=true,te&&Xe());},seek(s){let l=Math.min(1,Math.max(0,s));G=l,B=l,k=true,Ye(),Dt(l,x),Ee=true;},getProgress(){return G},refresh(){clearTimeout(Qe),yt(),te&&!k&&Xe();}},()=>({tStart:f,tEnd:q}))}function Ut(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function At(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let o=[],c=[],m=t[2].trim();if(m)for(let i of m.split(/[\s,]+/)){let u=i.match(/^([-+]?[\d.eE]+)(.*)$/);o.push(u?parseFloat(u[1]):0),c.push(u?u[2]:"");}n.push({fn:t[1],nums:o,units:c});}return n}function Xt(e,n,r){let t=At(e),o=At(n);return t.length===0||t.length!==o.length?r<1?e:n:t.map((c,m)=>{let i=o[m];return c.fn!==i.fn||c.nums.length!==i.nums.length?r<1?`${c.fn}(${c.nums.map((u,h)=>`${u}${c.units[h]}`).join(", ")})`:`${i.fn}(${i.nums.map((u,h)=>`${u}${i.units[h]}`).join(", ")})`:`${c.fn}(${c.nums.map((u,h)=>`${u+(i.nums[h]-u)*r}${c.units[h]}`).join(", ")})`}).join(" ")}function Pt(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),o=String(n);if(Ut(t))return Oe(t,o,r);if(t.includes("("))return Xt(t,o,r);let c=t.match(/^([-+]?[\d.]+)(.*)$/),m=o.match(/^([-+]?[\d.]+)(.*)$/);if(c&&m){let i=parseFloat(c[1]),u=parseFloat(m[1]);return `${i+(u-i)*r}${c[2]||m[2]}`}return r<1?t:o}function Yt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var Qt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Zt=0,Mt="--scroll-draw-progress";function Kt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function et(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:o={},easing:c="ease-out",speed:m=1,once:i=false,axis:u="y",scrollContainer:h,native:S=true,velocityScale:V=false,respectReducedMotion:x=true,triggerElement:fe,onProgress:qe,onComplete:J,onEnter:Pe,onLeave:xe,onEnterBack:he,onLeaveBack:oe}=n,me=x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,ee=typeof c=="function"?c:Se[c]??Se["ease-out"],se=De(o.start??"top bottom"),be=De(o.end??"bottom top"),Re=fe??e,Q=typeof h=="string"?document.querySelector(h):h??null,C=Object.entries(t).map(([a,f])=>({prop:Yt(a),from:Array.isArray(f)?f[0]:"",to:Array.isArray(f)?f[1]:f}));function Fe(){let a=window.getComputedStyle(e);for(let f of C)f.from===""&&(f.from=a.getPropertyValue(f.prop).trim()||"0");}function z(){for(let a of C)e.style.setProperty(a.prop,String(a.to));}let Me=new Map;for(let a of [...C.map(f=>f.prop),Mt])Me.set(a,e.style.getPropertyValue(a));function Ne(){for(let[a,f]of Me)f?e.style.setProperty(a,f):e.style.removeProperty(a);}if(me)return z(),J?.(),{...r,destroy:Ne,getProgress:()=>1};Fe();let Be=typeof c=="string"?Je(c):null;function tt(){if(!S||!Kt()||!Be||u!=="y"||Q||Re!==e||i||m!==1||qe||J||Pe||xe||he||oe||V!==false||(o.start??"top bottom").trim()!=="top bottom"||(o.end??"bottom top").trim()!=="bottom top")return false;for(let a of C)if(!Qt.has(a.prop))return false;return true}function Te(){let a=`ssd-a-${++Zt}`,f=C.map(I=>`${I.prop}:${I.from}`).join(";"),q=C.map(I=>`${I.prop}:${I.to}`).join(";"),v=document.createElement("style");v.setAttribute("data-ssd-animate",""),v.textContent=`@keyframes ${a}{from{${f}}to{${q}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${Be};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(v),e.classList.add(a);let $=()=>u==="x"?window.scrollX:window.scrollY,A=()=>u==="x"?window.innerWidth:window.innerHeight,te=()=>{let I=e.getBoundingClientRect();return Ce({top:I.top,height:I.height},$(),A(),se,be)};Ve(e,{type:"animate",getProgress:()=>B.getProgress(),getTrigger:te});let B={destroy(){e.classList.remove(a),v.remove(),e.style.animationPlayState="",Ne(),ze(e);},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(I){let k=Math.min(1,Math.max(0,I));e.classList.remove(a);for(let G of C)e.style.setProperty(G.prop,Pt(G.from,G.to,k));},getProgress(){let{tStart:I,tEnd:k}=te();return ee(ne($(),I,k,m))}};return B}if(tt())return Te();let U=0,W=0,ie=0,$e=false,ae=false,pe=-1,_=0,Z=false,le=NaN,ke=-1,X=0,Y=()=>Q?u==="x"?Q.scrollLeft:Q.scrollTop:u==="x"?window.scrollX:window.scrollY,O=()=>Q?u==="x"?Q.clientWidth:Q.clientHeight:u==="x"?window.innerWidth:window.innerHeight;function R(){let a=Ze(Re,Q,u),f=Ce(a,a.scroll,O(),se,be);U=f.tStart,W=f.tEnd;}function M(a){e.style.setProperty(Mt,String(a));for(let f of C)e.style.setProperty(f.prop,Pt(f.from,f.to,a));qe?.(a);}function H(a){if(isNaN(le)){le=a;return}le<=0&&a>0?Pe?.():le>0&&a<=0&&oe?.(),le<1&&a>=1?xe?.():le>=1&&a<1&&he?.(),le=a;}function D(){if(!$e||ae)return;let a=performance.now(),f=Y(),q=m;if(V!==false){let A=a-X,te=A>0?Math.abs(f-(ke<0?f:ke))/A:0;q=m*Math.max(.2,1+te*(typeof V=="number"?V:1)*.04);}ke=f,X=a;let v=W===U?0:(f-U)/(W-U);H(v);let $=ee(ne(f,U,W,q));i&&(pe=Math.max(pe,$),$=pe),_=$,M($),$>=1&&!Z?(Z=true,J?.()):$<1&&!i&&(Z=false),ie=requestAnimationFrame(D);}R(),W===U&&ye("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 a=ee(ne(Y(),U,W,m));i&&a>0&&(pe=a),_=a,M(a);}let ce=new IntersectionObserver(a=>{a.forEach(f=>{$e=f.isIntersecting,$e&&!ae?ie=requestAnimationFrame(D):cancelAnimationFrame(ie);});},{root:Q??null}),T;function b(){clearTimeout(T),T=setTimeout(R,150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),ce.observe(e),Ve(e,{type:"animate",getProgress:()=>_,getTrigger:()=>({tStart:U,tEnd:W})}),{destroy(){cancelAnimationFrame(ie),ce.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(T),Ne(),ze(e);},replay(){pe=-1,Z=false,_=0,ae=false,M(0);},pause(){ae=true,cancelAnimationFrame(ie);},resume(){ae&&(ae=false,$e&&(ie=requestAnimationFrame(D)));},seek(a){let f=Math.min(1,Math.max(0,a));_=f,pe=f,ae=true,cancelAnimationFrame(ie),M(f);},getProgress(){return _}}}var kt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Lt(e,n={}){if(typeof window>"u")return kt;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return ye("scrollParallax: element not found:",e),kt;let{speed:t=.3,axis:o="y",easing:c="linear",trigger:m,onProgress:i}=n,u=r.getBoundingClientRect(),h=o==="x"?u.width:u.height,S=t*h;return et(r,{props:o==="x"?{transform:["translateX(0px)",`translateX(${-S}px)`]}:{transform:["translateY(0px)",`translateY(${-S}px)`]},trigger:m??{start:"top bottom",end:"bottom top"},easing:c,native:false,onProgress:i})}function We(e){return e.map(n=>typeof n=="string"?document.querySelector(n):n).filter(n=>n!==null)}var Ae={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function br(e,n={}){if(typeof window>"u")return Ae;let r=We(e).map(t=>lt(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0},refresh(){r.forEach(t=>t.refresh?.());}}}function wr(e,n={}){if(typeof window>"u")return Ae;let r=We(e);if(r.length===0)return Ae;let t=0,o=[];function c(i){return lt(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=Math.min(i+1,r.length-1),t>i&&o[t]?.resume();}})}function m(){r.forEach((i,u)=>{o[u]=c(u);});for(let i=1;i<o.length;i++)o[i].pause();}return m(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,m();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0},refresh(){o.forEach(i=>i.refresh?.());}}}function vr(e,n){if(typeof window>"u")return Ae;let r=We(e).map(t=>et(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0},refresh(){r.forEach(t=>t.refresh?.());}}}function Er(e,n){if(typeof window>"u")return Ae;let r=We(e);if(r.length===0)return Ae;let t=0,o=[];function c(i){return et(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=Math.min(i+1,r.length-1),t>i&&o[t]?.resume();}})}function m(){r.forEach((i,u)=>{o[u]=c(u);});for(let i=1;i<o.length;i++)o[i].pause();}return m(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,m();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0},refresh(){o.forEach(i=>i.refresh?.());}}}function Sr(e,n={}){if(typeof window>"u")return Ae;let r=We(e).map(t=>Lt(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0},refresh(){r.forEach(t=>t.refresh?.());}}}exports.scrollAnimateGroup=vr;exports.scrollAnimateSequence=Er;exports.scrollDrawGroup=br;exports.scrollDrawSequence=wr;exports.scrollParallaxGroup=Sr;
|