svg-scroll-draw 2.7.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/index.cjs +3 -3
- package/dist/angular/index.d.mts +48 -0
- package/dist/angular/index.d.ts +48 -0
- package/dist/angular/index.mjs +3 -3
- package/dist/astro/index.cjs +3 -3
- package/dist/astro/index.d.mts +20 -5
- package/dist/astro/index.d.ts +20 -5
- package/dist/astro/index.mjs +3 -3
- package/dist/cdn/svg-scroll-draw.dev.global.js +1878 -0
- package/dist/cdn/svg-scroll-draw.global.js +3 -3
- package/dist/cinematic/index.cjs +2 -2
- package/dist/cinematic/index.mjs +2 -2
- package/dist/cli/init.js +104 -101
- package/dist/devtools/index.cjs +1 -1
- package/dist/devtools/index.mjs +1 -1
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +48 -0
- package/dist/group/index.d.ts +48 -0
- package/dist/group/index.mjs +3 -3
- package/dist/horizontal/index.cjs +1 -0
- package/dist/horizontal/index.d.mts +108 -0
- package/dist/horizontal/index.d.ts +108 -0
- package/dist/horizontal/index.mjs +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.mjs +4 -4
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +33 -0
- package/dist/nuxt/index.d.ts +33 -0
- package/dist/nuxt/index.mjs +3 -3
- package/dist/pin/index.cjs +1 -1
- package/dist/pin/index.mjs +1 -1
- package/dist/progress/index.cjs +1 -0
- package/dist/progress/index.d.mts +74 -0
- package/dist/progress/index.d.ts +74 -0
- package/dist/progress/index.mjs +1 -0
- package/dist/react/index.cjs +3 -3
- package/dist/react/index.d.mts +33 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.mjs +3 -3
- package/dist/reveal/index.cjs +1 -0
- package/dist/reveal/index.d.mts +80 -0
- package/dist/reveal/index.d.ts +80 -0
- package/dist/reveal/index.mjs +1 -0
- package/dist/snap/index.cjs +1 -1
- package/dist/snap/index.d.mts +8 -0
- package/dist/snap/index.d.ts +8 -0
- package/dist/snap/index.mjs +1 -1
- package/dist/solid/index.cjs +3 -3
- package/dist/solid/index.d.mts +48 -0
- package/dist/solid/index.d.ts +48 -0
- package/dist/solid/index.mjs +3 -3
- package/dist/svelte/index.cjs +3 -3
- package/dist/svelte/index.d.mts +48 -0
- package/dist/svelte/index.d.ts +48 -0
- package/dist/svelte/index.mjs +3 -3
- package/dist/text/index.cjs +1 -1
- package/dist/text/index.d.mts +15 -0
- package/dist/text/index.d.ts +15 -0
- package/dist/text/index.mjs +1 -1
- package/dist/timeline/index.cjs +8 -8
- package/dist/timeline/index.d.mts +31 -0
- package/dist/timeline/index.d.ts +31 -0
- package/dist/timeline/index.mjs +8 -8
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.d.mts +15 -0
- package/dist/video/index.d.ts +15 -0
- package/dist/video/index.mjs +1 -1
- package/dist/vue/index.cjs +3 -3
- package/dist/vue/index.d.mts +33 -0
- package/dist/vue/index.d.ts +33 -0
- package/dist/vue/index.mjs +3 -3
- package/dist/web-component/index.cjs +3 -3
- package/dist/web-component/index.mjs +3 -3
- package/package.json +37 -5
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var SvgScrollDraw=(()=>{var
|
|
2
|
-
<div style="position:absolute;${c?`left:${
|
|
3
|
-
<div style="position:absolute;${c?`left:${f}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${f}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`}return document.body.appendChild(n),window.addEventListener("scroll",a,{passive:!0}),a(),n}function tt(e,r,t){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,i=>{let g=parseFloat(i),f=n[a++]??g;return String(+(g+(f-g)*t).toFixed(4))})}function We(e,r={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:t,...n}=r,a=t?{...Be[t],...n}:n,i=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:g="path, polyline, line, polygon, rect, circle",speed:f=1,fade:c=!1,easing:p="linear",trigger:T={},stagger:H=0,direction:v="forward",once:_=!1,debug:pe=!1,axis:x="y",scrollContainer:$,autoReverse:y=!1,delay:E=0,strokeColor:b,strokeWidth:F,fillOpacity:A,waypoints:C,velocityScale:te=!1,threshold:de=0,rootMargin:be="0px",repeat:ie=0,repeatDelay:Y=0,morphTo:L,clip:j,autoplay:ge=!1,duration:re=1e3,native:ne=!0,onProgress:d,onStart:q,onComplete:U,onEnter:xe,onLeave:Oe,onEnterBack:Le,onLeaveBack:Ae}=a,ue=j===!0?"left":typeof j=="string"?j:!1,ae=typeof p=="function"?p:Q[p]??Q.linear,Ie=he(T.start??"top bottom"),Me=he(T.end??"bottom top"),z=typeof $=="string"?document.querySelector($):$??null,s=Array.isArray(b)?b[0]:null,m=Array.isArray(b)?b[1]:typeof b=="string"?b:null,N=Array.isArray(F)?F[0]:null,I=Array.isArray(F)?F[1]:typeof F=="number"?F:null,V=Array.isArray(A)?A[0]:null,G=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function B(o){let l=o*100;switch(ue){case"right":return`inset(0 0 0 ${100-l}%)`;case"top":return`inset(0 0 ${100-l}% 0)`;case"bottom":return`inset(${100-l}% 0 0 0)`;case"center":return`circle(${o*150}% at 50% 50%)`;default:return`inset(0 ${100-l}% 0 0)`}}let O=ue?[]:Array.from(e.querySelectorAll(g)),M=[],oe=[],le=0,we=0,X=!1,ce=!1,W=0,Fe=!1,me=-1,Ne=-1,Z=!1,Te=0,ye=0,ve,Ue=null,Ee=new Set,Re=-1,st=performance.now(),ke=NaN;function De(){return z?x==="x"?z.scrollLeft:z.scrollTop:x==="x"?window.scrollX:window.scrollY}function it(){return z?x==="x"?z.clientWidth:z.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function at(){let o=e.getBoundingClientRect(),l,w,R;if(z){let K=z.getBoundingClientRect();l=x==="x"?o.left-K.left+z.scrollLeft:o.top-K.top+z.scrollTop,w=x==="x"?o.width:o.height,R=De()}else l=x==="x"?o.left:o.top,w=x==="x"?o.width:o.height,R=De();let J=Se({top:l,height:w},R,it(),Ie,Me);le=J.tStart,we=J.tEnd,pe&&process.env.NODE_ENV!=="production"&&(Ue?.remove(),Ue=Rt(le,we,x))}function xt(o,l){if(e.style.setProperty("--scroll-draw-progress",String(o)),ue){let w=l==="reverse"?1-o:o;e.style.clipPath=B(w);return}O.forEach((w,R)=>{w.style.strokeDashoffset=l==="reverse"?`${M[R]*o}`:`${M[R]*(1-o)}`,c&&(w.style.opacity=l==="reverse"?`${1-o}`:`${o}`),s&&m?w.style.stroke=Ce(s,m,o):m&&(w.style.stroke=m),N!==null&&I!==null?w.style.strokeWidth=`${N+(I-N)*o}`:I!==null&&(w.style.strokeWidth=`${I}`),V!==null&&G!==null?w.style.fillOpacity=`${V+(G-V)*o}`:G!==null&&(w.style.fillOpacity=`${G}`),L&&w.tagName.toLowerCase()==="path"&&oe[R]&&w.setAttribute("d",tt(oe[R],L,o))})}function He(){if(e.style.setProperty("--scroll-draw-progress","0"),ue){e.style.clipPath=B(0);return}O.forEach((o,l)=>{o.style.strokeDasharray=`${M[l]}`,o.style.strokeDashoffset=v==="reverse"?"0":`${M[l]}`,c?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`),L&&o.tagName.toLowerCase()==="path"&&oe[l]&&o.setAttribute("d",oe[l])})}if(O.forEach(o=>{Nt(o);let l=Ve(o);M.push(l),o.tagName.toLowerCase()==="path"?oe.push(o.getAttribute("d")??""):oe.push(""),i?(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=v==="reverse"?`${l}`:"0",c&&(o.style.opacity="1"),m&&(o.style.stroke=m),I!==null&&(o.style.strokeWidth=`${I}`),G!==null&&(o.style.fillOpacity=`${G}`),L&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",L)):(o.style.strokeDasharray=`${l}`,o.style.strokeDashoffset=v==="reverse"?"0":`${l}`,c?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`))}),ue){if(i)return e.style.clipPath=B(1),U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=B(0)}else if(i)return U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function At(){return!(ne===!1||!Ft()||!O.length||typeof p!="string"||!(p in pt)||ue||x!=="y"||z||f!==1||H!==0||_||y||te!==!1||L||C||ie||E>0||d||q||U||xe||Oe||Le||Ae||b!=null||F!=null||A!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function Tt(){let o=`svg-scroll-draw-${++Ot}`,l=v==="reverse"?"0":"var(--ssd-len)",w=v==="reverse"?"var(--ssd-len)":"0",R=`stroke-dashoffset:${l};`,J=`stroke-dashoffset:${w};`;c&&(R+=`opacity:${v==="reverse"?1:0};`,J+=`opacity:${v==="reverse"?0:1};`);let K=document.createElement("style");K.setAttribute("data-svg-scroll-draw",""),K.textContent=`@keyframes ${o}{from{${R}}to{${J}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${pt[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(K);function se(u,S){u.style.setProperty("--ssd-len",String(M[S])),u.style.strokeDasharray=`${M[S]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(o)}O.forEach(se);let h=!1,k=-1;function P(){if(k>=0)return k;let u=e.getBoundingClientRect(),{tStart:S,tEnd:D}=Se({top:u.top,height:u.height},De(),it(),Ie,Me);return ae(ee(De(),S,D,f))}return{destroy(){O.forEach(u=>{u.classList.remove(o),u.style.removeProperty("--ssd-len"),u.style.animationPlayState=""}),K.remove()},replay(){h=!1,k=-1,O.forEach(se)},pause(){h=!0,O.forEach(u=>{u.style.animationPlayState="paused"})},resume(){h&&(h=!1,O.forEach(u=>{u.style.animationPlayState="running"}))},seek(u){let S=Math.min(1,Math.max(0,u));k=S,h=!0,O.forEach((D,$e)=>{D.classList.remove(o),D.style.strokeDashoffset=v==="reverse"?`${M[$e]*S}`:`${M[$e]*(1-S)}`,c&&(D.style.opacity=v==="reverse"?`${1-S}`:`${S}`)})},getProgress(){return P()}}}if(At())return Tt();function $t(){let o=Math.max(1,re),l=0,w=0;function R(P){let u=!0;if(ue){let S=Math.min(1,Math.max(0,P/o)),D=ae(S);Te=D,e.style.setProperty("--scroll-draw-progress",String(D)),e.style.clipPath=B(v==="reverse"?1-D:D),d?.(D),S<1&&(u=!1)}else O.forEach((S,D)=>{let $e=D*H*o,Pe=Math.min(1,Math.max(0,(P-$e)/o)),fe=ae(Pe);S.style.strokeDashoffset=v==="reverse"?`${M[D]*fe}`:`${M[D]*(1-fe)}`,c&&(S.style.opacity=v==="reverse"?`${1-fe}`:`${fe}`),s&&m?S.style.stroke=Ce(s,m,fe):m&&(S.style.stroke=m),N!==null&&I!==null?S.style.strokeWidth=`${N+(I-N)*fe}`:I!==null&&(S.style.strokeWidth=`${I}`),V!==null&&G!==null?S.style.fillOpacity=`${V+(G-V)*fe}`:G!==null&&(S.style.fillOpacity=`${G}`),L&&S.tagName.toLowerCase()==="path"&&oe[D]&&S.setAttribute("d",tt(oe[D],L,fe)),D===0&&(d?.(fe),e.style.setProperty("--scroll-draw-progress",String(fe))),Pe<1&&(u=!1)});if(C){let S=Math.min(1,Math.max(0,P/o)),D=ae(S);for(let $e in C){let Pe=parseFloat($e);D>=Pe&&!Ee.has(Pe)&&(Ee.add(Pe),C[$e]?.())}}return u}function J(P){if(Z)return;let u=P-l;ce||(ce=!0,q?.());let S=R(u);if(S&&!X){X=!0,R(o*(1+Math.max(0,O.length-1)*H)),U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{l=performance.now(),ce=!1,X=!1,Ee.clear(),He(),W=requestAnimationFrame(J)},Y));return}S||(W=requestAnimationFrame(J))}function K(){cancelAnimationFrame(W),clearTimeout(ve),l=performance.now(),w=0,Z=!1,ce=!1,X=!1,ye=0,Ee.clear(),He(),W=requestAnimationFrame(J)}let se=new IntersectionObserver(P=>{P.forEach(u=>{u.isIntersecting&&!(_&&X)?K():!u.isIntersecting&&!_&&!X&&(cancelAnimationFrame(W),clearTimeout(ve),l=null)})},{root:z??null,threshold:de,rootMargin:be}),h;function k(){clearTimeout(h),h=setTimeout(()=>{O.forEach((P,u)=>{M[u]=Ve(P),P.style.strokeDasharray=`${M[u]}`})},150)}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),E>0?setTimeout(()=>se.observe(e),E):se.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),se.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(h)},replay(){ye=0,K()},pause(){Z||(Z=!0,w=performance.now()-l,cancelAnimationFrame(W))},resume(){Z&&(Z=!1,l=performance.now()-w,W=requestAnimationFrame(J))},seek(P){let u=Math.min(1,Math.max(0,P));Te=u,Z=!0,w=u*o,l=performance.now()-w,cancelAnimationFrame(W),R(w)},getProgress(){return Te}}}if(ge)return $t();at();function qe(){if(!Fe||Z)return;let o=performance.now(),l=De(),w=f;if(te!==!1){let h=o-st,k=h>0?Math.abs(l-(Re<0?l:Re))/h:0;w=f*Math.max(.2,1+k*(typeof te=="number"?te:1)*.04)}Re=l,st=o;let R=y?Ne===-1||l>=Ne?"forward":"reverse":v;Ne=l;let J=we-le,K=!0,se=J===0?0:(l-le)/J;if(isNaN(ke)||(ke<=0&&se>0?xe?.():ke>0&&se<=0&&Ae?.(),ke<1&&se>=1?Oe?.():ke>=1&&se<1&&Le?.()),ke=se,ue){let h=ae(ee(l,le,we,w));_&&!y&&(me=Math.max(me,h),h=me),Te=h,e.style.setProperty("--scroll-draw-progress",String(h));let k=R==="reverse"?1-h:h;e.style.clipPath=B(k),d?.(h),!ce&&ee(l,le,we,w)>0&&(ce=!0,q?.()),h>=1&&!X?(X=!0,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=!1,X=!1,e.style.clipPath=B(0)},Y))):h<1&&!_&&(X=!1),W=requestAnimationFrame(qe);return}if(O.forEach((h,k)=>{let P=k*H*J,u=ae(ee(l,le+P,we+P,w));_&&!y&&(me=Math.max(me,u),u=me),Te=u,h.style.strokeDashoffset=R==="reverse"?`${M[k]*u}`:`${M[k]*(1-u)}`,c&&(h.style.opacity=R==="reverse"?`${1-u}`:`${u}`),s&&m?h.style.stroke=Ce(s,m,u):m&&(h.style.stroke=m),N!==null&&I!==null?h.style.strokeWidth=`${N+(I-N)*u}`:I!==null&&(h.style.strokeWidth=`${I}`),V!==null&&G!==null?h.style.fillOpacity=`${V+(G-V)*u}`:G!==null&&(h.style.fillOpacity=`${G}`),L&&h.tagName.toLowerCase()==="path"&&oe[k]&&h.setAttribute("d",tt(oe[k],L,u)),k===0&&(d?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(K=!1)}),C){let h=ae(ee(l,le,we,w));for(let k in C){let P=parseFloat(k);h>=P&&!Ee.has(P)&&(Ee.add(P),C[k]?.())}}!ce&&ee(l,le,we,w)>0&&(ce=!0,q?.()),K&&!X?(X=!0,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=!1,X=!1,Ee.clear(),He()},Y))):!K&&!_&&(X=!1),W=requestAnimationFrame(qe)}let Ze=new IntersectionObserver(o=>{o.forEach(l=>{Fe=l.isIntersecting,Fe&&!Z?W=requestAnimationFrame(qe):cancelAnimationFrame(W)})},{root:z??null,threshold:de,rootMargin:be}),Je;function ze(){clearTimeout(Je),Je=setTimeout(()=>{O.forEach((o,l)=>{M[l]=Ve(o),o.style.strokeDasharray=`${M[l]}`}),at()},150)}return window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze),E>0?setTimeout(()=>Ze.observe(e),E):Ze.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),Ze.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Je),Ue?.remove()},replay(){me=-1,Ne=-1,Re=-1,ce=!1,X=!1,ye=0,Z=!1,Ee.clear(),clearTimeout(ve),He()},pause(){Z=!0,cancelAnimationFrame(W)},resume(){Z&&(Z=!1,Fe&&(W=requestAnimationFrame(qe)))},seek(o){let l=Math.min(1,Math.max(0,o));Te=l,me=l,Z=!0,cancelAnimationFrame(W),xt(l,v)},getProgress(){return Te}}}var dt=new Map;function _e(e,r){dt.set(e,r)}function Ge(e){dt.delete(e)}function Ht(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function gt(e){let r=[],t=/([\w]+)\(([^)]*)\)/g,n;for(;(n=t.exec(e))!==null;){let a=[],i=[],g=n[2].trim();if(g)for(let f of g.split(/[\s,]+/)){let c=f.match(/^([-+]?[\d.eE]+)(.*)$/);a.push(c?parseFloat(c[1]):0),i.push(c?c[2]:"")}r.push({fn:n[1],nums:a,units:i})}return r}function qt(e,r,t){let n=gt(e),a=gt(r);return n.length===0||n.length!==a.length?t<1?e:r:n.map((i,g)=>{let f=a[g];return i.fn!==f.fn||i.nums.length!==f.nums.length?t<1?`${i.fn}(${i.nums.map((c,p)=>`${c}${i.units[p]}`).join(", ")})`:`${f.fn}(${f.nums.map((c,p)=>`${c}${f.units[p]}`).join(", ")})`:`${i.fn}(${i.nums.map((c,p)=>`${c+(f.nums[p]-c)*t}${i.units[p]}`).join(", ")})`}).join(" ")}function yt(e,r,t){if(typeof e=="number"&&typeof r=="number")return String(e+(r-e)*t);let n=String(e),a=String(r);if(Ht(n))return Ce(n,a,t);if(n.includes("("))return qt(n,a,t);let i=n.match(/^([-+]?[\d.]+)(.*)$/),g=a.match(/^([-+]?[\d.]+)(.*)$/);if(i&&g){let f=parseFloat(i[1]),c=parseFloat(g[1]);return`${f+(c-f)*t}${i[2]||g[2]}`}return t<1?n:a}function zt(e){return e.replace(/([A-Z])/g,r=>`-${r.toLowerCase()}`)}var ht={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Vt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Bt=0;function Wt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function bt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let{props:n,trigger:a={},easing:i="ease-out",speed:g=1,once:f=!1,axis:c="y",scrollContainer:p,native:T=!0,onProgress:H,onComplete:v,onEnter:_,onLeave:pe,onEnterBack:x,onLeaveBack:$}=r,y=window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=typeof i=="function"?i:Q[i]??Q["ease-out"],b=he(a.start??"top bottom"),F=he(a.end??"bottom top"),A=typeof p=="string"?document.querySelector(p):p??null,C=Object.entries(n).map(([s,m])=>({prop:zt(s),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function te(){let s=window.getComputedStyle(e);for(let m of C)m.from===""&&(m.from=s.getPropertyValue(m.prop).trim()||"0")}function de(){for(let s of C)e.style.setProperty(s.prop,String(s.to))}if(y)return de(),v?.(),t;te();function be(){if(!T||!Wt()||typeof i!="string"||!(i in ht)||c!=="y"||A||f||g!==1||H||v||_||pe||x||$||(a.start??"top bottom").trim()!=="top bottom"||(a.end??"bottom top").trim()!=="bottom top")return!1;for(let s of C)if(!Vt.has(s.prop))return!1;return!0}function ie(){let s=`ssd-a-${++Bt}`,m=C.map(B=>`${B.prop}:${B.from}`).join(";"),N=C.map(B=>`${B.prop}:${B.to}`).join(";"),I=document.createElement("style");I.setAttribute("data-ssd-animate",""),I.textContent=`@keyframes ${s}{from{${m}}to{${N}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${ht[i]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(I),e.classList.add(s);let V=()=>c==="x"?window.scrollX:window.scrollY,G=()=>c==="x"?window.innerWidth:window.innerHeight;return{destroy(){e.classList.remove(s),I.remove()},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(B){let O=Math.min(1,Math.max(0,B));e.classList.remove(s);for(let M of C)e.style.setProperty(M.prop,yt(M.from,M.to,O))},getProgress(){let B=e.getBoundingClientRect(),O=V(),M=G(),{tStart:oe,tEnd:le}=Se({top:B.top,height:B.height},O,M,b,F);return E(ee(O,oe,le,g))}}}if(be())return ie();let Y=0,L=0,j=0,ge=!1,re=!1,ne=-1,d=0,q=!1,U=NaN,xe=()=>A?c==="x"?A.scrollLeft:A.scrollTop:c==="x"?window.scrollX:window.scrollY,Oe=()=>A?c==="x"?A.clientWidth:A.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function Le(){let s=e.getBoundingClientRect(),m,N;if(A){let V=A.getBoundingClientRect();m=c==="x"?s.left-V.left+A.scrollLeft:s.top-V.top+A.scrollTop,N=c==="x"?s.width:s.height}else m=c==="x"?s.left:s.top,N=c==="x"?s.width:s.height;let I=Se({top:m,height:N},xe(),Oe(),b,F);Y=I.tStart,L=I.tEnd}function Ae(s){e.style.setProperty("--scroll-draw-progress",String(s));for(let m of C)e.style.setProperty(m.prop,yt(m.from,m.to,s));H?.(s)}function ue(s){if(isNaN(U)){U=s;return}U<=0&&s>0?_?.():U>0&&s<=0&&$?.(),U<1&&s>=1?pe?.():U>=1&&s<1&&x?.(),U=s}function ae(){if(!ge||re)return;let s=L===Y?0:(xe()-Y)/(L-Y);ue(s);let m=E(ee(xe(),Y,L,g));f&&(ne=Math.max(ne,m),m=ne),d=m,Ae(m),m>=1&&!q?(q=!0,v?.()):m<1&&!f&&(q=!1),j=requestAnimationFrame(ae)}Le();{let s=E(ee(xe(),Y,L,g));f&&s>0&&(ne=s),d=s,Ae(s)}let Ie=new IntersectionObserver(s=>{s.forEach(m=>{ge=m.isIntersecting,ge&&!re?j=requestAnimationFrame(ae):cancelAnimationFrame(j)})},{root:A??null}),Me;function z(){clearTimeout(Me),Me=setTimeout(Le,150)}return window.addEventListener("resize",z),window.addEventListener("orientationchange",z),Ie.observe(e),_e(e,{type:"animate",getProgress:()=>d,getTrigger:()=>({tStart:Y,tEnd:L})}),{destroy(){cancelAnimationFrame(j),Ie.disconnect(),window.removeEventListener("resize",z),window.removeEventListener("orientationchange",z),clearTimeout(Me),Ge(e)},replay(){ne=-1,q=!1,d=0,re=!1,Ae(0)},pause(){re=!0,cancelAnimationFrame(j)},resume(){re&&(re=!1,ge&&(j=requestAnimationFrame(ae)))},seek(s){let m=Math.min(1,Math.max(0,s));d=m,ne=m,re=!0,cancelAnimationFrame(j),Ae(m)},getProgress(){return d}}}var je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function wt(e,r){if(typeof window>"u")return je;let t=typeof e=="string"?document.querySelector(e):e;return t?bt(t,r):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),je)}function vt(e,r={}){if(typeof window>"u")return je;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),je;let{speed:n=.3,axis:a="y",easing:i="linear",trigger:g,onProgress:f}=r,c=t.getBoundingClientRect(),p=a==="x"?c.width:c.height,T=n*p;return bt(t,{props:a==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:g??{start:"top bottom",end:"bottom top"},easing:i,native:!1,onProgress:f})}var rt={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Et(e,r){if(typeof window>"u")return rt;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),rt;let n=t,{from:a=0,to:i,format:g,easing:f="ease-out",trigger:c={},once:p=!0,decimals:T,onComplete:H}=r,v=T!==void 0?d=>d.toFixed(T):g??(d=>String(Math.round(d))),_=typeof f=="function"?f:Q[f]??Q["ease-out"],pe=he(c.start??"top 80%"),x=he(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=v(i),H?.(),rt;n.textContent=v(a);let y=0,E=0,b=0,F=!1,A=!1,C=-1,te=0,de=!1,be=()=>window.scrollY,ie=()=>window.innerHeight;function Y(){let d=n.getBoundingClientRect(),q=Se({top:d.top,height:d.height},be(),ie(),pe,x);y=q.tStart,E=q.tEnd}function L(d){n.textContent=v(a+(i-a)*d),n.style.setProperty("--scroll-draw-progress",String(d))}function j(){if(!F||A)return;let d=_(ee(be(),y,E,1));p&&(C=Math.max(C,d),d=C),te=d,L(d),d>=1&&!de?(de=!0,H?.()):d<1&&!p&&(de=!1),b=requestAnimationFrame(j)}Y();{let d=_(ee(be(),y,E,1));p&&d>0&&(C=d),te=d,L(d)}let ge=new IntersectionObserver(d=>{d.forEach(q=>{F=q.isIntersecting,F&&!A?b=requestAnimationFrame(j):cancelAnimationFrame(b)})}),re;function ne(){clearTimeout(re),re=setTimeout(Y,150)}return window.addEventListener("resize",ne),window.addEventListener("orientationchange",ne),ge.observe(n),_e(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:y,tEnd:E})}),{destroy(){cancelAnimationFrame(b),ge.disconnect(),window.removeEventListener("resize",ne),window.removeEventListener("orientationchange",ne),clearTimeout(re),Ge(n)},replay(){C=-1,de=!1,te=0,A=!1,L(0)},pause(){A=!0,cancelAnimationFrame(b)},resume(){A&&(A=!1,F&&(b=requestAnimationFrame(j)))},seek(d){let q=Math.min(1,Math.max(0,d));te=q,C=q,A=!0,cancelAnimationFrame(b),L(q)},getProgress(){return te}}}var St="http://www.w3.org/2000/svg",_t="cinematic-photo",nt=e=>e<0?0:e>1?1:e;function Xe(e){let r=parseFloat(e);return Number.isFinite(r)?nt(r/100):0}function Gt(e){return Q[e]??Q.linear}var jt={destroy:()=>{},getProgress:()=>0},Ye=class{constructor(r){if(typeof document>"u"){this.mount=null;return}this.mount=typeof r.wrapper=="string"?document.querySelector(r.wrapper):r.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",r.wrapper)}loadStory(r){let t=this.mount;if(typeof window>"u"||!t)return jt;t.style.position="relative",t.style.height=r.totalHeight,t.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",t.appendChild(n);let a=[];for(let x of r.scenes){if(x.background){let y=document.createElement("img");y.id=_t,y.src=x.background,y.alt="",y.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(y)}let $=x.animations.filter(y=>y.type==="draw");if($.length){let y=document.createElementNS(St,"svg");y.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),y.setAttribute("preserveAspectRatio","xMidYMid meet"),y.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(y);for(let E of $){let b=document.createElementNS(St,"path");b.id=E.target.replace(/^#/,""),b.setAttribute("d",E.d),b.setAttribute("fill","none"),b.setAttribute("stroke",E.stroke),b.setAttribute("stroke-width",String(E.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let F=E.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(F),b.style.strokeDashoffset=String(F),y.appendChild(b),a.push({kind:"draw",el:b,start:Xe(E.start),end:Xe(E.end),ease:Gt(E.easing),length:F})}}for(let y of x.animations){if(y.type!=="fade")continue;let E=n.querySelector(y.target)??document.querySelector(y.target);E&&(E.style.opacity=String(y.from),a.push({kind:"fade",el:E,start:Xe(y.start),end:Xe(y.end),ease:Q["ease-in-out"]??Q.linear,from:y.from,to:y.to}))}}let i=0,g=()=>{let x=t.offsetHeight-window.innerHeight;return x<=0?t.getBoundingClientRect().top<=0?1:0:nt(-t.getBoundingClientRect().top/x)},f=x=>{for(let $ of a){let y=$.end-$.start,E=y<=0?x>=$.end?1:0:nt((x-$.start)/y),b=$.ease(E);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-b)):$.el.style.opacity=String($.from+($.to-$.from)*b)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(1),{destroy:()=>{},getProgress:()=>1};let c=0,p=!1,T=!1,H=()=>{i=g(),f(i),p&&(c=requestAnimationFrame(H))},v=()=>{p||(p=!0,c=requestAnimationFrame(H))},_=()=>{p=!1,cancelAnimationFrame(c)},pe=new IntersectionObserver(x=>{for(let $ of x)T=$.isIntersecting,T?v():_()},{threshold:0});return pe.observe(n),i=g(),f(i),{destroy(){_(),pe.disconnect()},getProgress:()=>i}}};function Xt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let n=typeof e=="string"?document.querySelector(e):e;return n?We(n,r):(console.warn("[svg-scroll-draw] Container not found:",e),t)}var ot=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let t={},n=this.getAttribute("speed"),a=this.getAttribute("easing"),i=this.getAttribute("stagger"),g=this.getAttribute("direction"),f=this.getAttribute("selector");n&&(t.speed=parseFloat(n)),a&&(t.easing=a),i&&(t.stagger=parseFloat(i)),g&&(t.direction=g),f&&(t.selector=f),this.hasAttribute("fade")&&(t.fade=this.getAttribute("fade")!=="false"),this.instance=We(this,t)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",ot);return It(Yt);})();
|
|
1
|
+
"use strict";var SvgScrollDraw=(()=>{var at=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var Bt=(e,t)=>{for(var r in t)at(e,r,{get:t[r],enumerable:!0})},Gt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qt(t))!Wt.call(e,i)&&i!==r&&at(e,i,{get:()=>t[i],enumerable:!(n=zt(t,i))||n.enumerable});return e};var jt=e=>Gt(at({},"__esModule",{value:!0}),e);var pr={};Bt(pr,{Cinematic:()=>rt,PRESETS:()=>Ye,createBounce:()=>lt,createElastic:()=>ct,createSpring:()=>xt,scrollAnimate:()=>It,scrollCounter:()=>Ft,scrollDraw:()=>fr,scrollParallax:()=>Ot});function xt({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function lt({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),l=0,f=[];for(let p=0;p<r;p++){let E=Math.pow(i,p);f.push(E),l+=E}let u=[0],c=0;for(let p=0;p<r;p++)c+=f[p]/l,u.push(c);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let E=0;E<r;E++)if(p<=u[E+1]){let D=(p-u[E])/(u[E+1]-u[E]);if(E===0)return D*(2-D);let A=1-Math.pow(n,E);return A+(1-A)*(2*D-1)*(2*D-1)}return 1}}function ct({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 l=>l<=0?0:l>=1?1:r*Math.pow(2,-10*l)*Math.sin((l-i)*(2*Math.PI)/n)+1}var J={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:lt(),elastic:ct()};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 vt(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 St(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 He(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 Ut(e,t,r){return Math.min(r,Math.max(t,e))}function ie(e,t,r,n){return r===t?0:Ut((e-t)/(r-t)*n,0,1)}function Xe(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 Oe(e,t,r,n,i){let l=vt(e.top,e.height,t,n.element)-St(n.viewport,r),f=vt(e.top,e.height,t,i.element)-St(i.viewport,r);return{tStart:l,tEnd:f}}function Et(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 _e(e,t,r){let n=Et(e),i=Et(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 Ye={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 Xt="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",Yt="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",At=33;function Qt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Zt(e){let t=[];for(let r=0;r<At;r++){let n=r/(At-1);t.push(String(Math.round(e(n)*1e5)/1e5))}return`linear(${t.join(",")})`}function Qe(e){switch(e){case"linear":return"linear";case"ease-in":return Xt;case"ease-out":return Yt;case"ease-in-out":return Qt()?Zt(J["ease-in-out"]):null;default:return null}}var Jt=0;function Kt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function er(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 tr(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 l=r==="x"?window.scrollX:window.scrollY,f=e-l,u=t-l,c=r==="x";n.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`left:${f}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${f}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
|
|
3
|
+
<div style="position:absolute;${c?`left:${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);})();
|
package/dist/cinematic/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';function
|
|
2
|
-
exports.Cinematic=
|
|
1
|
+
'use strict';function _({bounces:e=3,decay:n=.5}={}){let s=Math.max(1,Math.round(e)),a=Math.max(.01,Math.min(.99,n)),d=Math.sqrt(a),m=0,g=[];for(let r=0;r<s;r++){let u=Math.pow(d,r);g.push(u),m+=u;}let l=[0],b=0;for(let r=0;r<s;r++)b+=g[r]/m,l.push(b);return r=>{if(r<=0)return 0;if(r>=1)return 1;for(let u=0;u<s;u++)if(r<=l[u+1]){let f=(r-l[u])/(l[u+1]-l[u]);if(u===0)return f*(2-f);let w=1-Math.pow(a,u);return w+(1-w)*(2*f-1)*(2*f-1)}return 1}}function k({amplitude:e=1,period:n=.4}={}){let s=Math.max(1,e),a=Math.max(.1,n),d=s<=1?a/4:a/(2*Math.PI)*Math.asin(1/s);return m=>m<=0?0:m>=1?1:s*Math.pow(2,-10*m)*Math.sin((m-d)*(2*Math.PI)/a)+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:_(),elastic:k()};var C=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function A(e,...n){C&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var E="http://www.w3.org/2000/svg",L="cinematic-photo",x=e=>e<0?0:e>1?1:e;function y(e){let n=parseFloat(e);return Number.isFinite(n)?x(n/100):0}function T(e){return h[e]??h.linear}var R={destroy:()=>{},getProgress:()=>0},I=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||A("Cinematic: wrapper not found:",n.wrapper);}loadStory(n){let s=this.mount;if(typeof window>"u"||!s)return R;s.style.position="relative",s.style.height=n.totalHeight,s.style.display="block";let a=document.createElement("div");a.setAttribute("data-cinematic-stage",""),a.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",s.appendChild(a);let d=[];for(let p of n.scenes){if(p.background){let t=document.createElement("img");t.id=L,t.src=p.background,t.alt="",t.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",a.appendChild(t);}let o=p.animations.filter(t=>t.type==="draw");if(o.length){let t=document.createElementNS(E,"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;",a.appendChild(t);for(let c of o){let i=document.createElementNS(E,"path");i.id=c.target.replace(/^#/,""),i.setAttribute("d",c.d),i.setAttribute("fill","none"),i.setAttribute("stroke",c.stroke),i.setAttribute("stroke-width",String(c.strokeWidth)),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round");let S=c.length||i.getTotalLength?.()||0;i.style.strokeDasharray=String(S),i.style.strokeDashoffset=String(S),t.appendChild(i),d.push({kind:"draw",el:i,start:y(c.start),end:y(c.end),ease:T(c.easing),length:S});}}for(let t of p.animations){if(t.type!=="fade")continue;let c=a.querySelector(t.target)??document.querySelector(t.target);c&&(c.style.opacity=String(t.from),d.push({kind:"fade",el:c,start:y(t.start),end:y(t.end),ease:h["ease-in-out"]??h.linear,from:t.from,to:t.to}));}}let m=0,g=()=>{let p=s.offsetHeight-window.innerHeight;return p<=0?s.getBoundingClientRect().top<=0?1:0:x(-s.getBoundingClientRect().top/p)},l=p=>{for(let o of d){let t=o.end-o.start,c=t<=0?p>=o.end?1:0:x((p-o.start)/t),i=o.ease(c);o.kind==="draw"?o.el.style.strokeDashoffset=String(o.length*(1-i)):o.el.style.opacity=String(o.from+(o.to-o.from)*i);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return l(1),{destroy:()=>{},getProgress:()=>1};let b=0,r=false,u=false,f=()=>{m=g(),l(m),r&&(b=requestAnimationFrame(f));},w=()=>{r||(r=true,b=requestAnimationFrame(f));},M=()=>{r=false,cancelAnimationFrame(b);},v=new IntersectionObserver(p=>{for(let o of p)u=o.isIntersecting,u?w():M();},{threshold:0});return v.observe(a),m=g(),l(m),{destroy(){M(),v.disconnect();},getProgress:()=>m}}};
|
|
2
|
+
exports.Cinematic=I;
|
package/dist/cinematic/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
export{
|
|
1
|
+
function _({bounces:e=3,decay:n=.5}={}){let s=Math.max(1,Math.round(e)),a=Math.max(.01,Math.min(.99,n)),d=Math.sqrt(a),m=0,g=[];for(let r=0;r<s;r++){let u=Math.pow(d,r);g.push(u),m+=u;}let l=[0],b=0;for(let r=0;r<s;r++)b+=g[r]/m,l.push(b);return r=>{if(r<=0)return 0;if(r>=1)return 1;for(let u=0;u<s;u++)if(r<=l[u+1]){let f=(r-l[u])/(l[u+1]-l[u]);if(u===0)return f*(2-f);let w=1-Math.pow(a,u);return w+(1-w)*(2*f-1)*(2*f-1)}return 1}}function k({amplitude:e=1,period:n=.4}={}){let s=Math.max(1,e),a=Math.max(.1,n),d=s<=1?a/4:a/(2*Math.PI)*Math.asin(1/s);return m=>m<=0?0:m>=1?1:s*Math.pow(2,-10*m)*Math.sin((m-d)*(2*Math.PI)/a)+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:_(),elastic:k()};var C=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function A(e,...n){C&&console.warn(`[svg-scroll-draw] ${e}`,...n);}var E="http://www.w3.org/2000/svg",L="cinematic-photo",x=e=>e<0?0:e>1?1:e;function y(e){let n=parseFloat(e);return Number.isFinite(n)?x(n/100):0}function T(e){return h[e]??h.linear}var R={destroy:()=>{},getProgress:()=>0},I=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||A("Cinematic: wrapper not found:",n.wrapper);}loadStory(n){let s=this.mount;if(typeof window>"u"||!s)return R;s.style.position="relative",s.style.height=n.totalHeight,s.style.display="block";let a=document.createElement("div");a.setAttribute("data-cinematic-stage",""),a.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",s.appendChild(a);let d=[];for(let p of n.scenes){if(p.background){let t=document.createElement("img");t.id=L,t.src=p.background,t.alt="",t.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",a.appendChild(t);}let o=p.animations.filter(t=>t.type==="draw");if(o.length){let t=document.createElementNS(E,"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;",a.appendChild(t);for(let c of o){let i=document.createElementNS(E,"path");i.id=c.target.replace(/^#/,""),i.setAttribute("d",c.d),i.setAttribute("fill","none"),i.setAttribute("stroke",c.stroke),i.setAttribute("stroke-width",String(c.strokeWidth)),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round");let S=c.length||i.getTotalLength?.()||0;i.style.strokeDasharray=String(S),i.style.strokeDashoffset=String(S),t.appendChild(i),d.push({kind:"draw",el:i,start:y(c.start),end:y(c.end),ease:T(c.easing),length:S});}}for(let t of p.animations){if(t.type!=="fade")continue;let c=a.querySelector(t.target)??document.querySelector(t.target);c&&(c.style.opacity=String(t.from),d.push({kind:"fade",el:c,start:y(t.start),end:y(t.end),ease:h["ease-in-out"]??h.linear,from:t.from,to:t.to}));}}let m=0,g=()=>{let p=s.offsetHeight-window.innerHeight;return p<=0?s.getBoundingClientRect().top<=0?1:0:x(-s.getBoundingClientRect().top/p)},l=p=>{for(let o of d){let t=o.end-o.start,c=t<=0?p>=o.end?1:0:x((p-o.start)/t),i=o.ease(c);o.kind==="draw"?o.el.style.strokeDashoffset=String(o.length*(1-i)):o.el.style.opacity=String(o.from+(o.to-o.from)*i);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return l(1),{destroy:()=>{},getProgress:()=>1};let b=0,r=false,u=false,f=()=>{m=g(),l(m),r&&(b=requestAnimationFrame(f));},w=()=>{r||(r=true,b=requestAnimationFrame(f));},M=()=>{r=false,cancelAnimationFrame(b);},v=new IntersectionObserver(p=>{for(let o of p)u=o.isIntersecting,u?w():M();},{threshold:0});return v.observe(a),m=g(),l(m),{destroy(){M(),v.disconnect();},getProgress:()=>m}}};
|
|
2
|
+
export{I as Cinematic};
|
package/dist/cli/init.js
CHANGED
|
@@ -27,41 +27,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var readline = __toESM(require("readline"));
|
|
28
28
|
var fs = __toESM(require("fs"));
|
|
29
29
|
var path = __toESM(require("path"));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
);
|
|
30
|
+
|
|
31
|
+
// src/cli/generators.ts
|
|
32
|
+
var SAMPLE_SVG_JSX = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 100">
|
|
33
|
+
<path
|
|
34
|
+
d="M10 50 C 40 10, 80 10, 100 50 S 160 90, 190 50"
|
|
35
|
+
stroke="currentColor"
|
|
36
|
+
strokeWidth="2.5"
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
fill="none"
|
|
39
|
+
/>
|
|
40
|
+
</svg>`;
|
|
41
|
+
var SAMPLE_SVG_HTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 100">
|
|
42
|
+
<path
|
|
43
|
+
d="M10 50 C 40 10, 80 10, 100 50 S 160 90, 190 50"
|
|
44
|
+
stroke="currentColor"
|
|
45
|
+
stroke-width="2.5"
|
|
46
|
+
stroke-linecap="round"
|
|
47
|
+
fill="none"
|
|
48
|
+
/>
|
|
49
|
+
</svg>`;
|
|
50
|
+
function optionsBody({ easing, preset }) {
|
|
51
|
+
return preset !== "none" ? `preset: '${preset}'` : `easing: '${easing}', fade: true, once: true`;
|
|
54
52
|
}
|
|
55
|
-
var
|
|
56
|
-
<path
|
|
57
|
-
d="M10 50 C 40 10, 80 10, 100 50 S 160 90, 190 50"
|
|
58
|
-
stroke="currentColor"
|
|
59
|
-
strokeWidth="2.5"
|
|
60
|
-
strokeLinecap="round"
|
|
61
|
-
fill="none"
|
|
62
|
-
/>
|
|
63
|
-
</svg>`;
|
|
64
|
-
function genReact(selector, easing, preset) {
|
|
53
|
+
var genReact = ({ easing, preset }) => {
|
|
65
54
|
const presetProp = preset !== "none" ? `
|
|
66
55
|
preset="${preset}"` : "";
|
|
67
56
|
const easingProp = preset !== "none" ? "" : `
|
|
@@ -75,68 +64,59 @@ export function AnimatedSVG() {
|
|
|
75
64
|
fade
|
|
76
65
|
once
|
|
77
66
|
>
|
|
78
|
-
${
|
|
67
|
+
${SAMPLE_SVG_JSX}
|
|
79
68
|
</ScrollDraw>
|
|
80
69
|
);
|
|
81
70
|
}
|
|
82
71
|
`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const opts = preset !== "none" ? `preset: '${preset}'` : `easing: '${easing}', fade: true, once: true`;
|
|
86
|
-
return `<script setup>
|
|
72
|
+
};
|
|
73
|
+
var genVue = (opts) => `<script setup>
|
|
87
74
|
import { useScrollDraw } from 'svg-scroll-draw/vue';
|
|
88
75
|
|
|
89
76
|
const { ref } = useScrollDraw({
|
|
90
|
-
${opts},
|
|
77
|
+
${optionsBody(opts)},
|
|
91
78
|
});
|
|
92
79
|
</script>
|
|
93
80
|
|
|
94
81
|
<template>
|
|
95
82
|
<div :ref="ref">
|
|
96
|
-
${
|
|
83
|
+
${SAMPLE_SVG_HTML}
|
|
97
84
|
</div>
|
|
98
85
|
</template>
|
|
99
86
|
`;
|
|
100
|
-
|
|
101
|
-
function genSvelte(selector, easing, preset) {
|
|
102
|
-
const opts = preset !== "none" ? `{ preset: '${preset}' }` : `{ easing: '${easing}', fade: true, once: true }`;
|
|
103
|
-
return `<script>
|
|
87
|
+
var genSvelte = (opts) => `<script>
|
|
104
88
|
import { scrollDraw } from 'svg-scroll-draw/svelte';
|
|
105
89
|
</script>
|
|
106
90
|
|
|
107
|
-
<div use:scrollDraw={${opts}}>
|
|
108
|
-
${
|
|
91
|
+
<div use:scrollDraw={{ ${optionsBody(opts)} }}>
|
|
92
|
+
${SAMPLE_SVG_HTML}
|
|
109
93
|
</div>
|
|
110
94
|
`;
|
|
111
|
-
}
|
|
112
|
-
function genSolid(selector, easing, preset) {
|
|
113
|
-
const opts = preset !== "none" ? `preset: '${preset}'` : `easing: '${easing}', fade: true, once: true`;
|
|
114
|
-
return `import { createScrollDraw } from 'svg-scroll-draw/solid';
|
|
95
|
+
var genSolid = (opts) => `import { createScrollDraw } from 'svg-scroll-draw/solid';
|
|
115
96
|
|
|
116
97
|
export function AnimatedSVG() {
|
|
117
98
|
const { ref } = createScrollDraw({
|
|
118
|
-
${opts},
|
|
99
|
+
${optionsBody(opts)},
|
|
119
100
|
});
|
|
120
101
|
|
|
121
102
|
return (
|
|
122
103
|
<div ref={ref}>
|
|
123
|
-
${
|
|
104
|
+
${SAMPLE_SVG_JSX}
|
|
124
105
|
</div>
|
|
125
106
|
);
|
|
126
107
|
}
|
|
127
108
|
`;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const opts = preset !== "none" ? `preset: '${preset}'` : `easing: '${easing}',
|
|
109
|
+
var genVanilla = (opts) => {
|
|
110
|
+
const body = opts.preset !== "none" ? `preset: '${opts.preset}'` : `easing: '${opts.easing}',
|
|
131
111
|
fade: true,
|
|
132
112
|
once: true`;
|
|
133
113
|
return `import { scrollDraw } from 'svg-scroll-draw';
|
|
134
114
|
|
|
135
|
-
scrollDraw('${selector}', {
|
|
136
|
-
${
|
|
115
|
+
scrollDraw('${opts.selector}', {
|
|
116
|
+
${body},
|
|
137
117
|
});
|
|
138
118
|
`;
|
|
139
|
-
}
|
|
119
|
+
};
|
|
140
120
|
var GENERATORS = {
|
|
141
121
|
react: genReact,
|
|
142
122
|
vue: genVue,
|
|
@@ -151,59 +131,82 @@ var FILE_NAMES = {
|
|
|
151
131
|
solid: "ScrollDraw.tsx",
|
|
152
132
|
vanilla: "scroll-draw.js"
|
|
153
133
|
};
|
|
134
|
+
var FRAMEWORKS = Object.keys(GENERATORS);
|
|
135
|
+
var PRESETS = ["none", "sketch", "reveal", "typewriter", "cinematic", "spring"];
|
|
136
|
+
var EASINGS = ["ease-out", "ease-in", "ease-in-out", "linear", "spring", "bounce"];
|
|
137
|
+
function needsSelector(framework) {
|
|
138
|
+
return framework === "vanilla";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/cli/init.ts
|
|
142
|
+
var RESET = "\x1B[0m";
|
|
143
|
+
var BOLD = "\x1B[1m";
|
|
144
|
+
var DIM = "\x1B[2m";
|
|
145
|
+
var PINK = "\x1B[35m";
|
|
146
|
+
var GREEN = "\x1B[32m";
|
|
147
|
+
var CYAN = "\x1B[36m";
|
|
148
|
+
function ask(rl, question, fallback) {
|
|
149
|
+
return new Promise(
|
|
150
|
+
(resolve) => rl.question(` ${CYAN}?${RESET} ${question} ${DIM}(${fallback})${RESET} `, (ans) => {
|
|
151
|
+
resolve(ans.trim() || fallback);
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function pick(rl, question, options, fallback) {
|
|
156
|
+
const opts = options.map((o, i) => `${DIM}${i + 1})${RESET} ${o}`).join(" ");
|
|
157
|
+
return new Promise(
|
|
158
|
+
(resolve) => rl.question(` ${CYAN}?${RESET} ${question}
|
|
159
|
+
${opts}
|
|
160
|
+
${DIM}(${fallback})${RESET} `, (ans) => {
|
|
161
|
+
const idx = parseInt(ans) - 1;
|
|
162
|
+
resolve(idx >= 0 && idx < options.length ? options[idx] : fallback);
|
|
163
|
+
})
|
|
164
|
+
);
|
|
165
|
+
}
|
|
154
166
|
async function main() {
|
|
155
|
-
|
|
167
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
168
|
+
try {
|
|
169
|
+
console.log(`
|
|
156
170
|
${BOLD}${PINK}svg-scroll-draw${RESET} ${DIM}init${RESET}
|
|
157
171
|
`);
|
|
158
|
-
|
|
172
|
+
console.log(` ${DIM}Generates a starter file for your framework.${RESET}
|
|
159
173
|
`);
|
|
160
|
-
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"Easing?",
|
|
174
|
-
["ease-out", "ease-in", "ease-in-out", "linear", "spring", "bounce"],
|
|
175
|
-
"ease-out"
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
const selector = await ask("CSS selector for your SVG container?", "#my-svg");
|
|
179
|
-
const outFile = FILE_NAMES[framework] ?? "scroll-draw.js";
|
|
180
|
-
const outPath = path.join(process.cwd(), outFile);
|
|
181
|
-
if (fs.existsSync(outPath)) {
|
|
182
|
-
const overwrite = await ask(`${outFile} already exists. Overwrite?`, "y");
|
|
183
|
-
if (overwrite.toLowerCase() !== "y") {
|
|
184
|
-
console.log(`
|
|
174
|
+
const framework = await pick(rl, "Framework?", FRAMEWORKS, "react");
|
|
175
|
+
const preset = await pick(rl, "Preset?", PRESETS, "none");
|
|
176
|
+
let easing = "ease-out";
|
|
177
|
+
if (preset === "none") {
|
|
178
|
+
easing = await pick(rl, "Easing?", EASINGS, "ease-out");
|
|
179
|
+
}
|
|
180
|
+
const selector = needsSelector(framework) ? await ask(rl, "CSS selector for your SVG container?", "#my-svg") : "#my-svg";
|
|
181
|
+
const outFile = FILE_NAMES[framework] ?? "scroll-draw.js";
|
|
182
|
+
const outPath = path.join(process.cwd(), outFile);
|
|
183
|
+
if (fs.existsSync(outPath)) {
|
|
184
|
+
const overwrite = await ask(rl, `${outFile} already exists. Overwrite?`, "y");
|
|
185
|
+
if (overwrite.toLowerCase() !== "y") {
|
|
186
|
+
console.log(`
|
|
185
187
|
${DIM}Aborted.${RESET}
|
|
186
188
|
`);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
189
191
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
console.log(`
|
|
192
|
+
const code = GENERATORS[framework]?.({ selector, easing, preset }) ?? "";
|
|
193
|
+
fs.writeFileSync(outPath, code, "utf8");
|
|
194
|
+
console.log(`
|
|
194
195
|
${GREEN}\u2713${RESET} ${BOLD}${outFile}${RESET} created.
|
|
195
196
|
`);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
197
|
+
console.log(` ${DIM}Next steps:${RESET}`);
|
|
198
|
+
console.log(` npm i svg-scroll-draw`);
|
|
199
|
+
if (framework === "vanilla") {
|
|
200
|
+
console.log(` Add your SVG to the DOM and call scrollDraw('${selector}', ...)`);
|
|
201
|
+
} else {
|
|
202
|
+
console.log(` Import ${outFile.replace(/\.\w+$/, "")} and drop it into your page.`);
|
|
203
|
+
}
|
|
204
|
+
console.log(`
|
|
204
205
|
${DIM}Docs: https://svg-scroll-draw.vercel.app/docs${RESET}
|
|
205
206
|
`);
|
|
206
|
-
|
|
207
|
+
} finally {
|
|
208
|
+
rl.close();
|
|
209
|
+
}
|
|
207
210
|
}
|
|
208
211
|
main().catch((e) => {
|
|
209
212
|
console.error(e);
|
package/dist/devtools/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c",pin:"#f43f5e",snap:"#22d3ee"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function
|
|
1
|
+
'use strict';var C=new Map;function x(){return C}var E=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 L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function R(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function $(){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 M(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){R(),M(),b=requestAnimationFrame(h);}function w(){E&&(p||(p=true,L(),$(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),T());},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 T(){p?_():w();}function S(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var V={enable:w,disable:_,toggle:T,highlight:S};exports.devtools=V;
|
package/dist/devtools/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c",pin:"#f43f5e",snap:"#22d3ee"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function
|
|
1
|
+
var C=new Map;function x(){return C}var E=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 L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function R(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function $(){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 M(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){R(),M(),b=requestAnimationFrame(h);}function w(){E&&(p||(p=true,L(),$(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),T());},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 T(){p?_():w();}function S(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var V={enable:w,disable:_,toggle:T,highlight:S};export{V as devtools};
|