// home-ending.jsx: slides over the pinned carousel; tidy grid comes apart into a drifting desaturated wall // with a lens spotlight; headline + "Start a project" card. const END_RATIOS = ['9 / 16', '4 / 5', '9 / 16', '3 / 4', '9 / 16', '4 / 5', '3 / 4', '9 / 16']; const END_SPEEDS = [-0.55, 0.25, -0.85, 0.05, -0.45, 0.6], END_STARTS = [-0.16, -0.04, -0.24, -0.1, -0.2, -0.02]; function Ending() { const C = (window.SITE_CONTENT && window.SITE_CONTENT.ending) || {}; const { W, H, mobile: mob } = useViewport(); const secRef = React.useRef(null), stageRef = React.useRef(null), washRef = React.useRef(null), lensRef = React.useRef(null), ringRef = React.useRef(null), titleRef = React.useRef(null); const S = React.useRef({ mob, ptr: { x: 0, y: 0, in: false }, drift: 0 }).current; S.mob = mob; const gap = mob ? 6 : 10, ncol = mob ? 3 : 6; const cols = React.useMemo(() => Array.from({ length: ncol }, (_, i) => { const base = Array.from({ length: 6 }, (_, k) => { const c = LL.CLIPS[(i * 4 + k * 7 + (i % 2) * 2) % LL.CLIPS.length]; return { id: c.id, poster: c.poster, ratio: END_RATIOS[(i + k * 2) % END_RATIOS.length] }; }); return [...base, ...base]; }), [ncol]); React.useEffect(() => { const sec = secRef.current; Engine.invalidate(sec); LL.decorate(sec); S.loop = [...sec.querySelectorAll('[data-mcol]')].map((c) => c.scrollHeight / 2 + gap / 2); }, [mob, W]); // scroll settle: glide to the nearest fully-played state (lens wall, 'Start a project') React.useEffect(() => Engine.snap(secRef.current, [0, 0.7]), []); React.useEffect(() => { const w = Engine.w, qa = Engine.qa, red = LL.REDUCED; return Engine.add((dt, now, n) => { const sec = secRef.current, st = stageRef.current; if (!sec || !st || !Engine.vis(sec)) return; const Wd = st.clientWidth, Hd = st.clientHeight, mobile = S.mob; if (!S.loop || !S.loop[0]) S.loop = qa(sec, '[data-mcol]').map((c) => c.scrollHeight / 2 + (mobile ? 6 : 10) / 2); const p = Engine.prog(sec); if (!S.pos) { S.pos = { x: new LL.Spring(Wd / 2, 70, 13), y: new LL.Spring(Hd / 2, 70, 13) }; S.rad = new LL.Spring(0, 90, 14); } const apart = red ? (p > 0.4 ? 1 : 0) : LL.easeInOut(LL.range(p, 0.04, 0.5)); if (!red) S.drift += dt * (mobile ? 22 : 12) * apart; const cs = qa(sec, '[data-mcol]'), lcs = qa(sec, '[data-lmcol]'); cs.forEach((c, i) => { const L = S.loop[i] || 1000, dir = i % 2 ? 1 : -1; let y = END_STARTS[i % 6] * Hd + dir * S.drift * (1 + (i % 3) * 0.25); y += END_SPEEDS[i % 6] * LL.range(p, 0, 0.7) * Hd * (mobile ? 0.5 : 1); y = ((y % L) + L) % L - L; const tf = `translate3d(0,${LL.lerp(16 - L, y, apart).toFixed(1)}px,0)`; w(c, 'transform', tf); if (lcs[i]) w(lcs[i], 'transform', tf); }); w(washRef.current, 'opacity', (0.52 * apart).toFixed(3)); const tt = titleRef.current; if (tt) { const e = red ? (p > 0.4 ? 1 : 0) : LL.easeOut(LL.range(p, 0.32, 0.62)); w(tt, 'opacity', e.toFixed(3)); w(tt.firstElementChild, 'transform', `translateY(${((1 - e) * 40).toFixed(1)}px)`); w(tt.lastElementChild, 'transform', `translateY(${((1 - e) * 60).toFixed(1)}px) rotate(-1.5deg)`); w(tt, 'visibility', e <= 0 ? 'hidden' : 'visible'); } let tx = S.ptr.in ? S.ptr.x : Wd / 2 + Math.sin(now / 3100) * Wd * 0.18, ty = S.ptr.in ? S.ptr.y : Hd * 0.5 + Math.cos(now / 2300) * Hd * 0.14; if (mobile) { tx = Wd / 2; ty = Hd * 0.5; } S.pos.x.t = tx; S.pos.y.t = ty; if (red) { S.pos.x.x = tx; S.pos.y.x = ty; } else { S.pos.x.step(dt); S.pos.y.step(dt); } const x = S.pos.x.x, y = S.pos.y.x; S.rad.t = (mobile ? Math.min(Wd * 0.36, 150) : Math.min(170, Wd * 0.12)) * LL.range(apart, 0.5, 1); if (red) S.rad.x = S.rad.t; else S.rad.step(dt); const r = Math.max(0, S.rad.x); const cr = LL.lerp(Math.hypot(Wd, Hd), r, LL.smooth(LL.range(apart, 0, 0.7))); w(lensRef.current, 'clipPath', `circle(${cr.toFixed(0)}px at ${x.toFixed(0)}px ${y.toFixed(0)}px)`); w(ringRef.current, 'opacity', r > 4 ? '1' : '0'); w(ringRef.current, 'transform', `translate(${x.toFixed(1)}px,${y.toFixed(1)}px) scale(${(r / 100).toFixed(4)})`); if (n % 6 === 0 && apart > 0.6) { const sr = st.getBoundingClientRect(); qa(sec, '[data-ltile]').forEach((el) => { const b = el.getBoundingClientRect(), lx = b.left - sr.left, ly = b.top - sr.top; const nx = LL.clamp(x, lx, lx + b.width), ny = LL.clamp(y, ly, ly + b.height); (r > 4 && Math.hypot(nx - x, ny - y) < r) ? LL.clip(el).play() : LL.clip(el).pause(); }); } }); }, []); return (
); } Object.assign(window, { Ending });