// home-work.jsx: Recent work. Film strips + magnifier develop into the carousel (FLIP), with filters. // Carousel is 9:16, auto-scrolls at 90px/s, doubled list for looping. // Film stock: all brown (Lamia, edit request 3ffe1421), a few shades so the strips still read apart. const WORK_STOCKS = ['var(--ink)', '#5A3A27', '#4A2C1D', '#634230', 'var(--ink)']; const WORK_TILTS = [-3.5, 2.5, -1.5, 3, -2.5]; function Work() { const C = (window.SITE_CONTENT && window.SITE_CONTENT.work) || {}; const hero = (window.SITE_CONTENT && window.SITE_CONTENT.hero) || {}; const rotating = hero.rotating || ['UGC', 'Events', 'Travel']; const FIL = C.filters || ['All', 'UGC', 'Events', 'Brand Content']; const { W, H, mobile: mob } = useViewport(); const secRef = React.useRef(null), stageRef = React.useRef(null), labelRef = React.useRef(null), carWrapRef = React.useRef(null), carRef = React.useRef(null), trackRef = React.useRef(null); const flipRef = React.useRef(null), ringRef = React.useRef(null), magRef = React.useRef(null), magClipRef = React.useRef(null), magImgRef = React.useRef(null), magTagRef = React.useRef(null), cueRef = React.useRef(null), stripsRef = React.useRef(null); const [filter, setFilterState] = React.useState(FIL[0]); const [active, setActive] = React.useState(null); const [cat, setCat] = React.useState(0); const [paused, setPaused] = React.useState(false); const [sound, setSoundState] = React.useState(false); const S = React.useRef({ mob, ptr: { x: 0, y: 0, in: false }, carOff: 0, manual: false, off: [], spd: [], hover: null, zoom: null, active: null, filter: FIL[0], sound: false }).current; S.mob = mob; S.active = active; S.filter = filter; const reels = React.useMemo(() => LL.CLIPS.filter((c) => c.video), []); const filtered = filter === FIL[0] ? reels : reels.filter((r) => r.label === filter); let looped = filtered.slice(); while (looped.length && looped.length < 8) looped = looped.concat(filtered); const cards = [...looped, ...looped]; React.useEffect(() => LL.rotate(rotating.length, setCat, 2600), []); // strips const ns = mob ? 2 : 5, fw = mob ? Math.min(W * 0.3, 120) : Math.min(W * 0.105, 156), m = Math.round(fw * 0.15), sw = Math.round(fw + m * 2); const xs = mob ? [W * 0.2, W * 0.8] : Array.from({ length: ns }, (_, i) => W / ns * (i + 0.5)); const strips = Array.from({ length: ns }, (_, i) => { const base = Array.from({ length: 7 }, (_, k) => { const c = reels[(i * 3 + k * (mob ? 2 : 1)) % reels.length]; return { id: c.id, poster: c.poster, title: c.title, num: (i + 1) * 10 + k + (k % 2 ? 'A' : '') }; }); return { i, x: Math.round(xs[i] - sw / 2), w: sw, m, hole: Math.round(m * 0.22), hw: Math.max(5, Math.round(m * 0.5)), stock: WORK_STOCKS[mob ? i * 2 : i], tilt: WORK_TILTS[i], frames: [...base, ...base] }; }); const measure = () => { const sec = secRef.current; if (!sec) return; S.loop = [...sec.querySelectorAll('[data-track]')].map((t) => t.scrollHeight / 2); S.off = S.loop.map((L, i) => -L * (0.15 + 0.17 * i)); }; React.useEffect(() => { Engine.invalidate(secRef.current); LL.decorate(secRef.current); measure(); S.captured = null; }, [mob, W]); const setMag = (frame) => { const mc = magClipRef.current, mi = magImgRef.current; if (S.hover === frame) return; if (S.magCtl) S.magCtl.pause(); S.hover = frame; if (!frame || !mc) return; mc.setAttribute('data-clip', frame.getAttribute('data-clip')); mi.src = frame.getAttribute('data-poster'); if (mc._ll) { mc._ll.pause(); delete mc._ll; } mi.getAnimations().forEach((a) => a.cancel()); S.magCtl = LL.clip(mc); S.magCtl.play(); magTagRef.current.textContent = frame.getAttribute('data-num') + ' · ' + frame.getAttribute('data-title'); }; const capture = () => { const st = stageRef.current, sr = st.getBoundingClientRect(); const vis = []; [...trackRef.current.children].forEach((c) => { const b = c.getBoundingClientRect(); if (b.right > sr.left + 4 && b.left < sr.right - 4 && vis.length < 7) vis.push({ el: c, b }); }); const frames = [...st.querySelectorAll('[data-frame]')].map((f) => ({ f, b: f.getBoundingClientRect(), id: f.getAttribute('data-clip') })).filter((o) => o.b.bottom > sr.top && o.b.top < sr.bottom); const used = new Set(), picks = []; vis.forEach((v) => { const id = v.el.getAttribute('data-id'), cx = v.b.left + v.b.width / 2; let best = null, bd = 1e9; frames.forEach((o) => { if (used.has(o.f)) return; const d = Math.abs(o.b.left + o.b.width / 2 - cx) + Math.abs(o.b.top + o.b.height / 2 - (sr.top + sr.height / 2)) * 0.6 + (o.id === id ? 0 : 5000); if (d < bd) { bd = d; best = o; } }); if (!best) return; used.add(best.f); picks.push({ from: { x: best.b.left - sr.left, y: best.b.top - sr.top, w: best.b.width, h: best.b.height }, to: { x: v.b.left - sr.left, y: v.b.top - sr.top, w: v.b.width, h: v.b.height }, src: best.f.getAttribute('data-poster'), dst: v.el.getAttribute('data-poster'), same: best.id === id }); }); [...flipRef.current.querySelectorAll('[data-flip]')].forEach((fl, i) => { const pk = picks[i]; fl.style.display = pk ? 'block' : 'none'; if (!pk) return; fl.querySelector('[data-fa]').src = pk.src; const fb = fl.querySelector('[data-fb]'); fb.src = pk.dst; fb.style.opacity = 0; pk.fb = fb; pk.el = fl; pk.fin = fl.querySelector('[data-fin]'); }); S.captured = picks; }; const slide = (delta, ms) => { const track = trackRef.current; if (!track) return; const half = track.scrollWidth / 2; let next = S.carOff + delta; if (next < 0) next += half; if (next >= half) next -= half; S.carOff = next; S.manual = true; track.style.transition = `transform ${ms}ms cubic-bezier(.2,.7,.2,1)`; track.style.transform = `translateX(-${next}px)`; clearTimeout(S.slideT); S.slideT = setTimeout(() => { track.style.transition = ''; S.manual = false; }, ms + 30); }; const clipOf = (el) => el && el.querySelector('[data-clip]'); const deactivate = () => { const c = clipOf(S.activeEl); c && LL.clip(c).pause(); S.activeEl = null; S.active = null; S.paused = false; setActive(null); setPaused(false); }; // Click on the playing card: freeze it and offer the matching service page. const hold = (el) => { const c = clipOf(el); c && LL.clip(c).hold(); S.paused = true; setPaused(true); }; const resume = (el) => { const c = clipOf(el); c && LL.clip(c).resume(); S.paused = false; setPaused(false); }; const setSound = (on) => { S.sound = on; setSoundState(on); const c = clipOf(S.activeEl); c && LL.clip(c).sound(on); }; const activate = (i, el) => { if (!el) return; if (S.activeEl && S.activeEl !== el) { const c = clipOf(S.activeEl); c && LL.clip(c).pause(); } S.activeEl = el; S.paused = false; setPaused(false); const c = clipOf(el); if (c) { const ctl = LL.clip(c); ctl.sound(S.sound); ctl.onBlocked = () => { S.sound = false; setSoundState(false); }; ctl.play(); } S.active = i; setActive(i); const car = carRef.current; if (!car) return; const rr = el.getBoundingClientRect(), cr = car.getBoundingClientRect(), extra = (rr.width * 1.1 - rr.width) / 2; let delta = 0; if (rr.left - extra < cr.left) delta = rr.left - extra - cr.left - 12; else if (rr.right + extra > cr.right) delta = rr.right + extra - cr.right + 12; if (delta) slide(delta, 450); }; const setFilter = (f) => { if (S.filter === f) return; const track = trackRef.current; if (S.active != null) deactivate(); const swap = () => { setFilterState(f); S.filter = f; requestAnimationFrame(() => requestAnimationFrame(() => { S.carOff = 0; if (!track) return; track.style.transition = ''; track.style.transform = 'translateX(0px)'; if (LL.REDUCED) return; [...track.children].slice(0, 8).forEach((c, i) => c.animate([{ opacity: 0, transform: 'translateY(26px) scale(.94) rotate(' + (i % 2 ? 2 : -2) + 'deg)' }, { opacity: 1, transform: 'none' }], { duration: 650, delay: i * 55, easing: LL.EASE.spring, fill: 'backwards' })); })); }; if (!track || LL.REDUCED) return swap(); const a = track.animate([{ opacity: 1 }, { opacity: 0, transform: `translateX(-${S.carOff}px) translateY(-10px)` }], { duration: 180, easing: 'ease-in', fill: 'forwards' }); a.onfinish = () => { swap(); a.cancel(); }; }; const step = (dir) => { const first = trackRef.current && trackRef.current.children[0]; if (first) slide(dir * (first.getBoundingClientRect().width + 14), 500); }; // swipe the carousel on touch: drag the track 1:1 with the finger, snap to the nearest card on release const onSwipeStart = (e) => { if (e.pointerType !== 'touch') return; const track = trackRef.current; if (!track) return; track.setPointerCapture(e.pointerId); S.swipe = { x0: e.clientX, off0: S.carOff, moved: 0 }; S.manual = true; clearTimeout(S.slideT); track.style.transition = ''; }; const onSwipeMove = (e) => { const sw = S.swipe; if (!sw) return; const track = trackRef.current; if (!track) return; const dx = e.clientX - sw.x0; sw.moved = dx; const half = track.scrollWidth / 2; let next = sw.off0 - dx; next = ((next % half) + half) % half; S.carOff = next; track.style.transform = `translateX(-${next}px)`; }; const onSwipeEnd = () => { const sw = S.swipe; if (!sw) return; S.swipe = null; const track = trackRef.current; if (!track) return; const first = track.children[0], cardStep = first ? first.getBoundingClientRect().width + 14 : 0; // snap forward/back exactly one card from where the drag started (not from the dragged // position), so a long drag doesn't overshoot; a short drag just snaps back const target = sw.off0 + (Math.abs(sw.moved) > 30 ? (sw.moved < 0 ? 1 : -1) * cardStep : 0); slide(target - S.carOff, 400); // suppress the synthetic click a drag produces, so swiping doesn't also activate a card if (Math.abs(sw.moved) > 10) S.justSwiped = true; }; React.useEffect(() => { const onDoc = (e) => { if (S.active != null && !(e.target.closest && e.target.closest('[data-rc]'))) deactivate(); }; const onHide = () => { if (document.hidden && S.active != null) deactivate(); }; document.addEventListener('click', onDoc); document.addEventListener('visibilitychange', onHide); return () => { document.removeEventListener('click', onDoc); document.removeEventListener('visibilitychange', onHide); }; }, []); // per-frame // scroll settle: glide to the nearest fully-played state (film strips, finished carousel) React.useEffect(() => Engine.snap(secRef.current, [0, 0.6]), []); React.useEffect(() => { const w = Engine.w, qa = Engine.qa, red = LL.REDUCED; return Engine.add((dt, now) => { const sec = secRef.current, st = stageRef.current; if (!sec || !st) return; if (!Engine.vis(sec)) { if (S.introDone && S.magCtl) S.magCtl.pause(); if (S.active != null) deactivate(); return; } const Wd = st.clientWidth, Hd = st.clientHeight, mobile = S.mob; const praw = Engine.prog(sec), p = Math.min(1, praw / 0.6), cover = LL.range(praw, 0.72, 1); if (!S.loop || !S.loop[0]) measure(); if (!S.pos) { S.pos = { x: new LL.Spring(Wd / 2, 240, 26), y: new LL.Spring(Hd / 2, 240, 26) }; S.rad = new LL.Spring(0, 200, 19); } if (!S.introDone) { S.introDone = true; if (!red) { qa(sec, '[data-strip]').forEach((s, i) => s.animate([{ opacity: 0, transform: `translateY(${i % 2 ? -160 : 160}px) rotate(${s.getAttribute('data-tilt')}deg)` }, { opacity: 1, transform: `rotate(${s.getAttribute('data-tilt')}deg)` }], { duration: 1300, delay: 60 + i * 110, easing: LL.EASE.out, fill: 'backwards' })); const lb = labelRef.current; if (lb) lb.firstElementChild.animate([{ opacity: 0, transform: 'translateY(30px) rotate(-5deg) scale(.92)' }, { opacity: 1, transform: 'none' }], { duration: 1100, delay: 450, easing: LL.EASE.bouncy, fill: 'backwards' }); } } w(st, 'cursor', !mobile && p < 0.15 ? 'none' : 'auto'); const strs = qa(sec, '[data-strip]'), tracks = qa(sec, '[data-track]'); const straight = LL.easeInOut(LL.range(p, 0, 0.18)); const hoverStrip = S.hover ? S.hover.closest('[data-strip]') : null; tracks.forEach((t, i) => { const L = S.loop[i] || 1000, dir = i % 2 ? 1 : -1; const want = red || S.zoom ? 0 : (strs[i] === hoverStrip ? 0 : (mobile ? 20 : 24) + i * 3) * (1 - LL.range(p, 0, 0.12)); S.spd[i] = S.spd[i] == null ? want : LL.lerp(S.spd[i], want, Math.min(1, dt * 4)); S.off[i] = (S.off[i] || 0) + dir * S.spd[i] * dt; w(t, 'transform', `translate3d(0,${(((S.off[i] % L) + L) % L - L).toFixed(1)}px,0)`); w(strs[i], 'transform', `rotate(${(+strs[i].getAttribute('data-tilt') * (1 - straight)).toFixed(3)}deg)`); }); const lb = labelRef.current; if (lb) { const e = LL.range(p, 0.06, 0.22); w(lb, 'opacity', (1 - e).toFixed(3)); w(lb, 'transform', `translate(-50%,calc(-50% - ${(e * 60).toFixed(1)}px)) rotate(-2deg) scale(${(1 - e * 0.08).toFixed(3)})`); w(lb, 'visibility', e >= 1 ? 'hidden' : 'visible'); } w(cueRef.current, 'opacity', (1 - LL.range(p, 0, 0.05)).toFixed(3)); // hand-off to the real carousel const show = red ? p > 0.35 : p >= 0.8; const cw = carWrapRef.current, track = trackRef.current; w(cw, 'transform', cover > 0 && !red ? `translateY(${(-cover * 70).toFixed(1)}px) scale(${(1 - cover * 0.06).toFixed(4)})` : ''); w(cw, 'filter', cover > 0 ? `brightness(${(1 - cover * 0.18).toFixed(3)})` : ''); const he = red ? (show ? 1 : 0) : LL.easeOut(LL.range(p, 0.45, 0.72)); w(cw, 'pointerEvents', show ? 'auto' : 'none'); w(cw.firstElementChild, 'opacity', show ? 1 : he); w(cw.lastElementChild, 'visibility', show ? 'visible' : 'hidden'); if (!show && S.carOff !== 0 && track) { S.carOff = 0; w(track, 'transition', ''); w(track, 'transform', 'translateX(0px)'); if (S.active != null) deactivate(); } const flipOn = p >= 0.18 && !show && !red; if (flipOn && !S.captured) capture(); if (p < 0.18 && S.captured) S.captured = null; w(flipRef.current, 'visibility', flipOn ? 'visible' : 'hidden'); w(stripsRef.current, 'opacity', red ? (show ? 0 : 1) : (1 - LL.range(p, 0.2, 0.34)).toFixed(3)); if (flipOn && S.captured) S.captured.forEach((pk, i) => { const e = LL.easeInOut(LL.range(p, 0.2 + i * 0.03, 0.58 + i * 0.03)); w(pk.el, 'transform', `translate(${LL.lerp(pk.from.x, pk.to.x, e).toFixed(1)}px,${LL.lerp(pk.from.y, pk.to.y, e).toFixed(1)}px)`); w(pk.el, 'width', LL.lerp(pk.from.w, pk.to.w, e).toFixed(1) + 'px'); w(pk.el, 'height', LL.lerp(pk.from.h, pk.to.h, e).toFixed(1) + 'px'); w(pk.el, 'borderRadius', LL.lerp(2, 8, e).toFixed(1) + 'px'); w(pk.el, 'boxShadow', e > 0.96 ? 'none' : ''); w(pk.fin, 'transform', `scale(${LL.lerp(1, 1.22, e).toFixed(4)})`); w(pk.fb, 'opacity', pk.same ? '0' : LL.range(e, 0.25, 0.8).toFixed(3)); }); if (show && track && !S.manual && S.active == null && !red) { const half = track.scrollWidth / 2; S.carOff += 90 * dt; if (half > 0 && S.carOff >= half) S.carOff -= half; w(track, 'transform', `translateX(-${S.carOff.toFixed(1)}px)`); } // magnifier let tx = S.ptr.x, ty = S.ptr.y, R = 0; if (S.zoom) { tx = Wd / 2; ty = Hd * 0.52; R = Math.min(Wd * 0.42, 190); } else if (S.ptr.in && !mobile && p < 0.15) R = S.hover ? 118 : 34; if (p >= 0.15 && S.zoom) { S.zoom = null; setMag(null); } S.pos.x.t = tx; S.pos.y.t = ty; S.rad.t = R; if (red) { S.pos.x.x = tx; S.pos.y.x = ty; S.rad.x = R; } else { S.pos.x.step(dt); S.pos.y.step(dt); S.rad.step(dt); } const x = S.pos.x.x, y = S.pos.y.x, r = Math.max(0, S.rad.x); w(ringRef.current, 'opacity', r > 3 ? '1' : '0'); w(ringRef.current, 'transform', `translate(${x.toFixed(1)}px,${y.toFixed(1)}px) scale(${(r / 100).toFixed(4)})`); const target = S.zoom || S.hover; w(magRef.current, 'opacity', target && r > 30 ? '1' : '0'); if (target && magClipRef.current) { const sr = st.getBoundingClientRect(), b = target.getBoundingClientRect(), mc = magClipRef.current; if (S.zoom) { const wd = 172; w(mc, 'width', wd + 'px'); w(mc, 'height', (wd * 16 / 9) + 'px'); w(mc, 'left', (100 - wd / 2) + 'px'); w(mc, 'top', (100 - wd * 8 / 9) + 'px'); } else { const k = 1.9 * 100 / Math.max(r, 1), fwd = target.offsetWidth * k, fh = fwd * 16 / 9; const lx = (S.ptr.x - (b.left - sr.left)) / b.width, ly = (S.ptr.y - (b.top - sr.top)) / b.height; w(mc, 'width', fwd + 'px'); w(mc, 'height', fh + 'px'); w(mc, 'left', (100 - lx * fwd) + 'px'); w(mc, 'top', (100 - ly * fh) + 'px'); } } const mt = magTagRef.current; w(mt, 'opacity', target && r > 60 ? '1' : '0'); w(mt, 'transform', `translate(${Math.max(8, Math.min(Wd - 200, x - r * 0.6)).toFixed(1)}px,${(y + r + 14).toFixed(1)}px) rotate(-3deg)`); }); }, []); const rcW = mob ? 'min(52vw, calc((100svh - 380px) * 0.5625))' : 'min(24vw, calc((100svh - 340px) * 0.5625))'; const count = (f) => (f === FIL[0] ? reels.length : reels.filter((r) => r.label === f).length); return (
{ if (e.pointerType === 'touch') return; const r = stageRef.current.getBoundingClientRect(); S.ptr.x = e.clientX - r.left; S.ptr.y = e.clientY - r.top; S.ptr.in = true; const hit = document.elementFromPoint(e.clientX, e.clientY); setMag(hit && !S.zoom && Engine.prog(secRef.current) * (1 / 0.6) < 0.15 ? hit.closest('[data-frame]') : null); }} onPointerLeave={() => { S.ptr.in = false; if (!S.zoom) setMag(null); }} onClick={(e) => { if (!(S.mob || matchMedia('(hover: none)').matches)) return; if (S.zoom) { S.zoom = null; setMag(null); return; } const f = e.target.closest && e.target.closest('[data-frame]'); if (!f || Engine.prog(secRef.current) / 0.6 > 0.15) return; const r = stageRef.current.getBoundingClientRect(), b = f.getBoundingClientRect(); if (S.pos) { S.pos.x.x = b.left + b.width / 2 - r.left; S.pos.y.x = b.top + b.height / 2 - r.top; S.rad.x = b.width / 2; } S.zoom = f; S.hover = null; setMag(f); S.hover = null; }}>
); } Object.assign(window, { Work });