2 lines
5.9 KiB
JavaScript
Raw Permalink Normal View History

2025-06-21 23:30:33 +03:00
"function"==typeof SuppressedError&&SuppressedError;const t=new WeakMap;let e;function n({target:e,contentRect:n,borderBoxSize:o}){var r;null===(r=t.get(e))||void 0===r||r.forEach((t=>{t({target:e,contentSize:n,get size(){return function(t,e){if(e){const{inlineSize:t,blockSize:n}=e[0];return{width:t,height:n}}return t instanceof SVGElement&&"getBBox"in t?t.getBBox():{width:t.offsetWidth,height:t.offsetHeight}}(e,o)}})}))}function o(t){t.forEach(n)}function r(n,r){e||"undefined"!=typeof ResizeObserver&&(e=new ResizeObserver(o));const i=function(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t||[])}(n);return i.forEach((n=>{let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(r),null==e||e.observe(n)})),()=>{i.forEach((n=>{const o=t.get(n);null==o||o.delete(r),(null==o?void 0:o.size)||null==e||e.unobserve(n)}))}}const i=new Set;let s;function c(t){return i.add(t),s||(s=()=>{const t={width:window.innerWidth,height:window.innerHeight},e={target:window,size:t,contentSize:t};i.forEach((t=>t(e)))},window.addEventListener("resize",s)),()=>{i.delete(t),!i.size&&s&&(s=void 0)}}const f=(t,e,n)=>Math.min(Math.max(n,t),e),l=t=>"number"==typeof t,a=t=>Array.isArray(t)&&!l(t[0]),u=(t,e,n)=>{const o=e-t;return((n-t)%o+o)%o+t};const g=(t,e,n)=>-n*t+n*e+t,h=t=>t,d=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function p(t,e){const n=t[t.length-1];for(let o=1;o<=e;o++){const r=d(0,e,o);t.push(g(n,1,r))}}function m(t){const e=[0];return p(e,t-1),e}function y(t,e=m(t.length),n=h){const o=t.length,r=o-e.length;return r>0&&p(e,r),r=>{let i=0;for(;i<o-2&&!(r<e[i+1]);i++);let s=f(0,1,d(e[i],e[i+1],r));const c=function(t,e){return a(t)?t[u(0,t.length,e)]:t}(n,i);return s=c(s),g(t[i],t[i+1],s)}}const v=t=>"function"==typeof t,w=t=>"string"==typeof t;const E=50,x={x:{length:"Width",position:"Left"},y:{length:"Height",position:"Top"}};function L(t,e,n,o){const r=n[e],{length:i,position:s}=x[e],c=r.current,f=n.time;r.current=t[`scroll${s}`],r.scrollLength=t[`scroll${i}`]-t[`client${i}`],r.offset.length=0,r.offset[0]=0,r.offset[1]=r.scrollLength,r.progress=d(0,r.scrollLength,r.current);const l=o-f;var a,u;r.velocity=l>E?0:(a=r.current-c,(u=l)?a*(1e3/u):0)}const O={Enter:[[0,1],[1,1]],Exit:[[0,0],[1,0]],Any:[[1,0],[0,1]],All:[[0,0],[1,1]]},W={start:0,center:.5,end:1};function S(t,e,n=0){let o=0;if(void 0!==W[t]&&(t=W[t]),w(t)){const e=parseFloat(t);t.endsWith("px")?o=e:t.endsWith("%")?t=e/100:t.endsWith("vw")?o=e/100*document.documentElement.clientWidth:t.endsWith("vh")?o=e/100*document.documentElement.clientHeight:t=e}return l(t)&&(o=e*t),n+o}const z=[0,0];function b(t,e,n,o){let r=Array.isArray(t)?t:z,i=0,s=0;return l(t)?r=[t,t]:w(t)&&(r=(t=t.trim()).includes(" ")?t.split(" "):[t,W[t]?t:"0"]),i=S(r[0],n,o),s=S(r[1],e),i-s}const A={x:0,y:0};function H(t,e,n){let{offset:o=O.All}=n;const{target:r=t,axis:i="y"}=n,s="y"===i?"height":"width",c=r!==t?function(t,e){let n={x:0,y:0},o=t;for(;o&&o!==e;)if(o instanceof HTMLElement)n.x+=o.offsetLeft,n.y+=o.offsetTop,o=o.offsetParent;else if(o instanceof SVGGraphicsElement&&"getBBox"in o){const{top:t,left:e}=o.getBBox();for(n.x+=e,n.y+=t;o&&"svg"!==o.tagName;)o=o.parentNode}return n}(r,t):A,f=r===t?{width:t.scrollWidth,height:t.scrollHeight}:{width:r.clientWidth,height:r.clientHeight},l={width:t.clientWidth,height:t.clientHeight};e[i].offset.length=0;let a=!e[i].interpolate;const u=o.length;for(let t=0;t<u;t++){const n=b(o[t],l[s],f[s],c[i]);a||n===e[i].interpolatorOffsets[t]||(a=!0),e[i].offset[t]=n}a&&(e[i].interpolate=y(m(u),e[i].offset),e[i].interpolatorOffsets=[...e[i].offset]),e[i].progress=e[i].interpolate(e[i].current)}function B(t,e,n,o={}){const r=o.axis||"y";return{measure:()=>function(t,e=t,n){if(n.x.targetOffset=0,n.y.targetOffset=0,e!==t){let o=e;for(;o&&o!=t;)n.x.targetOffset+=o.offsetLeft,n.y.targetOffset+=o.offsetTop,o=o.offsetParent}n.x.targetLength=e===t?e.scrollWidth:e.clientWidth,n.y.targetLength=e===t?e.scrollHeight:e.clientHeight,n.x.containerLength=t.clientWidth,n.y.containerL