svg-scroll-draw 2.2.0 → 2.6.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/README.md +7 -7
- package/dist/angular/index.cjs +3 -3
- package/dist/angular/index.d.mts +178 -9
- package/dist/angular/index.d.ts +178 -9
- package/dist/angular/index.mjs +3 -3
- package/dist/astro/index.cjs +3 -3
- package/dist/astro/index.d.mts +70 -1
- package/dist/astro/index.d.ts +70 -1
- package/dist/astro/index.mjs +3 -3
- package/dist/devtools/index.d.mts +12 -0
- package/dist/devtools/index.d.ts +12 -0
- package/dist/group/index.cjs +3 -3
- package/dist/group/index.d.mts +72 -1
- package/dist/group/index.d.ts +72 -1
- package/dist/group/index.mjs +3 -3
- package/dist/nuxt/index.cjs +3 -3
- package/dist/nuxt/index.d.mts +270 -5
- package/dist/nuxt/index.d.ts +270 -5
- package/dist/nuxt/index.mjs +3 -3
- package/dist/solid/index.cjs +3 -3
- package/dist/solid/index.d.mts +155 -1
- package/dist/solid/index.d.ts +155 -1
- package/dist/solid/index.mjs +3 -3
- package/dist/svelte/index.cjs +3 -3
- package/dist/svelte/index.d.mts +167 -10
- package/dist/svelte/index.d.ts +167 -10
- package/dist/svelte/index.mjs +3 -3
- package/dist/vue/index.cjs +3 -3
- package/dist/vue/index.d.mts +262 -1
- package/dist/vue/index.d.ts +262 -1
- package/dist/vue/index.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -429,15 +429,15 @@ devtools.highlight('#my-element'); // outline for 2 seconds
|
|
|
429
429
|
|---|---|
|
|
430
430
|
| `svg-scroll-draw` | `scrollDraw`, `scrollAnimate`, `scrollCounter`, `scrollParallax`, `PRESETS`, easing factories |
|
|
431
431
|
| `svg-scroll-draw/react` | `ScrollDraw`, `ScrollAnimate`, `ScrollCounter`, `ScrollVideo`, `ScrollText`, `useScrollDrawProgress` |
|
|
432
|
-
| `svg-scroll-draw/vue` | `ScrollDraw`, `useScrollDraw` |
|
|
433
|
-
| `svg-scroll-draw/svelte` | `scrollDraw` action, `createScrollDraw` |
|
|
434
|
-
| `svg-scroll-draw/solid` | `useScrollDraw`, `createScrollDraw` |
|
|
435
|
-
| `svg-scroll-draw/angular` | `ScrollDrawRef` |
|
|
436
|
-
| `svg-scroll-draw/astro` | `initScrollDraw()` |
|
|
437
|
-
| `svg-scroll-draw/nuxt` | `
|
|
432
|
+
| `svg-scroll-draw/vue` | `ScrollDraw`, `useScrollDraw` · **v2:** `ScrollAnimate`, `ScrollCounter`, `ScrollVideo`, `ScrollText`, `useScrollAnimate`, `useScrollCounter`, `useScrollVideo`, `useScrollText` |
|
|
433
|
+
| `svg-scroll-draw/svelte` | `scrollDraw` action, `createScrollDraw` · **v2:** `scrollAnimate`, `scrollCounterAction`, `scrollVideoAction`, `scrollTextAction`, `createScrollAnimate`, `createScrollCounter`, `createScrollVideo`, `createScrollText` |
|
|
434
|
+
| `svg-scroll-draw/solid` | `useScrollDraw`, `createScrollDraw` · **v2:** `useScrollAnimate`, `useScrollCounter`, `useScrollVideo`, `useScrollText`, `createScrollAnimate`, `createScrollCounter`, `createScrollVideo`, `createScrollText` |
|
|
435
|
+
| `svg-scroll-draw/angular` | `ScrollDrawRef` · **v2:** `ScrollAnimateRef`, `ScrollCounterRef`, `ScrollVideoRef`, `ScrollTextRef` |
|
|
436
|
+
| `svg-scroll-draw/astro` | `initScrollDraw()` · **v2:** `initScrollAnimate()`, `initScrollCounter()`, `initScrollText()`, `initAll()` |
|
|
437
|
+
| `svg-scroll-draw/nuxt` | All Vue v1+v2 composables and components, `createScrollDrawPlugin()` |
|
|
438
438
|
| `svg-scroll-draw/video` | `scrollVideo` |
|
|
439
439
|
| `svg-scroll-draw/text` | `scrollText` |
|
|
440
|
-
| `svg-scroll-draw/group` | `scrollDrawGroup`, `scrollDrawSequence` |
|
|
440
|
+
| `svg-scroll-draw/group` | `scrollDrawGroup`, `scrollDrawSequence` · **v2:** `scrollAnimateGroup`, `scrollAnimateSequence`, `scrollParallaxGroup` |
|
|
441
441
|
| `svg-scroll-draw/timeline` | `scrollDrawTimeline` |
|
|
442
442
|
| `svg-scroll-draw/cinematic` | `Cinematic` |
|
|
443
443
|
| `svg-scroll-draw/devtools` | `devtools` (dev-only) |
|
package/dist/angular/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function
|
|
2
|
-
<div style="position:absolute;${
|
|
3
|
-
<div style="position:absolute;${S?`left:${x}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${x}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(o),window.addEventListener("scroll",h,{passive:true}),h(),o}function Ie(e,n,s){let o=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),h=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,g=>{let D=parseFloat(g),x=o[h++]??D;return String(+(D+(x-D)*s).toFixed(4))})}function Xe(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:s,...o}=n,h=s?{...Ge[s],...o}:o,g=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:D="path, polyline, line, polygon, rect, circle",speed:x=1,fade:S=false,easing:p="linear",trigger:E={},stagger:G=0,direction:d="forward",once:K=false,debug:je=false,axis:N="y",scrollContainer:$e,autoReverse:me=false,delay:ue=0,strokeColor:Q,strokeWidth:Y,fillOpacity:Z,waypoints:ee,velocityScale:pe=false,threshold:Oe=0,rootMargin:Fe="0px",repeat:te=0,repeatDelay:Me=0,morphTo:H,clip:Se,autoplay:Je=false,duration:Ke=1e3,native:Qe=true,onProgress:ce,onStart:de,onComplete:ae}=h,_=Se===true?"left":typeof Se=="string"?Se:false,re=typeof p=="function"?p:Pe[p]??Pe.linear,Ce=Le(E.start??"top bottom"),Re=Le(E.end??"bottom top"),I=typeof $e=="string"?document.querySelector($e):$e??null,W=Array.isArray(Q)?Q[0]:null,T=Array.isArray(Q)?Q[1]:typeof Q=="string"?Q:null,O=Array.isArray(Y)?Y[0]:null,k=Array.isArray(Y)?Y[1]:typeof Y=="number"?Y:null,F=Array.isArray(Z)?Z[0]:null,A=Array.isArray(Z)?Z[1]:typeof Z=="number"?Z:null;function ne(t){let r=t*100;switch(_){case "right":return `inset(0 0 0 ${100-r}%)`;case "top":return `inset(0 0 ${100-r}% 0)`;case "bottom":return `inset(${100-r}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-r}% 0 0)`}}let $=_?[]:Array.from(e.querySelectorAll(D)),w=[],z=[],X=0,U=0,M=false,R=false,v=0,ye=false,q=-1,he=-1,P=false,se=0,B=0,j,Te=null,J=new Set,ge=-1,Ne=performance.now();function fe(){return I?N==="x"?I.scrollLeft:I.scrollTop:N==="x"?window.scrollX:window.scrollY}function He(){return I?N==="x"?I.clientWidth:I.clientHeight:N==="x"?window.innerWidth:window.innerHeight}function We(){let t=e.getBoundingClientRect(),r,l,y;if(I){let L=I.getBoundingClientRect();r=N==="x"?t.left-L.left+I.scrollLeft:t.top-L.top+I.scrollTop,l=N==="x"?t.width:t.height,y=fe();}else r=N==="x"?t.left:t.top,l=N==="x"?t.width:t.height,y=fe();let C=De({top:r,height:l},y,He(),Ce,Re);X=C.tStart,U=C.tEnd,je&&process.env.NODE_ENV!=="production"&&(Te?.remove(),Te=lt(X,U,N));}function Ye(t,r){if(e.style.setProperty("--scroll-draw-progress",String(t)),_){let l=r==="reverse"?1-t:t;e.style.clipPath=ne(l);return}$.forEach((l,y)=>{l.style.strokeDashoffset=r==="reverse"?`${w[y]*t}`:`${w[y]*(1-t)}`,S&&(l.style.opacity=r==="reverse"?`${1-t}`:`${t}`),W&&T?l.style.stroke=xe(W,T,t):T&&(l.style.stroke=T),O!==null&&k!==null?l.style.strokeWidth=`${O+(k-O)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),F!==null&&A!==null?l.style.fillOpacity=`${F+(A-F)*t}`:A!==null&&(l.style.fillOpacity=`${A}`),H&&l.tagName.toLowerCase()==="path"&&z[y]&&l.setAttribute("d",Ie(z[y],H,t));});}function be(){if(e.style.setProperty("--scroll-draw-progress","0"),_){e.style.clipPath=ne(0);return}$.forEach((t,r)=>{t.style.strokeDasharray=`${w[r]}`,t.style.strokeDashoffset=d==="reverse"?"0":`${w[r]}`,S?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",W&&(t.style.stroke=W),O!==null&&(t.style.strokeWidth=`${O}`),F!==null&&(t.style.fillOpacity=`${F}`),H&&t.tagName.toLowerCase()==="path"&&z[r]&&t.setAttribute("d",z[r]);});}if($.forEach(t=>{at(t);let r=Ee(t);w.push(r),t.tagName.toLowerCase()==="path"?z.push(t.getAttribute("d")??""):z.push(""),g?(t.style.strokeDasharray=`${r}`,t.style.strokeDashoffset=d==="reverse"?`${r}`:"0",S&&(t.style.opacity="1"),T&&(t.style.stroke=T),k!==null&&(t.style.strokeWidth=`${k}`),A!==null&&(t.style.fillOpacity=`${A}`),H&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",H)):(t.style.strokeDasharray=`${r}`,t.style.strokeDashoffset=d==="reverse"?"0":`${r}`,S?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",W&&(t.style.stroke=W),O!==null&&(t.style.strokeWidth=`${O}`),F!==null&&(t.style.fillOpacity=`${F}`));}),_){if(g)return e.style.clipPath=ne(1),ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0);}else if(g)return ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Ze(){return !(Qe===false||!it()||!$.length||typeof p!="string"||!(p in _e)||_||N!=="y"||I||x!==1||G!==0||K||me||pe!==false||H||ee||te||ue>0||ce||de||ae||Q!=null||Y!=null||Z!=null||(E.start??"top bottom").trim()!=="top bottom"||(E.end??"bottom top").trim()!=="bottom top")}function et(){let t=`svg-scroll-draw-${++ot}`,r=d==="reverse"?"0":"var(--ssd-len)",l=d==="reverse"?"var(--ssd-len)":"0",y=`stroke-dashoffset:${r};`,C=`stroke-dashoffset:${l};`;S&&(y+=`opacity:${d==="reverse"?1:0};`,C+=`opacity:${d==="reverse"?0:1};`);let L=document.createElement("style");L.setAttribute("data-svg-scroll-draw",""),L.textContent=`@keyframes ${t}{from{${y}}to{${C}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${_e[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(L);function a(i,c){i.style.setProperty("--ssd-len",String(w[c])),i.style.strokeDasharray=`${w[c]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t);}$.forEach(a);let f=false,b=-1;function u(){if(b>=0)return b;let i=e.getBoundingClientRect(),{tStart:c,tEnd:m}=De({top:i.top,height:i.height},fe(),He(),Ce,Re);return re(ie(fe(),c,m,x))}return {destroy(){$.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState="";}),L.remove();},replay(){f=false,b=-1,$.forEach(a);},pause(){f=true,$.forEach(i=>{i.style.animationPlayState="paused";});},resume(){f&&(f=false,$.forEach(i=>{i.style.animationPlayState="running";}));},seek(i){let c=Math.min(1,Math.max(0,i));b=c,f=true,$.forEach((m,oe)=>{m.classList.remove(t),m.style.strokeDashoffset=d==="reverse"?`${w[oe]*c}`:`${w[oe]*(1-c)}`,S&&(m.style.opacity=d==="reverse"?`${1-c}`:`${c}`);});},getProgress(){return u()}}}if(Ze())return et();function tt(){let t=Math.max(1,Ke),r=0,l=0;function y(u){let i=true;if(_){let c=Math.min(1,Math.max(0,u/t)),m=re(c);se=m,e.style.setProperty("--scroll-draw-progress",String(m)),e.style.clipPath=ne(d==="reverse"?1-m:m),ce?.(m),c<1&&(i=false);}else $.forEach((c,m)=>{let oe=m*G*t,le=Math.min(1,Math.max(0,(u-oe)/t)),V=re(le);c.style.strokeDashoffset=d==="reverse"?`${w[m]*V}`:`${w[m]*(1-V)}`,S&&(c.style.opacity=d==="reverse"?`${1-V}`:`${V}`),W&&T?c.style.stroke=xe(W,T,V):T&&(c.style.stroke=T),O!==null&&k!==null?c.style.strokeWidth=`${O+(k-O)*V}`:k!==null&&(c.style.strokeWidth=`${k}`),F!==null&&A!==null?c.style.fillOpacity=`${F+(A-F)*V}`:A!==null&&(c.style.fillOpacity=`${A}`),H&&c.tagName.toLowerCase()==="path"&&z[m]&&c.setAttribute("d",Ie(z[m],H,V)),m===0&&(ce?.(V),e.style.setProperty("--scroll-draw-progress",String(V))),le<1&&(i=false);});if(ee){let c=Math.min(1,Math.max(0,u/t)),m=re(c);for(let oe in ee){let le=parseFloat(oe);m>=le&&!J.has(le)&&(J.add(le),ee[oe]?.());}}return i}function C(u){if(P)return;let i=u-r;R||(R=true,de?.());let c=y(i);if(c&&!M){M=true,y(t*(1+Math.max(0,$.length-1)*G)),ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,j=setTimeout(()=>{r=performance.now(),R=false,M=false,J.clear(),be(),v=requestAnimationFrame(C);},Me));return}c||(v=requestAnimationFrame(C));}function L(){cancelAnimationFrame(v),clearTimeout(j),r=performance.now(),l=0,P=false,R=false,M=false,B=0,J.clear(),be(),v=requestAnimationFrame(C);}let a=new IntersectionObserver(u=>{u.forEach(i=>{i.isIntersecting&&!(K&&M)?L():!i.isIntersecting&&!K&&!M&&(cancelAnimationFrame(v),clearTimeout(j),r=null);});},{root:I??null,threshold:Oe,rootMargin:Fe}),f;function b(){clearTimeout(f),f=setTimeout(()=>{$.forEach((u,i)=>{w[i]=Ee(u),u.style.strokeDasharray=`${w[i]}`;});},150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),ue>0?setTimeout(()=>a.observe(e),ue):a.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(j),a.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(f);},replay(){B=0,L();},pause(){P||(P=true,l=performance.now()-r,cancelAnimationFrame(v));},resume(){P&&(P=false,r=performance.now()-l,v=requestAnimationFrame(C));},seek(u){let i=Math.min(1,Math.max(0,u));se=i,P=true,l=i*t,r=performance.now()-l,cancelAnimationFrame(v),y(l);},getProgress(){return se}}}if(Je)return tt();We();function we(){if(!ye||P)return;let t=performance.now(),r=fe(),l=x;if(pe!==false){let a=t-Ne,f=a>0?Math.abs(r-(ge<0?r:ge))/a:0;l=x*Math.max(.2,1+f*(typeof pe=="number"?pe:1)*.04);}ge=r,Ne=t;let y=me?he===-1||r>=he?"forward":"reverse":d;he=r;let C=U-X,L=true;if(_){let a=re(ie(r,X,U,l));K&&!me&&(q=Math.max(q,a),a=q),se=a,e.style.setProperty("--scroll-draw-progress",String(a));let f=y==="reverse"?1-a:a;e.style.clipPath=ne(f),ce?.(a),!R&&ie(r,X,U,l)>0&&(R=true,de?.()),a>=1&&!M?(M=true,ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,j=setTimeout(()=>{q=-1,R=false,M=false,e.style.clipPath=ne(0);},Me))):a<1&&!K&&(M=false),v=requestAnimationFrame(we);return}if($.forEach((a,f)=>{let b=f*G*C,u=re(ie(r,X+b,U+b,l));K&&!me&&(q=Math.max(q,u),u=q),se=u,a.style.strokeDashoffset=y==="reverse"?`${w[f]*u}`:`${w[f]*(1-u)}`,S&&(a.style.opacity=y==="reverse"?`${1-u}`:`${u}`),W&&T?a.style.stroke=xe(W,T,u):T&&(a.style.stroke=T),O!==null&&k!==null?a.style.strokeWidth=`${O+(k-O)*u}`:k!==null&&(a.style.strokeWidth=`${k}`),F!==null&&A!==null?a.style.fillOpacity=`${F+(A-F)*u}`:A!==null&&(a.style.fillOpacity=`${A}`),H&&a.tagName.toLowerCase()==="path"&&z[f]&&a.setAttribute("d",Ie(z[f],H,u)),f===0&&(ce?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(L=false);}),ee){let a=re(ie(r,X,U,l));for(let f in ee){let b=parseFloat(f);a>=b&&!J.has(b)&&(J.add(b),ee[f]?.());}}!R&&ie(r,X,U,l)>0&&(R=true,de?.()),L&&!M?(M=true,ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,j=setTimeout(()=>{q=-1,R=false,M=false,J.clear(),be();},Me))):!L&&!K&&(M=false),v=requestAnimationFrame(we);}let ke=new IntersectionObserver(t=>{t.forEach(r=>{ye=r.isIntersecting,ye&&!P?v=requestAnimationFrame(we):cancelAnimationFrame(v);});},{root:I??null,threshold:Oe,rootMargin:Fe}),Ae;function ve(){clearTimeout(Ae),Ae=setTimeout(()=>{$.forEach((t,r)=>{w[r]=Ee(t),t.style.strokeDasharray=`${w[r]}`;}),We();},150);}return window.addEventListener("resize",ve),window.addEventListener("orientationchange",ve),ue>0?setTimeout(()=>ke.observe(e),ue):ke.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(j),ke.disconnect(),window.removeEventListener("resize",ve),window.removeEventListener("orientationchange",ve),clearTimeout(Ae),Te?.remove();},replay(){q=-1,he=-1,ge=-1,R=false,M=false,B=0,P=false,J.clear(),clearTimeout(j),be();},pause(){P=true,cancelAnimationFrame(v);},resume(){P&&(P=false,ye&&(v=requestAnimationFrame(we)));},seek(t){let r=Math.min(1,Math.max(0,t));se=r,q=r,P=true,cancelAnimationFrame(v),Ye(r,d);},getProgress(){return se}}}var Ue=class{constructor(){this.instance=null;}init(n,s={}){return this.destroy(),this.instance=Xe(n,s),this}replay(){return this.instance?.replay(),this}destroy(){return this.instance?.destroy(),this.instance=null,this}};exports.ScrollDrawRef=Ue;
|
|
1
|
+
'use strict';function Et({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,r)),u=Math.sqrt(t),o=0,m=[];for(let d=0;d<n;d++){let I=Math.pow(u,d);m.push(I),o+=I;}let l=[0],c=0;for(let d=0;d<n;d++)c+=m[d]/o,l.push(c);return d=>{if(d<=0)return 0;if(d>=1)return 1;for(let I=0;I<n;I++)if(d<=l[I+1]){let B=(d-l[I])/(l[I+1]-l[I]);if(I===0)return B*(2-B);let E=1-Math.pow(t,I);return E+(1-E)*(2*B-1)*(2*B-1)}return 1}}function St({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),t=Math.max(.1,r),u=n<=1?t/4:t/(2*Math.PI)*Math.asin(1/n);return o=>o<=0?0:o>=1?1:n*Math.pow(2,-10*o)*Math.sin((o-u)*(2*Math.PI)/t)+1}var ae={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Et(),elastic:St()};function le(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",t="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:t}}function Ye(e,r,n,t){switch(t){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function je(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Re(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(n+t)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function xt(e,r,n){return Math.min(n,Math.max(r,e))}function J(e,r,n,t){return n===r?0:xt((e-r)/(n-r)*t,0,1)}function fe(e,r,n,t,u){let o=Ye(e.top,e.height,r,t.element)-je(t.viewport,n),m=Ye(e.top,e.height,r,u.element)-je(u.viewport,n);return {tStart:o,tEnd:m}}function Ue(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[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 Ce(e,r,n){let t=Ue(e),u=Ue(r);return !t||!u?e:`rgb(${Math.round(t[0]+(u[0]-t[0])*n)},${Math.round(t[1]+(u[1]-t[1])*n)},${Math.round(t[2]+(u[2]-t[2])*n)})`}var Ze={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};function Je(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ke={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Tt=0;function At(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Mt(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Je("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Je("Element has a fill \u2014 it may obscure the stroke animation.",e);}function $t(e,r,n){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function u(){let o=n==="x"?window.scrollX:window.scrollY,m=e-o,l=r-o,c=n==="x";t.innerHTML=`
|
|
2
|
+
<div style="position:absolute;${c?`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;${c?`left:${l}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${l}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(t),window.addEventListener("scroll",u,{passive:true}),u(),t}function We(e,r,n){let t=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,o=>{let m=parseFloat(o),l=t[u++]??m;return String(+(m+(l-m)*n).toFixed(4))})}function Qe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...t}=r,u=n?{...Ze[n],...t}:t,o=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:m="path, polyline, line, polygon, rect, circle",speed:l=1,fade:c=false,easing:d="linear",trigger:I={},stagger:B=0,direction:E="forward",once:re=false,debug:de=false,axis:q="y",scrollContainer:K,autoReverse:T=false,delay:N=0,strokeColor:A,strokeWidth:$,fillOpacity:P,waypoints:b,velocityScale:L=false,threshold:O=0,rootMargin:D="0px",repeat:M=0,repeatDelay:z=0,morphTo:C,clip:_,autoplay:Q=false,duration:j=1e3,native:oe=true,onProgress:f,onStart:k,onComplete:h}=u,p=_===true?"left":typeof _=="string"?_:false,F=typeof d=="function"?d:ae[d]??ae.linear,ge=le(I.start??"top bottom"),a=le(I.end??"bottom top"),g=typeof K=="string"?document.querySelector(K):K??null,ne=Array.isArray(A)?A[0]:null,V=Array.isArray(A)?A[1]:typeof A=="string"?A:null,U=Array.isArray($)?$[0]:null,se=Array.isArray($)?$[1]:typeof $=="number"?$:null,H=Array.isArray(P)?P[0]:null,G=Array.isArray(P)?P[1]:typeof P=="number"?P:null;function me(s){let i=s*100;switch(p){case "right":return `inset(0 0 0 ${100-i}%)`;case "top":return `inset(0 0 ${100-i}% 0)`;case "bottom":return `inset(${100-i}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-i}% 0 0)`}}let ee=p?[]:Array.from(e.querySelectorAll(m)),X=[],ye=[],Ee=0,Se=0,ie=false,he=false,te=0,Ie=false,be=-1,Oe=-1,ce=false,$e=0,ve=0,xe,ze=null,Te=new Set,Fe=-1,Be=performance.now();function ke(){return g?q==="x"?g.scrollLeft:g.scrollTop:q==="x"?window.scrollX:window.scrollY}function Ge(){return g?q==="x"?g.clientWidth:g.clientHeight:q==="x"?window.innerWidth:window.innerHeight}function Xe(){let s=e.getBoundingClientRect(),i,v,Y;if(g){let ue=g.getBoundingClientRect();i=q==="x"?s.left-ue.left+g.scrollLeft:s.top-ue.top+g.scrollTop,v=q==="x"?s.width:s.height,Y=ke();}else i=q==="x"?s.left:s.top,v=q==="x"?s.width:s.height,Y=ke();let pe=fe({top:i,height:v},Y,Ge(),ge,a);Ee=pe.tStart,Se=pe.tEnd,de&&process.env.NODE_ENV!=="production"&&(ze?.remove(),ze=$t(Ee,Se,q));}function yt(s,i){if(e.style.setProperty("--scroll-draw-progress",String(s)),p){let v=i==="reverse"?1-s:s;e.style.clipPath=me(v);return}ee.forEach((v,Y)=>{v.style.strokeDashoffset=i==="reverse"?`${X[Y]*s}`:`${X[Y]*(1-s)}`,c&&(v.style.opacity=i==="reverse"?`${1-s}`:`${s}`),ne&&V?v.style.stroke=Ce(ne,V,s):V&&(v.style.stroke=V),U!==null&&se!==null?v.style.strokeWidth=`${U+(se-U)*s}`:se!==null&&(v.style.strokeWidth=`${se}`),H!==null&&G!==null?v.style.fillOpacity=`${H+(G-H)*s}`:G!==null&&(v.style.fillOpacity=`${G}`),C&&v.tagName.toLowerCase()==="path"&&ye[Y]&&v.setAttribute("d",We(ye[Y],C,s));});}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),p){e.style.clipPath=me(0);return}ee.forEach((s,i)=>{s.style.strokeDasharray=`${X[i]}`,s.style.strokeDashoffset=E==="reverse"?"0":`${X[i]}`,c?s.style.opacity=E==="reverse"?"1":"0":s.style.opacity="",ne&&(s.style.stroke=ne),U!==null&&(s.style.strokeWidth=`${U}`),H!==null&&(s.style.fillOpacity=`${H}`),C&&s.tagName.toLowerCase()==="path"&&ye[i]&&s.setAttribute("d",ye[i]);});}if(ee.forEach(s=>{Mt(s);let i=Re(s);X.push(i),s.tagName.toLowerCase()==="path"?ye.push(s.getAttribute("d")??""):ye.push(""),o?(s.style.strokeDasharray=`${i}`,s.style.strokeDashoffset=E==="reverse"?`${i}`:"0",c&&(s.style.opacity="1"),V&&(s.style.stroke=V),se!==null&&(s.style.strokeWidth=`${se}`),G!==null&&(s.style.fillOpacity=`${G}`),C&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",C)):(s.style.strokeDasharray=`${i}`,s.style.strokeDashoffset=E==="reverse"?"0":`${i}`,c?s.style.opacity=E==="reverse"?"1":"0":s.style.opacity="",ne&&(s.style.stroke=ne),U!==null&&(s.style.strokeWidth=`${U}`),H!==null&&(s.style.fillOpacity=`${H}`));}),p){if(o)return e.style.clipPath=me(1),h?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=me(0);}else if(o)return h?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function bt(){return !(oe===false||!At()||!ee.length||typeof d!="string"||!(d in Ke)||p||q!=="y"||g||l!==1||B!==0||re||T||L!==false||C||b||M||N>0||f||k||h||A!=null||$!=null||P!=null||(I.start??"top bottom").trim()!=="top bottom"||(I.end??"bottom top").trim()!=="bottom top")}function wt(){let s=`svg-scroll-draw-${++Tt}`,i=E==="reverse"?"0":"var(--ssd-len)",v=E==="reverse"?"var(--ssd-len)":"0",Y=`stroke-dashoffset:${i};`,pe=`stroke-dashoffset:${v};`;c&&(Y+=`opacity:${E==="reverse"?1:0};`,pe+=`opacity:${E==="reverse"?0:1};`);let ue=document.createElement("style");ue.setAttribute("data-svg-scroll-draw",""),ue.textContent=`@keyframes ${s}{from{${Y}}to{${pe}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${Ke[d]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(ue);function w(y,x){y.style.setProperty("--ssd-len",String(X[x])),y.style.strokeDasharray=`${X[x]}`,y.style.strokeDashoffset="",y.style.opacity="",y.style.animationPlayState="",y.classList.add(s);}ee.forEach(w);let R=false,Z=-1;function S(){if(Z>=0)return Z;let y=e.getBoundingClientRect(),{tStart:x,tEnd:W}=fe({top:y.top,height:y.height},ke(),Ge(),ge,a);return F(J(ke(),x,W,l))}return {destroy(){ee.forEach(y=>{y.classList.remove(s),y.style.removeProperty("--ssd-len"),y.style.animationPlayState="";}),ue.remove();},replay(){R=false,Z=-1,ee.forEach(w);},pause(){R=true,ee.forEach(y=>{y.style.animationPlayState="paused";});},resume(){R&&(R=false,ee.forEach(y=>{y.style.animationPlayState="running";}));},seek(y){let x=Math.min(1,Math.max(0,y));Z=x,R=true,ee.forEach((W,Pe)=>{W.classList.remove(s),W.style.strokeDashoffset=E==="reverse"?`${X[Pe]*x}`:`${X[Pe]*(1-x)}`,c&&(W.style.opacity=E==="reverse"?`${1-x}`:`${x}`);});},getProgress(){return S()}}}if(bt())return wt();function vt(){let s=Math.max(1,j),i=0,v=0;function Y(S){let y=true;if(p){let x=Math.min(1,Math.max(0,S/s)),W=F(x);$e=W,e.style.setProperty("--scroll-draw-progress",String(W)),e.style.clipPath=me(E==="reverse"?1-W:W),f?.(W),x<1&&(y=false);}else ee.forEach((x,W)=>{let Pe=W*B*s,Le=Math.min(1,Math.max(0,(S-Pe)/s)),we=F(Le);x.style.strokeDashoffset=E==="reverse"?`${X[W]*we}`:`${X[W]*(1-we)}`,c&&(x.style.opacity=E==="reverse"?`${1-we}`:`${we}`),ne&&V?x.style.stroke=Ce(ne,V,we):V&&(x.style.stroke=V),U!==null&&se!==null?x.style.strokeWidth=`${U+(se-U)*we}`:se!==null&&(x.style.strokeWidth=`${se}`),H!==null&&G!==null?x.style.fillOpacity=`${H+(G-H)*we}`:G!==null&&(x.style.fillOpacity=`${G}`),C&&x.tagName.toLowerCase()==="path"&&ye[W]&&x.setAttribute("d",We(ye[W],C,we)),W===0&&(f?.(we),e.style.setProperty("--scroll-draw-progress",String(we))),Le<1&&(y=false);});if(b){let x=Math.min(1,Math.max(0,S/s)),W=F(x);for(let Pe in b){let Le=parseFloat(Pe);W>=Le&&!Te.has(Le)&&(Te.add(Le),b[Pe]?.());}}return y}function pe(S){if(ce)return;let y=S-i;he||(he=true,k?.());let x=Y(y);if(x&&!ie){ie=true,Y(s*(1+Math.max(0,ee.length-1)*B)),h?.(),ve<(M==="infinite"?1/0:M??0)&&(ve++,xe=setTimeout(()=>{i=performance.now(),he=false,ie=false,Te.clear(),De(),te=requestAnimationFrame(pe);},z));return}x||(te=requestAnimationFrame(pe));}function ue(){cancelAnimationFrame(te),clearTimeout(xe),i=performance.now(),v=0,ce=false,he=false,ie=false,ve=0,Te.clear(),De(),te=requestAnimationFrame(pe);}let w=new IntersectionObserver(S=>{S.forEach(y=>{y.isIntersecting&&!(re&&ie)?ue():!y.isIntersecting&&!re&&!ie&&(cancelAnimationFrame(te),clearTimeout(xe),i=null);});},{root:g??null,threshold:O,rootMargin:D}),R;function Z(){clearTimeout(R),R=setTimeout(()=>{ee.forEach((S,y)=>{X[y]=Re(S),S.style.strokeDasharray=`${X[y]}`;});},150);}return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),N>0?setTimeout(()=>w.observe(e),N):w.observe(e),{destroy(){cancelAnimationFrame(te),clearTimeout(xe),w.disconnect(),window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z),clearTimeout(R);},replay(){ve=0,ue();},pause(){ce||(ce=true,v=performance.now()-i,cancelAnimationFrame(te));},resume(){ce&&(ce=false,i=performance.now()-v,te=requestAnimationFrame(pe));},seek(S){let y=Math.min(1,Math.max(0,S));$e=y,ce=true,v=y*s,i=performance.now()-v,cancelAnimationFrame(te),Y(v);},getProgress(){return $e}}}if(Q)return vt();Xe();function Ne(){if(!Ie||ce)return;let s=performance.now(),i=ke(),v=l;if(L!==false){let w=s-Be,R=w>0?Math.abs(i-(Fe<0?i:Fe))/w:0;v=l*Math.max(.2,1+R*(typeof L=="number"?L:1)*.04);}Fe=i,Be=s;let Y=T?Oe===-1||i>=Oe?"forward":"reverse":E;Oe=i;let pe=Se-Ee,ue=true;if(p){let w=F(J(i,Ee,Se,v));re&&!T&&(be=Math.max(be,w),w=be),$e=w,e.style.setProperty("--scroll-draw-progress",String(w));let R=Y==="reverse"?1-w:w;e.style.clipPath=me(R),f?.(w),!he&&J(i,Ee,Se,v)>0&&(he=true,k?.()),w>=1&&!ie?(ie=true,h?.(),ve<(M==="infinite"?1/0:M??0)&&(ve++,xe=setTimeout(()=>{be=-1,he=false,ie=false,e.style.clipPath=me(0);},z))):w<1&&!re&&(ie=false),te=requestAnimationFrame(Ne);return}if(ee.forEach((w,R)=>{let Z=R*B*pe,S=F(J(i,Ee+Z,Se+Z,v));re&&!T&&(be=Math.max(be,S),S=be),$e=S,w.style.strokeDashoffset=Y==="reverse"?`${X[R]*S}`:`${X[R]*(1-S)}`,c&&(w.style.opacity=Y==="reverse"?`${1-S}`:`${S}`),ne&&V?w.style.stroke=Ce(ne,V,S):V&&(w.style.stroke=V),U!==null&&se!==null?w.style.strokeWidth=`${U+(se-U)*S}`:se!==null&&(w.style.strokeWidth=`${se}`),H!==null&&G!==null?w.style.fillOpacity=`${H+(G-H)*S}`:G!==null&&(w.style.fillOpacity=`${G}`),C&&w.tagName.toLowerCase()==="path"&&ye[R]&&w.setAttribute("d",We(ye[R],C,S)),R===0&&(f?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&(ue=false);}),b){let w=F(J(i,Ee,Se,v));for(let R in b){let Z=parseFloat(R);w>=Z&&!Te.has(Z)&&(Te.add(Z),b[R]?.());}}!he&&J(i,Ee,Se,v)>0&&(he=true,k?.()),ue&&!ie?(ie=true,h?.(),ve<(M==="infinite"?1/0:M??0)&&(ve++,xe=setTimeout(()=>{be=-1,he=false,ie=false,Te.clear(),De();},z))):!ue&&!re&&(ie=false),te=requestAnimationFrame(Ne);}let Ve=new IntersectionObserver(s=>{s.forEach(i=>{Ie=i.isIntersecting,Ie&&!ce?te=requestAnimationFrame(Ne):cancelAnimationFrame(te);});},{root:g??null,threshold:O,rootMargin:D}),qe;function He(){clearTimeout(qe),qe=setTimeout(()=>{ee.forEach((s,i)=>{X[i]=Re(s),s.style.strokeDasharray=`${X[i]}`;}),Xe();},150);}return window.addEventListener("resize",He),window.addEventListener("orientationchange",He),N>0?setTimeout(()=>Ve.observe(e),N):Ve.observe(e),{destroy(){cancelAnimationFrame(te),clearTimeout(xe),Ve.disconnect(),window.removeEventListener("resize",He),window.removeEventListener("orientationchange",He),clearTimeout(qe),ze?.remove();},replay(){be=-1,Oe=-1,Fe=-1,he=false,ie=false,ve=0,ce=false,Te.clear(),clearTimeout(xe),De();},pause(){ce=true,cancelAnimationFrame(te);},resume(){ce&&(ce=false,Ie&&(te=requestAnimationFrame(Ne)));},seek(s){let i=Math.min(1,Math.max(0,s));$e=i,be=i,ce=true,cancelAnimationFrame(te),yt(i,E);},getProgress(){return $e}}}var et=new Map;function Ae(e,r){et.set(e,r);}function Me(e){et.delete(e);}function Pt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function tt(e){let r=[],n=/([\w]+)\(([^)]*)\)/g,t;for(;(t=n.exec(e))!==null;){let u=[],o=[],m=t[2].trim();if(m)for(let l of m.split(/[\s,]+/)){let c=l.match(/^([-+]?[\d.eE]+)(.*)$/);u.push(c?parseFloat(c[1]):0),o.push(c?c[2]:"");}r.push({fn:t[1],nums:u,units:o});}return r}function Lt(e,r,n){let t=tt(e),u=tt(r);return t.length===0||t.length!==u.length?n<1?e:r:t.map((o,m)=>{let l=u[m];return o.fn!==l.fn||o.nums.length!==l.nums.length?n<1?`${o.fn}(${o.nums.map((c,d)=>`${c}${o.units[d]}`).join(", ")})`:`${l.fn}(${l.nums.map((c,d)=>`${c}${l.units[d]}`).join(", ")})`:`${o.fn}(${o.nums.map((c,d)=>`${c+(l.nums[d]-c)*n}${o.units[d]}`).join(", ")})`}).join(" ")}function rt(e,r,n){if(typeof e=="number"&&typeof r=="number")return String(e+(r-e)*n);let t=String(e),u=String(r);if(Pt(t))return Ce(t,u,n);if(t.includes("("))return Lt(t,u,n);let o=t.match(/^([-+]?[\d.]+)(.*)$/),m=u.match(/^([-+]?[\d.]+)(.*)$/);if(o&&m){let l=parseFloat(o[1]),c=parseFloat(m[1]);return `${l+(c-l)*n}${o[2]||m[2]}`}return n<1?t:u}function Ct(e){return e.replace(/([A-Z])/g,r=>`-${r.toLowerCase()}`)}var nt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},kt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),It=0;function Ot(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function st(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let{props:t,trigger:u={},easing:o="ease-out",speed:m=1,once:l=false,axis:c="y",scrollContainer:d,native:I=true,onProgress:B,onComplete:E}=r,re=window.matchMedia("(prefers-reduced-motion: reduce)").matches,de=typeof o=="function"?o:ae[o]??ae["ease-out"],q=le(u.start??"top bottom"),K=le(u.end??"bottom top"),T=typeof d=="string"?document.querySelector(d):d??null,N=Object.entries(t).map(([a,g])=>({prop:Ct(a),from:Array.isArray(g)?g[0]:"",to:Array.isArray(g)?g[1]:g}));function A(){let a=window.getComputedStyle(e);for(let g of N)g.from===""&&(g.from=a.getPropertyValue(g.prop).trim()||"0");}function $(){for(let a of N)e.style.setProperty(a.prop,String(a.to));}if(re)return $(),E?.(),n;A();function P(){if(!I||!Ot()||typeof o!="string"||!(o in nt)||c!=="y"||T||l||m!==1||B||E||(u.start??"top bottom").trim()!=="top bottom"||(u.end??"bottom top").trim()!=="bottom top")return false;for(let a of N)if(!kt.has(a.prop))return false;return true}function b(){let a=`ssd-a-${++It}`,g=N.map(H=>`${H.prop}:${H.from}`).join(";"),ne=N.map(H=>`${H.prop}:${H.to}`).join(";"),V=document.createElement("style");V.setAttribute("data-ssd-animate",""),V.textContent=`@keyframes ${a}{from{${g}}to{${ne}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${nt[o]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(V),e.classList.add(a);let U=()=>c==="x"?window.scrollX:window.scrollY,se=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),V.remove();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(H){let G=Math.min(1,Math.max(0,H));e.classList.remove(a);for(let me of N)e.style.setProperty(me.prop,rt(me.from,me.to,G));},getProgress(){let H=e.getBoundingClientRect(),G=U(),me=se(),{tStart:ee,tEnd:X}=fe({top:H.top,height:H.height},G,me,q,K);return de(J(G,ee,X,m))}}}if(P())return b();let L=0,O=0,D=0,M=false,z=false,C=-1,_=0,Q=false,j=()=>T?c==="x"?T.scrollLeft:T.scrollTop:c==="x"?window.scrollX:window.scrollY,oe=()=>T?c==="x"?T.clientWidth:T.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function f(){let a=e.getBoundingClientRect(),g,ne;if(T){let U=T.getBoundingClientRect();g=c==="x"?a.left-U.left+T.scrollLeft:a.top-U.top+T.scrollTop,ne=c==="x"?a.width:a.height;}else g=c==="x"?a.left:a.top,ne=c==="x"?a.width:a.height;let V=fe({top:g,height:ne},j(),oe(),q,K);L=V.tStart,O=V.tEnd;}function k(a){e.style.setProperty("--scroll-draw-progress",String(a));for(let g of N)e.style.setProperty(g.prop,rt(g.from,g.to,a));B?.(a);}function h(){if(!M||z)return;let a=de(J(j(),L,O,m));l&&(C=Math.max(C,a),a=C),_=a,k(a),a>=1&&!Q?(Q=true,E?.()):a<1&&!l&&(Q=false),D=requestAnimationFrame(h);}f();{let a=de(J(j(),L,O,m));l&&a>0&&(C=a),_=a,k(a);}let p=new IntersectionObserver(a=>{a.forEach(g=>{M=g.isIntersecting,M&&!z?D=requestAnimationFrame(h):cancelAnimationFrame(D);});},{root:T??null}),F;function ge(){clearTimeout(F),F=setTimeout(f,150);}return window.addEventListener("resize",ge),window.addEventListener("orientationchange",ge),p.observe(e),Ae(e,{type:"animate",getProgress:()=>_,getTrigger:()=>({tStart:L,tEnd:O})}),{destroy(){cancelAnimationFrame(D),p.disconnect(),window.removeEventListener("resize",ge),window.removeEventListener("orientationchange",ge),clearTimeout(F),Me(e);},replay(){C=-1,Q=false,_=0,z=false,k(0);},pause(){z=true,cancelAnimationFrame(D);},resume(){z&&(z=false,M&&(D=requestAnimationFrame(h)));},seek(a){let g=Math.min(1,Math.max(0,a));_=g,C=g,z=true,cancelAnimationFrame(D),k(g);},getProgress(){return _}}}var _e={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function ot(e,r){if(typeof window>"u")return _e;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),_e;let t=n,{from:u=0,to:o,format:m,easing:l="ease-out",trigger:c={},once:d=true,decimals:I,onComplete:B}=r,E=I!==void 0?f=>f.toFixed(I):m??(f=>String(Math.round(f))),re=typeof l=="function"?l:ae[l]??ae["ease-out"],de=le(c.start??"top 80%"),q=le(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return t.textContent=E(o),B?.(),_e;t.textContent=E(u);let T=0,N=0,A=0,$=false,P=false,b=-1,L=0,O=false,D=()=>window.scrollY,M=()=>window.innerHeight;function z(){let f=t.getBoundingClientRect(),k=fe({top:f.top,height:f.height},D(),M(),de,q);T=k.tStart,N=k.tEnd;}function C(f){t.textContent=E(u+(o-u)*f),t.style.setProperty("--scroll-draw-progress",String(f));}function _(){if(!$||P)return;let f=re(J(D(),T,N,1));d&&(b=Math.max(b,f),f=b),L=f,C(f),f>=1&&!O?(O=true,B?.()):f<1&&!d&&(O=false),A=requestAnimationFrame(_);}z();{let f=re(J(D(),T,N,1));d&&f>0&&(b=f),L=f,C(f);}let Q=new IntersectionObserver(f=>{f.forEach(k=>{$=k.isIntersecting,$&&!P?A=requestAnimationFrame(_):cancelAnimationFrame(A);});}),j;function oe(){clearTimeout(j),j=setTimeout(z,150);}return window.addEventListener("resize",oe),window.addEventListener("orientationchange",oe),Q.observe(t),Ae(t,{type:"counter",getProgress:()=>L,getTrigger:()=>({tStart:T,tEnd:N})}),{destroy(){cancelAnimationFrame(A),Q.disconnect(),window.removeEventListener("resize",oe),window.removeEventListener("orientationchange",oe),clearTimeout(j),Me(t);},replay(){b=-1,O=false,L=0,P=false,C(0);},pause(){P=true,cancelAnimationFrame(A);},resume(){P&&(P=false,$&&(A=requestAnimationFrame(_)));},seek(f){let k=Math.min(1,Math.max(0,f));L=k,b=k,P=true,cancelAnimationFrame(A),C(k);},getProgress(){return L}}}var it={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function at(e,r={}){if(typeof window>"u")return it;let n=typeof e=="string"?document.querySelector(e):e;if(!n||n.tagName.toLowerCase()!=="video")return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollVideo: <video> element not found:",e),it;let t=n,{trigger:u={},easing:o="linear",once:m=false,axis:l="y",preload:c="auto",onReady:d,onComplete:I,onProgress:B}=r,E=window.matchMedia("(prefers-reduced-motion: reduce)").matches,re=typeof o=="function"?o:ae[o]??ae.linear,de=le(u.start??"top top"),q=le(u.end??"bottom top");t.pause(),t.hasAttribute("preload")||(t.preload=c);let K=r.from??0,T=r.to,N=0,A=0,$=0,P=false,b=false,L=-1,O=0,D=false,M=false,z=()=>l==="x"?window.scrollX:window.scrollY,C=()=>l==="x"?window.innerWidth:window.innerHeight;function _(){let p=t.getBoundingClientRect(),F=l==="x"?p.left:p.top,ge=l==="x"?p.width:p.height,a=fe({top:F,height:ge},z(),C(),de,q);N=a.tStart,A=a.tEnd;}function Q(p){if(!M)return;let F=T??t.duration??0;t.currentTime=K+(F-K)*p,t.style.setProperty("--scroll-draw-progress",String(p)),B?.(p);}function j(){if(!P||b||!M)return;let p=re(J(z(),N,A,1));m&&(L=Math.max(L,p),p=L),O=p,Q(p),p>=1&&!D?(D=true,I?.()):p<1&&!m&&(D=false),$=requestAnimationFrame(j);}function oe(){if(M=true,T===void 0&&(T=t.duration),E){Q(1),d?.();return}_(),d?.(),P&&!b&&($=requestAnimationFrame(j));}t.readyState>=1?oe():t.addEventListener("loadedmetadata",oe,{once:true}),M||_();let f=new IntersectionObserver(p=>{p.forEach(F=>{P=F.isIntersecting,P&&!b&&M?$=requestAnimationFrame(j):cancelAnimationFrame($);});}),k;function h(){clearTimeout(k),k=setTimeout(_,150);}return window.addEventListener("resize",h),window.addEventListener("orientationchange",h),f.observe(t),Ae(t,{type:"video",getProgress:()=>O,getTrigger:()=>({tStart:N,tEnd:A})}),{destroy(){cancelAnimationFrame($),f.disconnect(),t.removeEventListener("loadedmetadata",oe),window.removeEventListener("resize",h),window.removeEventListener("orientationchange",h),clearTimeout(k),Me(t);},replay(){L=-1,D=false,O=0,b=false,Q(0);},pause(){b=true,cancelAnimationFrame($);},resume(){b&&(b=false,P&&M&&($=requestAnimationFrame(j)));},seek(p){let F=Math.min(1,Math.max(0,p));O=F,L=F,b=true,cancelAnimationFrame($),Q(F);},getProgress(){return O}}}function ut(e){let r=e.textContent??"";return e.textContent="",r.split(/(\s+)/).filter(Boolean).map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),/^\s+$/.test(n)?(t.textContent=n,t.style.whiteSpace="pre"):(t.textContent=n,t.style.display="inline-block"),e.appendChild(t),/^\s+$/.test(n)?null:t}).filter(n=>n!==null)}function Ft(e){let r=e.textContent??"";return e.textContent="",r.split("").map(n=>{let t=document.createElement("span");return t.setAttribute("aria-hidden","true"),t.textContent=n,n===" "?t.style.whiteSpace="pre":t.style.display="inline-block",e.appendChild(t),n===" "?null:t}).filter(n=>n!==null)}function lt(e){let r=ut(e),n=new Map;for(let o of r){let m=o.offsetTop;n.has(m)||n.set(m,[]),n.get(m).push(o);}let t=[],u=Array.from(n.keys()).sort((o,m)=>o-m);for(let o of u){let m=n.get(o),l=document.createElement("span");l.setAttribute("aria-hidden","true"),l.style.display="inline-block";for(let c of m)l.appendChild(c);t.push(l);}e.textContent="";for(let o of t)e.appendChild(o),e.appendChild(document.createTextNode(" "));return t}function Dt(e,r,n,t){if(n<=1||t===0)return e;let u=(n-1)*t,o=r*t,m=o+(1-u);return m<=o?e>=o?1:0:Math.min(1,Math.max(0,(e-o)/(m-o)))}function Nt(e,r){let n=[];if(r?.y!==void 0&&n.push(`translateY(${r.y*(1-e)}px)`),r?.x!==void 0&&n.push(`translateX(${r.x*(1-e)}px)`),r?.rotate!==void 0&&n.push(`rotate(${r.rotate*(1-e)}deg)`),r?.scale!==void 0){let t=r.scale+(1-r.scale)*e;n.push(`scale(${t})`);}return n.join(" ")||""}var ct={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function mt(e,r={}){if(typeof window>"u")return ct;let n=typeof e=="string"?document.querySelector(e):e;if(!n)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollText: element not found:",e),ct;let t=n,{split:u="words",stagger:o=.04,easing:m="ease-out",from:l={opacity:0,y:24},trigger:c={},once:d=true,onComplete:I}=r,B=window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=typeof m=="function"?m:ae[m]??ae["ease-out"],re=le(c.start??"top 85%"),de=le(c.end??"top 40%"),q=t.innerHTML;t.setAttribute("aria-label",t.textContent??"");let K;u==="chars"?K=Ft(t):u==="lines"?K=lt(t):K=ut(t);let T=K.length;function N(h,p){l?.opacity!==void 0&&(h.style.opacity=String(l.opacity+(1-l.opacity)*p));let F=Nt(p,l);F&&(h.style.transform=F);}function A(h){t.style.setProperty("--scroll-draw-progress",String(h)),K.forEach((p,F)=>{let ge=E(Dt(h,F,T,o));N(p,ge);});}if(B)return A(1),I?.(),{destroy(){t.innerHTML=q,t.removeAttribute("aria-label");},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};A(0);let $=0,P=0,b=0,L=false,O=false,D=-1,M=0,z=false,C=()=>window.scrollY,_=()=>window.innerHeight;function Q(){let h=t.getBoundingClientRect(),p=fe({top:h.top,height:h.height},C(),_(),re,de);$=p.tStart,P=p.tEnd;}function j(){if(!L||O)return;let h=J(C(),$,P,1);d&&(D=Math.max(D,h),h=D),M=h,A(h),h>=1&&!z?(z=true,I?.()):h<1&&!d&&(z=false),b=requestAnimationFrame(j);}Q();let oe=new IntersectionObserver(h=>{h.forEach(p=>{L=p.isIntersecting,L&&!O?b=requestAnimationFrame(j):cancelAnimationFrame(b);});}),f;function k(){clearTimeout(f),f=setTimeout(()=>{if(u==="lines"){let h=M;t.innerHTML=q,t.setAttribute("aria-label",t.textContent??""),K=lt(t),A(h);}Q();},150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),oe.observe(t),Ae(t,{type:"text",getProgress:()=>M,getTrigger:()=>({tStart:$,tEnd:P})}),{destroy(){cancelAnimationFrame(b),oe.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(f),t.innerHTML=q,t.removeAttribute("aria-label"),Me(t);},replay(){D=-1,z=false,M=0,O=false,A(0);},pause(){O=true,cancelAnimationFrame(b);},resume(){O&&(O=false,L&&(b=requestAnimationFrame(j)));},seek(h){let p=Math.min(1,Math.max(0,h));M=p,D=p,O=true,cancelAnimationFrame(b),A(p);},getProgress(){return M}}}var pt=class{constructor(){this.instance=null;}init(r,n={}){return this.destroy(),this.instance=Qe(r,n),this}replay(){return this.instance?.replay(),this}pause(){return this.instance?.pause(),this}resume(){return this.instance?.resume(),this}seek(r){return this.instance?.seek(r),this}getProgress(){return this.instance?.getProgress()??0}destroy(){return this.instance?.destroy(),this.instance=null,this}},ft=class{constructor(){this.instance=null;}init(r,n){return this.destroy(),this.instance=st(r,n),this}replay(){return this.instance?.replay(),this}pause(){return this.instance?.pause(),this}resume(){return this.instance?.resume(),this}seek(r){return this.instance?.seek(r),this}getProgress(){return this.instance?.getProgress()??0}destroy(){return this.instance?.destroy(),this.instance=null,this}},dt=class{constructor(){this.instance=null;}init(r,n){return this.destroy(),this.instance=ot(r,n),this}replay(){return this.instance?.replay(),this}pause(){return this.instance?.pause(),this}resume(){return this.instance?.resume(),this}seek(r){return this.instance?.seek(r),this}getProgress(){return this.instance?.getProgress()??0}destroy(){return this.instance?.destroy(),this.instance=null,this}},gt=class{constructor(){this.instance=null;}init(r,n={}){return this.destroy(),this.instance=at(r,n),this}replay(){return this.instance?.replay(),this}pause(){return this.instance?.pause(),this}resume(){return this.instance?.resume(),this}seek(r){return this.instance?.seek(r),this}getProgress(){return this.instance?.getProgress()??0}destroy(){return this.instance?.destroy(),this.instance=null,this}},ht=class{constructor(){this.instance=null;}init(r,n={}){return this.destroy(),this.instance=mt(r,n),this}replay(){return this.instance?.replay(),this}pause(){return this.instance?.pause(),this}resume(){return this.instance?.resume(),this}seek(r){return this.instance?.seek(r),this}getProgress(){return this.instance?.getProgress()??0}destroy(){return this.instance?.destroy(),this.instance=null,this}};exports.ScrollAnimateRef=ft;exports.ScrollCounterRef=dt;exports.ScrollDrawRef=pt;exports.ScrollTextRef=ht;exports.ScrollVideoRef=gt;
|
package/dist/angular/index.d.mts
CHANGED
|
@@ -119,14 +119,64 @@ interface ScrollDrawInstance {
|
|
|
119
119
|
getProgress: () => number;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
interface ScrollAnimateOptions {
|
|
123
|
+
props: Record<string, string | number | [string | number, string | number]>;
|
|
124
|
+
trigger?: TriggerConfig;
|
|
125
|
+
easing?: EasingName | ((t: number) => number);
|
|
126
|
+
speed?: number;
|
|
127
|
+
once?: boolean;
|
|
128
|
+
axis?: 'x' | 'y';
|
|
129
|
+
scrollContainer?: string | Element;
|
|
130
|
+
native?: boolean;
|
|
131
|
+
onProgress?: (alpha: number) => void;
|
|
132
|
+
onComplete?: () => void;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface ScrollCounterOptions {
|
|
136
|
+
from?: number;
|
|
137
|
+
to: number;
|
|
138
|
+
format?: (value: number) => string;
|
|
139
|
+
easing?: EasingName | ((t: number) => number);
|
|
140
|
+
trigger?: TriggerConfig;
|
|
141
|
+
once?: boolean;
|
|
142
|
+
decimals?: number;
|
|
143
|
+
onComplete?: () => void;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface ScrollVideoOptions {
|
|
147
|
+
trigger?: TriggerConfig;
|
|
148
|
+
from?: number;
|
|
149
|
+
to?: number;
|
|
150
|
+
easing?: EasingName | ((t: number) => number);
|
|
151
|
+
once?: boolean;
|
|
152
|
+
axis?: 'x' | 'y';
|
|
153
|
+
preload?: 'auto' | 'metadata';
|
|
154
|
+
onReady?: () => void;
|
|
155
|
+
onComplete?: () => void;
|
|
156
|
+
onProgress?: (alpha: number) => void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface ScrollTextOptions {
|
|
160
|
+
split?: 'chars' | 'words' | 'lines';
|
|
161
|
+
stagger?: number;
|
|
162
|
+
easing?: EasingName | ((t: number) => number);
|
|
163
|
+
from?: {
|
|
164
|
+
opacity?: number;
|
|
165
|
+
y?: number;
|
|
166
|
+
x?: number;
|
|
167
|
+
rotate?: number;
|
|
168
|
+
scale?: number;
|
|
169
|
+
};
|
|
170
|
+
trigger?: TriggerConfig;
|
|
171
|
+
once?: boolean;
|
|
172
|
+
onComplete?: () => void;
|
|
173
|
+
}
|
|
174
|
+
|
|
122
175
|
/**
|
|
123
176
|
* Framework-agnostic class for use in Angular components.
|
|
124
177
|
* No @angular/core dependency required.
|
|
125
178
|
*
|
|
126
179
|
* @example
|
|
127
|
-
* // In your Angular component:
|
|
128
|
-
* import { ScrollDrawRef } from 'svg-scroll-draw/angular';
|
|
129
|
-
*
|
|
130
180
|
* @Component({ template: '<div #container><svg>...</svg></div>' })
|
|
131
181
|
* export class HeroComponent implements AfterViewInit, OnDestroy {
|
|
132
182
|
* @ViewChild('container') containerRef!: ElementRef<HTMLElement>;
|
|
@@ -134,22 +184,141 @@ interface ScrollDrawInstance {
|
|
|
134
184
|
*
|
|
135
185
|
* ngAfterViewInit() {
|
|
136
186
|
* this.draw.init(this.containerRef.nativeElement, {
|
|
137
|
-
* easing: 'ease-out',
|
|
138
|
-
* speed: 1.2,
|
|
139
|
-
* fade: true,
|
|
187
|
+
* easing: 'ease-out', speed: 1.2, fade: true,
|
|
140
188
|
* });
|
|
141
189
|
* }
|
|
142
190
|
*
|
|
143
191
|
* ngOnDestroy() { this.draw.destroy(); }
|
|
144
|
-
*
|
|
145
|
-
* replay() { this.draw.replay(); }
|
|
146
192
|
* }
|
|
147
193
|
*/
|
|
148
194
|
declare class ScrollDrawRef {
|
|
149
195
|
private instance;
|
|
150
196
|
init(element: HTMLElement, options?: ScrollDrawOptions): this;
|
|
151
197
|
replay(): this;
|
|
198
|
+
pause(): this;
|
|
199
|
+
resume(): this;
|
|
200
|
+
seek(p: number): this;
|
|
201
|
+
getProgress(): number;
|
|
202
|
+
destroy(): this;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Animate any CSS property on any element driven by scroll — Angular class-based API.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* @Component({ template: '<div #el>...</div>' })
|
|
209
|
+
* export class CardComponent implements AfterViewInit, OnDestroy {
|
|
210
|
+
* @ViewChild('el') elRef!: ElementRef<HTMLElement>;
|
|
211
|
+
* private animate = new ScrollAnimateRef();
|
|
212
|
+
*
|
|
213
|
+
* ngAfterViewInit() {
|
|
214
|
+
* this.animate.init(this.elRef.nativeElement, {
|
|
215
|
+
* props: { opacity: [0, 1], transform: ['translateY(40px)', 'translateY(0)'] },
|
|
216
|
+
* easing: 'ease-out',
|
|
217
|
+
* once: true,
|
|
218
|
+
* });
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* ngOnDestroy() { this.animate.destroy(); }
|
|
222
|
+
* }
|
|
223
|
+
*/
|
|
224
|
+
declare class ScrollAnimateRef {
|
|
225
|
+
private instance;
|
|
226
|
+
init(element: HTMLElement, options: ScrollAnimateOptions): this;
|
|
227
|
+
replay(): this;
|
|
228
|
+
pause(): this;
|
|
229
|
+
resume(): this;
|
|
230
|
+
seek(p: number): this;
|
|
231
|
+
getProgress(): number;
|
|
232
|
+
destroy(): this;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Animate a number from `from` to `to` as the element scrolls into view — Angular class-based API.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* @Component({ template: '<span #counter></span>' })
|
|
239
|
+
* export class StatsComponent implements AfterViewInit, OnDestroy {
|
|
240
|
+
* @ViewChild('counter') counterRef!: ElementRef<HTMLElement>;
|
|
241
|
+
* private counter = new ScrollCounterRef();
|
|
242
|
+
*
|
|
243
|
+
* ngAfterViewInit() {
|
|
244
|
+
* this.counter.init(this.counterRef.nativeElement, {
|
|
245
|
+
* to: 1_250_000,
|
|
246
|
+
* format: n => '$' + Math.round(n).toLocaleString(),
|
|
247
|
+
* once: true,
|
|
248
|
+
* });
|
|
249
|
+
* }
|
|
250
|
+
*
|
|
251
|
+
* ngOnDestroy() { this.counter.destroy(); }
|
|
252
|
+
* }
|
|
253
|
+
*/
|
|
254
|
+
declare class ScrollCounterRef {
|
|
255
|
+
private instance;
|
|
256
|
+
init(element: HTMLElement, options: ScrollCounterOptions): this;
|
|
257
|
+
replay(): this;
|
|
258
|
+
pause(): this;
|
|
259
|
+
resume(): this;
|
|
260
|
+
seek(p: number): this;
|
|
261
|
+
getProgress(): number;
|
|
262
|
+
destroy(): this;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Tie a <video> element's currentTime to scroll — Angular class-based API.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* @Component({ template: '<video #vid src="/hero.mp4" muted playsinline preload="auto"></video>' })
|
|
269
|
+
* export class HeroVideoComponent implements AfterViewInit, OnDestroy {
|
|
270
|
+
* @ViewChild('vid') vidRef!: ElementRef<HTMLVideoElement>;
|
|
271
|
+
* private video = new ScrollVideoRef();
|
|
272
|
+
*
|
|
273
|
+
* ngAfterViewInit() {
|
|
274
|
+
* this.video.init(this.vidRef.nativeElement, {
|
|
275
|
+
* trigger: { start: 'top top', end: 'bottom top' },
|
|
276
|
+
* });
|
|
277
|
+
* }
|
|
278
|
+
*
|
|
279
|
+
* ngOnDestroy() { this.video.destroy(); }
|
|
280
|
+
* }
|
|
281
|
+
*/
|
|
282
|
+
declare class ScrollVideoRef {
|
|
283
|
+
private instance;
|
|
284
|
+
init(element: HTMLVideoElement, options?: ScrollVideoOptions): this;
|
|
285
|
+
replay(): this;
|
|
286
|
+
pause(): this;
|
|
287
|
+
resume(): this;
|
|
288
|
+
seek(p: number): this;
|
|
289
|
+
getProgress(): number;
|
|
290
|
+
destroy(): this;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Split text and stagger-animate each piece on scroll — Angular class-based API.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* @Component({ template: '<h2 #headline>Animate on scroll.</h2>' })
|
|
297
|
+
* export class HeroComponent implements AfterViewInit, OnDestroy {
|
|
298
|
+
* @ViewChild('headline') headlineRef!: ElementRef<HTMLElement>;
|
|
299
|
+
* private text = new ScrollTextRef();
|
|
300
|
+
*
|
|
301
|
+
* ngAfterViewInit() {
|
|
302
|
+
* this.text.init(this.headlineRef.nativeElement, {
|
|
303
|
+
* split: 'words',
|
|
304
|
+
* stagger: 0.05,
|
|
305
|
+
* from: { opacity: 0, y: 24 },
|
|
306
|
+
* once: true,
|
|
307
|
+
* });
|
|
308
|
+
* }
|
|
309
|
+
*
|
|
310
|
+
* ngOnDestroy() { this.text.destroy(); }
|
|
311
|
+
* }
|
|
312
|
+
*/
|
|
313
|
+
declare class ScrollTextRef {
|
|
314
|
+
private instance;
|
|
315
|
+
init(element: HTMLElement, options?: ScrollTextOptions): this;
|
|
316
|
+
replay(): this;
|
|
317
|
+
pause(): this;
|
|
318
|
+
resume(): this;
|
|
319
|
+
seek(p: number): this;
|
|
320
|
+
getProgress(): number;
|
|
152
321
|
destroy(): this;
|
|
153
322
|
}
|
|
154
323
|
|
|
155
|
-
export { type ScrollDrawInstance, type ScrollDrawOptions, ScrollDrawRef };
|
|
324
|
+
export { type ScrollAnimateOptions, ScrollAnimateRef, type ScrollCounterOptions, ScrollCounterRef, type ScrollDrawInstance, type ScrollDrawOptions, ScrollDrawRef, type ScrollTextOptions, ScrollTextRef, type ScrollVideoOptions, ScrollVideoRef };
|
package/dist/angular/index.d.ts
CHANGED
|
@@ -119,14 +119,64 @@ interface ScrollDrawInstance {
|
|
|
119
119
|
getProgress: () => number;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
interface ScrollAnimateOptions {
|
|
123
|
+
props: Record<string, string | number | [string | number, string | number]>;
|
|
124
|
+
trigger?: TriggerConfig;
|
|
125
|
+
easing?: EasingName | ((t: number) => number);
|
|
126
|
+
speed?: number;
|
|
127
|
+
once?: boolean;
|
|
128
|
+
axis?: 'x' | 'y';
|
|
129
|
+
scrollContainer?: string | Element;
|
|
130
|
+
native?: boolean;
|
|
131
|
+
onProgress?: (alpha: number) => void;
|
|
132
|
+
onComplete?: () => void;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface ScrollCounterOptions {
|
|
136
|
+
from?: number;
|
|
137
|
+
to: number;
|
|
138
|
+
format?: (value: number) => string;
|
|
139
|
+
easing?: EasingName | ((t: number) => number);
|
|
140
|
+
trigger?: TriggerConfig;
|
|
141
|
+
once?: boolean;
|
|
142
|
+
decimals?: number;
|
|
143
|
+
onComplete?: () => void;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface ScrollVideoOptions {
|
|
147
|
+
trigger?: TriggerConfig;
|
|
148
|
+
from?: number;
|
|
149
|
+
to?: number;
|
|
150
|
+
easing?: EasingName | ((t: number) => number);
|
|
151
|
+
once?: boolean;
|
|
152
|
+
axis?: 'x' | 'y';
|
|
153
|
+
preload?: 'auto' | 'metadata';
|
|
154
|
+
onReady?: () => void;
|
|
155
|
+
onComplete?: () => void;
|
|
156
|
+
onProgress?: (alpha: number) => void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface ScrollTextOptions {
|
|
160
|
+
split?: 'chars' | 'words' | 'lines';
|
|
161
|
+
stagger?: number;
|
|
162
|
+
easing?: EasingName | ((t: number) => number);
|
|
163
|
+
from?: {
|
|
164
|
+
opacity?: number;
|
|
165
|
+
y?: number;
|
|
166
|
+
x?: number;
|
|
167
|
+
rotate?: number;
|
|
168
|
+
scale?: number;
|
|
169
|
+
};
|
|
170
|
+
trigger?: TriggerConfig;
|
|
171
|
+
once?: boolean;
|
|
172
|
+
onComplete?: () => void;
|
|
173
|
+
}
|
|
174
|
+
|
|
122
175
|
/**
|
|
123
176
|
* Framework-agnostic class for use in Angular components.
|
|
124
177
|
* No @angular/core dependency required.
|
|
125
178
|
*
|
|
126
179
|
* @example
|
|
127
|
-
* // In your Angular component:
|
|
128
|
-
* import { ScrollDrawRef } from 'svg-scroll-draw/angular';
|
|
129
|
-
*
|
|
130
180
|
* @Component({ template: '<div #container><svg>...</svg></div>' })
|
|
131
181
|
* export class HeroComponent implements AfterViewInit, OnDestroy {
|
|
132
182
|
* @ViewChild('container') containerRef!: ElementRef<HTMLElement>;
|
|
@@ -134,22 +184,141 @@ interface ScrollDrawInstance {
|
|
|
134
184
|
*
|
|
135
185
|
* ngAfterViewInit() {
|
|
136
186
|
* this.draw.init(this.containerRef.nativeElement, {
|
|
137
|
-
* easing: 'ease-out',
|
|
138
|
-
* speed: 1.2,
|
|
139
|
-
* fade: true,
|
|
187
|
+
* easing: 'ease-out', speed: 1.2, fade: true,
|
|
140
188
|
* });
|
|
141
189
|
* }
|
|
142
190
|
*
|
|
143
191
|
* ngOnDestroy() { this.draw.destroy(); }
|
|
144
|
-
*
|
|
145
|
-
* replay() { this.draw.replay(); }
|
|
146
192
|
* }
|
|
147
193
|
*/
|
|
148
194
|
declare class ScrollDrawRef {
|
|
149
195
|
private instance;
|
|
150
196
|
init(element: HTMLElement, options?: ScrollDrawOptions): this;
|
|
151
197
|
replay(): this;
|
|
198
|
+
pause(): this;
|
|
199
|
+
resume(): this;
|
|
200
|
+
seek(p: number): this;
|
|
201
|
+
getProgress(): number;
|
|
202
|
+
destroy(): this;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Animate any CSS property on any element driven by scroll — Angular class-based API.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* @Component({ template: '<div #el>...</div>' })
|
|
209
|
+
* export class CardComponent implements AfterViewInit, OnDestroy {
|
|
210
|
+
* @ViewChild('el') elRef!: ElementRef<HTMLElement>;
|
|
211
|
+
* private animate = new ScrollAnimateRef();
|
|
212
|
+
*
|
|
213
|
+
* ngAfterViewInit() {
|
|
214
|
+
* this.animate.init(this.elRef.nativeElement, {
|
|
215
|
+
* props: { opacity: [0, 1], transform: ['translateY(40px)', 'translateY(0)'] },
|
|
216
|
+
* easing: 'ease-out',
|
|
217
|
+
* once: true,
|
|
218
|
+
* });
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* ngOnDestroy() { this.animate.destroy(); }
|
|
222
|
+
* }
|
|
223
|
+
*/
|
|
224
|
+
declare class ScrollAnimateRef {
|
|
225
|
+
private instance;
|
|
226
|
+
init(element: HTMLElement, options: ScrollAnimateOptions): this;
|
|
227
|
+
replay(): this;
|
|
228
|
+
pause(): this;
|
|
229
|
+
resume(): this;
|
|
230
|
+
seek(p: number): this;
|
|
231
|
+
getProgress(): number;
|
|
232
|
+
destroy(): this;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Animate a number from `from` to `to` as the element scrolls into view — Angular class-based API.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* @Component({ template: '<span #counter></span>' })
|
|
239
|
+
* export class StatsComponent implements AfterViewInit, OnDestroy {
|
|
240
|
+
* @ViewChild('counter') counterRef!: ElementRef<HTMLElement>;
|
|
241
|
+
* private counter = new ScrollCounterRef();
|
|
242
|
+
*
|
|
243
|
+
* ngAfterViewInit() {
|
|
244
|
+
* this.counter.init(this.counterRef.nativeElement, {
|
|
245
|
+
* to: 1_250_000,
|
|
246
|
+
* format: n => '$' + Math.round(n).toLocaleString(),
|
|
247
|
+
* once: true,
|
|
248
|
+
* });
|
|
249
|
+
* }
|
|
250
|
+
*
|
|
251
|
+
* ngOnDestroy() { this.counter.destroy(); }
|
|
252
|
+
* }
|
|
253
|
+
*/
|
|
254
|
+
declare class ScrollCounterRef {
|
|
255
|
+
private instance;
|
|
256
|
+
init(element: HTMLElement, options: ScrollCounterOptions): this;
|
|
257
|
+
replay(): this;
|
|
258
|
+
pause(): this;
|
|
259
|
+
resume(): this;
|
|
260
|
+
seek(p: number): this;
|
|
261
|
+
getProgress(): number;
|
|
262
|
+
destroy(): this;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Tie a <video> element's currentTime to scroll — Angular class-based API.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* @Component({ template: '<video #vid src="/hero.mp4" muted playsinline preload="auto"></video>' })
|
|
269
|
+
* export class HeroVideoComponent implements AfterViewInit, OnDestroy {
|
|
270
|
+
* @ViewChild('vid') vidRef!: ElementRef<HTMLVideoElement>;
|
|
271
|
+
* private video = new ScrollVideoRef();
|
|
272
|
+
*
|
|
273
|
+
* ngAfterViewInit() {
|
|
274
|
+
* this.video.init(this.vidRef.nativeElement, {
|
|
275
|
+
* trigger: { start: 'top top', end: 'bottom top' },
|
|
276
|
+
* });
|
|
277
|
+
* }
|
|
278
|
+
*
|
|
279
|
+
* ngOnDestroy() { this.video.destroy(); }
|
|
280
|
+
* }
|
|
281
|
+
*/
|
|
282
|
+
declare class ScrollVideoRef {
|
|
283
|
+
private instance;
|
|
284
|
+
init(element: HTMLVideoElement, options?: ScrollVideoOptions): this;
|
|
285
|
+
replay(): this;
|
|
286
|
+
pause(): this;
|
|
287
|
+
resume(): this;
|
|
288
|
+
seek(p: number): this;
|
|
289
|
+
getProgress(): number;
|
|
290
|
+
destroy(): this;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Split text and stagger-animate each piece on scroll — Angular class-based API.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* @Component({ template: '<h2 #headline>Animate on scroll.</h2>' })
|
|
297
|
+
* export class HeroComponent implements AfterViewInit, OnDestroy {
|
|
298
|
+
* @ViewChild('headline') headlineRef!: ElementRef<HTMLElement>;
|
|
299
|
+
* private text = new ScrollTextRef();
|
|
300
|
+
*
|
|
301
|
+
* ngAfterViewInit() {
|
|
302
|
+
* this.text.init(this.headlineRef.nativeElement, {
|
|
303
|
+
* split: 'words',
|
|
304
|
+
* stagger: 0.05,
|
|
305
|
+
* from: { opacity: 0, y: 24 },
|
|
306
|
+
* once: true,
|
|
307
|
+
* });
|
|
308
|
+
* }
|
|
309
|
+
*
|
|
310
|
+
* ngOnDestroy() { this.text.destroy(); }
|
|
311
|
+
* }
|
|
312
|
+
*/
|
|
313
|
+
declare class ScrollTextRef {
|
|
314
|
+
private instance;
|
|
315
|
+
init(element: HTMLElement, options?: ScrollTextOptions): this;
|
|
316
|
+
replay(): this;
|
|
317
|
+
pause(): this;
|
|
318
|
+
resume(): this;
|
|
319
|
+
seek(p: number): this;
|
|
320
|
+
getProgress(): number;
|
|
152
321
|
destroy(): this;
|
|
153
322
|
}
|
|
154
323
|
|
|
155
|
-
export { type ScrollDrawInstance, type ScrollDrawOptions, ScrollDrawRef };
|
|
324
|
+
export { type ScrollAnimateOptions, ScrollAnimateRef, type ScrollCounterOptions, ScrollCounterRef, type ScrollDrawInstance, type ScrollDrawOptions, ScrollDrawRef, type ScrollTextOptions, ScrollTextRef, type ScrollVideoOptions, ScrollVideoRef };
|