← Public packages
@tannerlinsley/react-summit-talk
Use TanStack: an animated React Summit talk about AI, user trust, and open-source foundations.
Files
// Use TanStack deck timeline.
//
// Fragment times live in the slideshow island in index.html. Every slide
// builder below reads them, so retiming a beat means editing the island only.
// The motion for fragment i runs from fragment i-1 (or the scene start) to
// fragment i.
// Scene timings are read right away: once the HyperFrames runtime attaches it can
// rewrite data-start on nested compositions.
const DECK_SCENE_TIMES = Object.fromEntries(
[...document.querySelectorAll("#root > [data-composition-id]")].map((el) => [el.dataset.compositionId, [Number(el.dataset.start), Number(el.dataset.duration)]]),
);
// Built after fonts load, so measured text (names, glyph dots) matches the real faces.
document.fonts.ready.then(() => {
// The page can evaluate this script more than once in live mode; build once.
if (window.__deckBuilt) return;
window.__deckBuilt = true;
gsap.registerPlugin(TextPlugin);
const $ = (sel, root = document) => root.querySelector(sel);
const $$ = (sel, root = document) => [...root.querySelectorAll(sel)];
const root = document.getElementById("root");
const TOTAL = Number(root.dataset.duration);
const island = JSON.parse($('script[type="application/hyperframes-slideshow+json"]').textContent);
// Navigation can hold only the problem and fix while retaining intermediate animation cues.
const allSlides = [...island.slides, ...(island.slideSequences || []).flatMap((q) => q.slides)]
.map((slide) => ({ ...slide, fragments: slide.animationFragments || slide.fragments }));
// Live presenter (inside <hyperframes-slideshow>) gets ambient CSS loops.
let live = false;
try {
live = window.parent !== window && !!window.parent.document.querySelector("hyperframes-slideshow");
} catch (e) {
live = false;
}
if (live) root.classList.add("live");
// Presenter view: draggable dividers between the slide, the notes and "Up next".
// The stock player repaints its panel on every slide change, so re-apply after
// each repaint. Sizes are remembered in this browser. This reaches into the
// player's markup (pinned @hyperframes/core 0.8.172), so recheck after upgrades.
if (live) {
try {
const pdoc = window.parent.document;
const host = pdoc.querySelector("hyperframes-slideshow");
const KEY = "deck-presenter-layout";
const lay = { h: 32, w: 380 };
try {
Object.assign(lay, JSON.parse(localStorage.getItem(KEY) || "{}"));
} catch (e) {}
const save = () => {
try {
localStorage.setItem(KEY, JSON.stringify(lay));
} catch (e) {}
};
const drag = (handle, onMove) => {
handle.addEventListener("pointerdown", (e) => {
e.preventDefault();
handle.setPointerCapture(e.pointerId);
const move = (ev) => {
onMove(ev);
apply();
};
const up = () => {
handle.removeEventListener("pointermove", move);
handle.removeEventListener("pointerup", up);
save();
};
handle.addEventListener("pointermove", move);
handle.addEventListener("pointerup", up);
});
};
const grip = (css, cursor) => {
const g = pdoc.createElement("div");
g.style.cssText = `position:absolute;z-index:5;cursor:${cursor};background:transparent;${css}`;
g.addEventListener("pointerenter", () => (g.style.background = "rgba(255,255,255,0.12)"));
g.addEventListener("pointerleave", () => (g.style.background = "transparent"));
return g;
};
// Steps, not slides: every click in the talk, counted straight through.
const STEP_BASE = [];
island.slides.reduce((n, sl, i) => ((STEP_BASE[i] = n), n + Math.max(1, sl.fragments.length)), 0);
const STEP_TOTAL = island.slides.reduce((n, sl) => n + Math.max(1, sl.fragments.length), 0);
const stepNow = () => {
const p = (host.controller && host.controller.position) || {};
return Math.min(STEP_TOTAL, (STEP_BASE[p.slideIndex || 0] || 0) + Math.max(0, p.fragmentIndex || 0) + 1);
};
// Keep presenter mode, the current click and the countdown in the URL
// (?present=1&step=72&dur=20&t0=...), so a reload lands in the same place.
const pwin = pdoc.defaultView;
// Countdown timer: set the talk length, Start, Reset. Runs over into red.
const timer = { dur: 20, t0: null };
const fmtClock = (ms) => {
const t = Math.round(Math.abs(ms) / 1000);
return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
};
const timerNode = pdoc.createElement("div");
timerNode.setAttribute("data-deck-timer", "");
timerNode.style.cssText = "display:flex;flex-direction:column;gap:10px;";
timerNode.innerHTML = `
<div data-t-label style="font-size:11px;text-transform:uppercase;letter-spacing:.1em;opacity:.5;">Remaining</div>
<div data-t-clock style="font-family:inherit;font-weight:600;font-variant-numeric:tabular-nums;line-height:1;letter-spacing:-0.02em;"></div>
<div style="display:flex;align-items:center;gap:8px;font-size:13px;">
<input data-t-min type="number" min="1" max="180" step="1" style="width:56px;padding:5px 6px;border-radius:6px;border:1px solid rgba(255,255,255,0.2);background:rgba(255,255,255,0.06);color:#fff;font:inherit;" />
<span style="opacity:.6;">min</span>
<button data-t-start type="button" style="padding:5px 12px;border-radius:6px;border:0;background:#fff;color:#11151f;font:inherit;font-weight:600;cursor:pointer;">Start</button>
<button data-t-reset type="button" style="padding:5px 12px;border-radius:6px;border:1px solid rgba(255,255,255,0.25);background:transparent;color:#fff;font:inherit;cursor:pointer;">Reset</button>
</div>`;
const tMin = timerNode.querySelector("[data-t-min]");
// Keys typed into the minutes box shouldn't drive the slides.
tMin.addEventListener("keydown", (e) => e.stopPropagation());
tMin.addEventListener("change", () => {
timer.dur = Math.max(1, Number(tMin.value) || 20);
renderTimer();
apply();
});
timerNode.querySelector("[data-t-start]").addEventListener("click", () => {
timer.dur = Math.max(1, Number(tMin.value) || 20);
timer.t0 = Date.now();
host.presenterStartMs = timer.t0;
renderTimer();
apply();
});
timerNode.querySelector("[data-t-reset]").addEventListener("click", () => {
timer.t0 = null;
renderTimer();
apply();
});
function renderTimer() {
const clock = timerNode.querySelector("[data-t-clock]");
const left = timer.dur * 60000 - (timer.t0 ? Date.now() - timer.t0 : 0);
const text = left < 0 ? `+${fmtClock(left)}` : fmtClock(left);
if (clock.textContent !== text) clock.textContent = text;
const color = left < 0 ? "#ff6b57" : timer.t0 && left < 5 * 60000 ? "#f4b740" : "#fff";
if (clock.style.color !== color) clock.style.color = color;
const size = `${Math.round(Math.min(120, lay.w / 3.6))}px`;
if (clock.style.fontSize !== size) clock.style.fontSize = size;
const label = left < 0 ? "Over" : timer.t0 ? "Remaining" : "Ready";
const lbl = timerNode.querySelector("[data-t-label]");
if (lbl.textContent !== label) lbl.textContent = label;
const v = String(timer.dur);
if (pdoc.activeElement !== tMin && tMin.value !== v) tMin.value = v;
}
pwin.setInterval(renderTimer, 250);
// Back steps one click, not one slide. On a slide's first click it lands
// on the previous slide's last click, mirroring how Next moves forward.
function patchPrev(c) {
if (!c || c.__deckPrev || !c.resumeSlide || !c.slidesOf) return;
c.__deckPrev = true;
c.prev = function () {
const f = this.frame;
if (!f) return;
if (f.fragmentIndex > 0) return this.resumeSlide(f.slideIndex, f.fragmentIndex - 1);
if (f.slideIndex > 0) {
const before = this.slidesOf(f.sequenceId)[f.slideIndex - 1];
if (this.stopSlideMedia) this.stopSlideMedia();
this.resumeSlide(f.slideIndex - 1, Math.max(0, before.fragments.length - 1));
}
};
}
function syncUrl() {
const c = host.controller;
patchPrev(c);
if (!c || !c.stack || !c.stack[0] || !c.position) return;
const u = new URL(pwin.location.href);
if (u.searchParams.get("mode") === "audience") return;
// Once per page load (the deck script can run again in a fresh frame).
if (!pwin.__deckRestored) {
pwin.__deckRestored = true;
let slide = Number(u.searchParams.get("slide"));
let step = Number(u.searchParams.get("step")) || 0;
if (!slide && step >= 1) {
// ?step=72 counts every click in the talk; map it back to slide + click.
const g = Math.min(step, STEP_TOTAL) - 1;
let i = STEP_BASE.length - 1;
while (i > 0 && STEP_BASE[i] > g) i--;
slide = i + 1;
step = g - STEP_BASE[i];
}
timer.dur = Math.max(1, Number(u.searchParams.get("dur")) || 20);
timer.t0 = Number(u.searchParams.get("t0")) || null;
if (u.searchParams.get("present") === "1" && host.getAttribute("data-hf-presenting") !== "true") {
host.setAttribute("data-hf-presenting", "true");
host.presenterStartMs = Number(u.searchParams.get("t0")) || Date.now();
if (host.presenterInterval == null) host.presenterInterval = pwin.setInterval(() => host.updateElapsed(), 1000);
}
if (slide >= 1) c.syncTo("main", slide - 1, step);
host.render();
return;
}
const p = c.position;
u.searchParams.delete("slide");
u.searchParams.set("step", String(stepNow()));
if (host.getAttribute("data-hf-presenting") === "true") {
u.searchParams.set("present", "1");
u.searchParams.set("dur", String(timer.dur));
if (timer.t0) u.searchParams.set("t0", String(timer.t0));
else u.searchParams.delete("t0");
} else {
u.searchParams.delete("present");
u.searchParams.delete("t0");
u.searchParams.delete("dur");
}
if (u.href !== pwin.location.href) pwin.history.replaceState(pwin.history.state, "", u.href);
}
function apply() {
syncUrl();
const step = stepNow();
const pill = host.querySelector("[data-hf-counter]");
if (pill && pill.textContent !== `${step} / ${STEP_TOTAL}`) {
pill.textContent = `${step} / ${STEP_TOTAL}`;
pill.setAttribute("aria-label", `Step ${step} of ${STEP_TOTAL}`);
}
const panel = pdoc.querySelector("[data-hf-presenter]");
if (!panel) return;
const view = pdoc.defaultView;
panel.style.height = `${lay.h}%`;
const player = host.querySelector("hyperframes-player");
if (player) player.style.bottom = `${lay.h}%`;
const nav = host.querySelector('[data-deck-nav], [style*="calc(32% + 18px)"]');
if (nav) {
nav.setAttribute("data-deck-nav", "");
nav.style.bottom = `calc(${lay.h}% + 18px)`;
}
// Right column: a big elapsed timer and a small slide progress bar
// (the stock "Up next" preview is hidden; the notes stack shows what's next).
const nextEl = panel.querySelector("[data-hf-presenter-next]");
const side = nextEl && nextEl.parentElement;
if (side) {
side.style.width = `${lay.w}px`;
side.style.justifyContent = "center";
side.firstElementChild.style.display = "none";
nextEl.style.display = "none";
const elapsed = side.querySelector("[data-hf-presenter-elapsed]");
const counter = side.querySelector("[data-hf-presenter-counter]");
const stats = elapsed && elapsed.parentElement.parentElement;
if (stats && counter) {
stats.style.cssText = "display:flex;flex-direction:column;gap:22px;margin:0;";
elapsed.parentElement.style.display = "none";
if (timerNode.parentElement !== stats) stats.prepend(timerNode);
counter.style.fontSize = "18px";
counter.style.opacity = "0.7";
let bar = side.querySelector("[data-deck-prog]");
if (!bar) {
bar = pdoc.createElement("div");
bar.setAttribute("data-deck-prog", "");
bar.style.cssText = "height:4px;border-radius:2px;background:rgba(255,255,255,0.14);overflow:hidden;";
bar.innerHTML = '<i style="display:block;height:100%;background:#fff;transition:width .4s ease-out;"></i>';
counter.after(bar);
}
const lbl = counter.previousElementSibling;
if (lbl && lbl.textContent !== "Step") lbl.textContent = "Step";
if (counter.textContent !== `${step} / ${STEP_TOTAL}`) counter.textContent = `${step} / ${STEP_TOTAL}`;
const pct = `${((step / STEP_TOTAL) * 100).toFixed(1)}%`;
if (bar.firstElementChild.style.width !== pct) bar.firstElementChild.style.width = pct;
}
}
if (!panel.querySelector("[data-deck-grip]")) {
const row = grip("left:0;right:0;top:-6px;height:12px;", "row-resize");
row.setAttribute("data-deck-grip", "row");
drag(row, (ev) => (lay.h = Math.min(75, Math.max(12, ((view.innerHeight - ev.clientY) / view.innerHeight) * 100))));
const col = grip("top:0;bottom:0;width:12px;", "col-resize");
col.setAttribute("data-deck-grip", "col");
drag(col, (ev) => (lay.w = Math.min(view.innerWidth - 300, Math.max(180, panel.getBoundingClientRect().right - ev.clientX))));
panel.append(row, col);
}
const col = panel.querySelector('[data-deck-grip="col"]');
if (col) col.style.right = `${lay.w - 6}px`;
notesPage(panel);
}
// One notes page per click. The slide's notes are a script: title, context,
// one "[click]" line per stop, then "Note:" lines. Show only where you are
// now and what the next click does. Double-click toggles the full script.
let fullScript = false;
let pageNode = null;
let subscribed = false;
const esc = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
const parse = (notes) => {
const lines = (notes || "").split("\n");
const clicks = lines.filter((l) => l.startsWith("[click] ")).map((l) => l.slice(8));
const notesOut = lines.filter((l) => l.startsWith("Note: ")).map((l) => l.slice(6));
const ctx = [];
for (const l of lines.slice(1)) {
if (!l.trim()) break;
ctx.push(l);
}
return { title: lines[0] || "", ctx: ctx.join(" "), clicks, notes: notesOut };
};
// Rolodex: every page for the slide in one stack (the context, one page per
// click, then the next slide's title). The active page is pinned to the top
// of the panel in bold; upcoming pages wait below, dimmed. Each click slides
// the stack up, so the old page leaves at the top and the next rises in.
function notesPage(panel) {
const c = host.controller;
if (!c || !c.currentSlide) return;
if (!subscribed && c.onChange) {
subscribed = true;
c.onChange(() => requestAnimationFrame(apply));
}
const area = panel.querySelector("textarea[data-hf-presenter-notes]");
if (!area) return;
// The player rebuilds its panel on every click, so keep one roll element
// alive and move it into each new panel; it then slides from where it was.
let page = pageNode;
if (!page) {
page = pageNode = pdoc.createElement("div");
page.setAttribute("data-deck-page", "");
page.style.cssText = "flex:1;min-width:0;display:flex;flex-direction:column;font-family:sans-serif;color:#fff;cursor:default;";
page.innerHTML = `
<div data-deck-view style="position:relative;flex:1;overflow:hidden;"><div data-deck-track style="position:absolute;left:0;right:0;top:0;"></div></div>
<div data-deck-foot style="padding:8px 36px 14px;border-top:1px solid rgba(255,255,255,0.08);font-size:15px;line-height:1.4;color:rgba(255,255,255,0.5);background:#11151f;"></div>`;
page.title = "Double-click for the full script";
page.addEventListener("dblclick", () => {
fullScript = true;
apply();
});
}
if (page.parentElement !== panel) area.before(page);
if (!area.dataset.deckDbl) {
area.dataset.deckDbl = "1";
area.addEventListener("dblclick", () => {
fullScript = false;
apply();
});
}
area.style.display = fullScript ? "" : "none";
page.style.display = fullScript ? "none" : "flex";
const track = page.querySelector("[data-deck-track]");
const EASE_OUT = "cubic-bezier(.16,1,.3,1)";
// One continuous roll for the whole talk: every slide's opening page,
// then its clicks. data-at maps each page to "slideIndex:fragmentIndex".
if (!track.dataset.built) {
track.dataset.built = "1";
track.innerHTML = island.slides
.map((sl, si) => {
const n = parse(sl.notes);
const pages = [[n.title, n.ctx, true], ...n.clicks.map((t, i) => [`Click ${i + 1}`, t, false])];
return pages
.map(([, text], fi) => `<div data-deck-item data-at="${si}:${fi}" style="padding:16px 36px 14px;transition:opacity .45s ${EASE_OUT};"><div data-deck-text style="font-size:26px;line-height:1.38;">${esc(text)}</div></div>`)
.join("");
})
.join("");
}
const pos = c.position || {};
const si = pos.slideIndex || 0;
const n = parse(c.currentSlide.notes);
const k = Math.min(pos.fragmentIndex || 0, n.clicks.length);
const items = [...track.children];
const at = items.findIndex((it) => it.dataset.at === `${si}:${k}`);
if (at < 0) return;
items.forEach((item, i) => {
item.style.opacity = i === at ? "1" : i > at ? (i === at + 1 ? "0.55" : "0.32") : "0";
const t = item.querySelector("[data-deck-text]");
if (t) t.style.fontWeight = i === at ? "700" : "400";
});
const y = items[at].offsetTop;
if (track.dataset.y === String(y)) return;
// Jumps of more than a few pages (slide list, Home) snap instead of rolling.
// The first placement and big jumps snap; single clicks roll.
const first = track.dataset.at === undefined;
const prev = Number(track.dataset.at || at);
track.dataset.y = String(y);
track.dataset.at = String(at);
track.style.transition = first || Math.abs(at - prev) > 3 ? "none" : `transform .55s ${EASE_OUT}`;
track.style.transform = `translateY(${-y}px)`;
page.querySelector("[data-deck-foot]").innerHTML = n.notes.map((t) => `Note: ${esc(t)}`).join("<br>");
}
if (host) {
new MutationObserver(apply).observe(host, { childList: true, subtree: true });
// Slide and click changes don't always repaint the chrome; follow them too.
const hook = pwin.setInterval(() => {
if (!host.controller || !host.controller.onChange) return;
pwin.clearInterval(hook);
host.controller.onChange(() => requestAnimationFrame(apply));
apply();
}, 200);
apply();
}
} catch (e) {}
}
const tl = gsap.timeline({ paused: true });
// Numbers that keep climbing in the live deck once their count-up lands.
const tickers = [];
// Measure "Make no mistakes." in the opening composer so it can glide to center
// and the next slide can pick it up at exactly the same spot and size.
const MNM_SCALE = 2;
const MNM_BOX = (() => {
const op = $("#open-prompts");
const src = op && $(".mnm", op);
if (!src) return null;
const cam = $(".cam", op);
let x = 0;
let y = 0;
for (let n = src; n && n !== cam; n = n.offsetParent) {
x += n.offsetLeft;
y += n.offsetTop;
}
const w = src.offsetWidth;
return { x, y, w, text: src.textContent, tx: 960 - (w * MNM_SCALE) / 2, ty: 320 };
})();
// Measure the "Oh, and use ..." names before their text is cleared for typing,
// so the next slide can start its dots exactly where the names sit.
const NAME_BOXES = (() => {
const oh = $("#open-ohand");
if (!oh) return [];
const ohCam = $(".cam", oh);
return [".nm-react", ".nm-vite", ".nm-tanstack"].map((sel) => {
const src = $(sel, oh);
let x = 0;
let y = 0;
for (let n = src; n && n !== ohCam; n = n.offsetParent) {
x += n.offsetLeft;
y += n.offsetTop;
}
return { sel, text: src.textContent, x, y, w: src.offsetWidth, h: 68, color: getComputedStyle(src).color };
}).map((b, i) => ({ ...b, tx: 960 - b.w, ty: 330 + i * 140 - 68 }));
})();
function slide(id) {
const el = document.querySelector(`[data-composition-id="${id}"]`);
const ref = allSlides.find((x) => x.sceneId === id);
return { el, s: DECK_SCENE_TIMES[id][0], F: ref ? ref.fragments || [] : [] };
}
const num = (v, d) => (v === undefined || v === "" ? d : Number(v));
const pair = (v) => v.split(",").map(Number);
// ---------- motion helpers ----------
const EASE = "power3.out";
const MOVE = "power2.inOut";
function rise(el, t, d = 0.6, y = 28) {
tl.fromTo(el, { opacity: 0, y }, { opacity: 1, y: 0, duration: d, ease: EASE, immediateRender: false }, t);
}
function prepType(el) {
const full = el.textContent;
el.textContent = "";
return full;
}
function typeIn(el, full, t, d) {
tl.to(el, { text: { value: full }, duration: d, ease: "none" }, t);
}
// ---------- camera ----------
// .cam has transform-origin 0 0, so centering world point (cx, cy) at scale s
// means translating by (960 - cx * s, 540 - cy * s).
const HOME = [960, 540, 1];
const camPose = ([cx, cy, s]) => ({ x: 960 - cx * s, y: 540 - cy * s, scale: s });
function camSet(cam, v, t) {
tl.set(cam, camPose(v), t);
}
function camTo(cam, v, t, d = 0.8, ease = "power3.inOut") {
tl.to(cam, { ...camPose(v), duration: d, ease }, t);
}
function relPos(el, ancestor) {
let x = 0;
let y = 0;
for (let n = el; n && n !== ancestor; n = n.offsetParent) {
x += n.offsetLeft;
y += n.offsetTop;
}
return [x + el.offsetWidth / 2, y + el.offsetHeight / 2];
}
// ---------- cursor ----------
const CURSOR = '<div class="cursor"><svg viewBox="0 0 54 54"><path d="M4 3v37l10-10 7 16 7-3-7-15h14z" fill="#f4f2ea" stroke="#050505" stroke-width="2.5" stroke-linejoin="round"/></svg></div>';
function addCursor(container) {
container.insertAdjacentHTML("beforeend", CURSOR);
return container.lastElementChild;
}
function moveTo(c, [x, y], t, d = 0.8) {
tl.to(c, { x, y, duration: d, ease: MOVE }, t);
}
function click(c, t) {
tl.to(c, { scale: 0.82, duration: 0.08, ease: "power1.in" }, t);
tl.to(c, { scale: 1, duration: 0.14, ease: "power1.out" }, t + 0.08);
}
// ---------- per-beat "also handles" flash, in three tiers ----------
// Tier 1: the library's first four #flash cards, named one at a time.
// Tier 2: a wall of everything else (rest of #flash plus #handles).
// Tier 3: a faint field running past the edges, "and way more".
function beatMore(scene, lib, t1, t2, namedCount = 4) {
// data-covered on the scene lists items its sub-beats already showed; skip those here.
const covered = (scene.dataset.covered || "").split("|").map((t) => t.trim().toLowerCase());
const fresh = (t) => !covered.includes(t.trim().toLowerCase());
const flood = $$("#flash .ec").filter((c) => $(".ec-lib", c).textContent.trim().toLowerCase() === lib && fresh($(".ec-txt", c).textContent));
if (!flood.length) return null;
const name = $(".ec-lib", flood[0]).textContent.trim();
const extra = $$("i", $("#handles").content).filter((i) => i.dataset.lib === lib && fresh(i.textContent)).map((i) => i.textContent);
const wallItems = [...flood.slice(namedCount).map((c) => $(".ec-txt", c).textContent), ...extra];
const fieldItems = Array.from({ length: 7 }, () => wallItems).flat();
const wrap = document.createElement("div");
wrap.className = "beat-more";
wrap.setAttribute("data-layout-allow-overlap", "");
wrap.style.setProperty("--acc", getComputedStyle(flood[0]).getPropertyValue("--acc") || "var(--text)");
wrap.innerHTML = `<div class="bm-inner">
<div class="bm-field floater" aria-hidden="true" style="--d: 16s; --fx: -30px; --fy: -20px">${fieldItems.map((x) => `<span data-t="${x}"></span>`).join("")}</div>
<h2 class="display beat-more-h">TanStack ${name} also handles</h2>
<div class="bm-named"></div>
<div class="bm-wall">${wallItems.map((x) => `<span class="bm-chip">${x}</span>`).join("")}</div>
<div class="bm-more">…and way more</div>
</div>`;
if (namedCount > 4) wrap.classList.add("bm-many");
const named = flood.slice(0, namedCount).map((c) => {
const card = c.cloneNode(true);
$(".ec-ok", card).style.opacity = "1";
$(".bm-named", wrap).appendChild(card);
return card;
});
scene.appendChild(wrap);
const inner = $(".bm-inner", wrap);
tl.fromTo(wrap, { opacity: 0 }, { opacity: 1, duration: 0.3, ease: "power1.out", immediateRender: false }, t1);
rise($(".beat-more-h", wrap), t1 + 0.05, 0.45, 20);
named.forEach((card, i) => {
tl.fromTo(card, { opacity: 0, y: 30, scale: 0.85 }, { opacity: 1, y: 0, scale: 1, duration: 0.4, ease: "back.out(1.7)", immediateRender: false }, t1 + 0.35 + i * (named.length > 4 ? 0.42 : 0.42));
});
const chips = $$(".bm-chip", wrap);
chips.forEach((chip, i) => {
tl.fromTo(chip, { opacity: 0, y: 24 }, { opacity: 1, y: 0, duration: 0.3, ease: EASE, immediateRender: false }, t2 + i * 0.045);
});
tl.fromTo($(".bm-field", wrap), { opacity: 0 }, { opacity: 1, duration: 0.8, immediateRender: false }, t2 + 0.4);
rise($(".bm-more", wrap), t2 + 0.2 + chips.length * 0.045, 0.5, 16);
return { wrap, inner };
}
// =====================================================================
// Exits. Each slide's exit runs from its last hold for EXIT seconds; the
// live driver plays it before the next slide's entrance.
// =====================================================================
const EXIT = 0.7;
// A few slides leave with a longer, built-in move instead of the quick exit.
const EXIT_LONG = { "start-wall": 3.0 };
const NO_EXIT = new Set(["table-prompt", "table-usage", "table-rewind", "close"]);
const customExit = new Set();
const lastOf = (F) => F[F.length - 1];
function exitDefault(el, t) {
const kids = [...el.children];
tl.to(kids, { opacity: 0, duration: 0.45, stagger: 0.04, ease: "power1.in" }, t);
}
// The beat's "also handles" cards fly into the corner watermark: the
// knowledge goes into TanStack. The big flood later brings them all back.
const WM = [104, 1000];
function exitIntoWatermark(el, more, t) {
customExit.add(el.dataset.compositionId);
const wm = $(".watermark");
tl.to(more.inner, { x: WM[0] - 960, y: WM[1] - 540, scale: 0.03, opacity: 0, duration: 0.6, ease: "power3.in" }, t);
tl.to(wm, { scale: 1.4, opacity: 0.95, duration: 0.12, ease: "power1.out" }, t + 0.55);
tl.to(wm, { scale: 1, opacity: 0.32, duration: 0.3, ease: "power1.in" }, t + 0.67);
tl.to([...el.children].filter((c) => c !== more.wrap), { opacity: 0, duration: 0.3 }, t);
tl.to(more.wrap, { backgroundColor: "rgba(5, 5, 5, 0)", duration: 0.4 }, t + 0.2);
}
const build = {};
// =====================================================================
// Opening
// =====================================================================
// Pseudo UI for the four prompts, in 900x420 window coordinates. The same
// 14 blocks reflow between apps ([x, y, w, h, highlighted]); each app also
// has a detail layer (text, icons) that fades in once the shapes settle.
const MORPH = [
// To-do
[[36, 28, 200, 44], [36, 100, 32, 32, 1], [36, 162, 32, 32, 1], [36, 224, 32, 32, 1], [36, 286, 32, 32], [36, 348, 32, 32],
[84, 94, 560, 44], [84, 156, 560, 44], [84, 218, 560, 44], [84, 280, 560, 44], [84, 342, 560, 44], [704, 28, 160, 44, 1], [704, 100, 160, 10], [252, 28, 96, 44]],
// Sales dashboard
[[36, 28, 200, 44], [36, 92, 262, 112], [318, 92, 262, 112], [600, 92, 264, 112], [56, 310, 34, 70, 1], [108, 276, 34, 104, 1],
[160, 292, 34, 88, 1], [212, 240, 34, 140, 1], [264, 258, 34, 122, 1], [316, 212, 34, 168, 1], [380, 222, 484, 170], [760, 28, 104, 44, 1], [520, 28, 110, 44], [640, 28, 110, 44]],
// Checkout
[[36, 28, 220, 44], [36, 92, 220, 220], [276, 96, 280, 30], [276, 134, 160, 26], [276, 186, 300, 46], [276, 244, 300, 46],
[276, 302, 300, 46], [276, 362, 300, 44, 1], [600, 92, 264, 300], [620, 120, 224, 30], [620, 160, 224, 30], [620, 200, 224, 30], [620, 334, 224, 40, 1], [36, 330, 220, 44]],
// CRM
[[0, 0, 184, 420], [212, 28, 300, 44], [600, 28, 264, 44], [212, 92, 652, 46], [212, 146, 652, 46], [212, 200, 652, 46],
[212, 254, 652, 46], [212, 308, 652, 46], [212, 362, 652, 46], [222, 99, 32, 32, 1], [222, 153, 32, 32, 1], [222, 207, 32, 32, 1], [222, 261, 32, 32, 1], [16, 84, 152, 40, 1]],
];
const t = (x, y, txt, cls = "") => `<span class="mt ${cls}" style="left: ${x}px; top: ${y}px">${txt}</span>`;
const DETAIL = [
// To-do
t(52, 36, "Today", "h") + t(268, 39, "3 / 5", "mute") + t(726, 39, "+ Add task", "on") +
["Ship pricing page", "Reply to Priya", "Book flights", "Renew the domain", "Plan Q3 launch"].map((x, i) => t(104, 104 + i * 62, x, i < 3 ? "done" : "")).join("") +
[0, 1, 2].map((i) => t(43, 103 + i * 62, "✓", "chk")).join("") + '<i class="m-fill" style="left: 704px; top: 100px; width: 96px"></i>',
// Dashboard
t(52, 36, "Sales", "h") + t(544, 39, "Week", "mute") + t(660, 39, "Month") + t(780, 39, "Export", "on") +
[["Revenue", "$128,430"], ["Deals", "342"], ["Win rate", "31%"]].map(([k, v], i) => t(56 + i * 282, 108, k, "mute") + t(56 + i * 282, 138, v, "kpi")).join("") +
'<svg class="m-line" style="left: 380px; top: 222px" width="484" height="170" viewBox="0 0 484 170"><polyline points="20,140 90,120 160,128 230,86 300,96 370,52 460,30" /></svg>',
// Checkout
t(52, 36, "Checkout", "h") + t(108, 180, "PRO", "badge") + t(286, 98, "Pro Plan, annual") + t(286, 134, "$1,249.00", "mute") +
t(292, 197, "you@acme.com", "mute") + t(292, 255, "4242 4242 4242 4242", "mute") + t(292, 313, "12 / 28 123", "mute") + t(354, 372, "Pay $1,249.00", "on") +
t(636, 125, "Subtotal", "mute") + t(756, 125, "$1,249") + t(636, 165, "Discount", "mute") + t(756, 165, "$0") + t(636, 205, "Tax", "mute") + t(756, 205, "$0") +
t(636, 343, "Total", "on") + t(722, 343, "$1,249.00", "on") + t(52, 340, "Sale ends tonight", "mute"),
// CRM
t(24, 30, "acme", "h") + t(32, 92, "Customers", "on") + t(32, 150, "Deals", "mute") + t(32, 196, "Pipeline", "mute") + t(32, 242, "Reports", "mute") +
t(228, 36, "Customers", "h") + t(620, 39, "Search 12,408", "mute") +
[["Northwind Traders", "$8,940"], ["Globex", "$12,600"], ["Lumen Coffee", "$1,280"], ["Harbor & Pine", "$2,315"], ["Atlas Freight", "$5,120"], ["Juniper Health", "$740"]]
.map(([n, v], i) => t(i < 4 ? 268 : 232, 104 + i * 54, n) + t(770, 104 + i * 54, v, "mute")).join("") +
["N", "G", "L", "H"].map((x, i) => t(222, 99 + i * 54, x, "av")).join(""),
];
const mbPose = ([x, y, w, h, hi]) => ({ x, y, width: w, height: h, backgroundColor: hi ? "#f4f2ea" : "#262626" });
build["open-prompts"] = ({ el, s, F }) => {
const cam = $(".cam", el);
camSet(cam, HOME, s);
// Hidden from the first frame; otherwise it flashes in before the rise starts.
tl.set($(".composer-wrap", el), { opacity: 0 }, s);
rise($(".composer-wrap", el), s + 0.1, 0.6);
const morph = $(".morph", el);
const blocks = MORPH[0].map(() => {
const b = document.createElement("i");
b.className = "mb";
morph.appendChild(b);
return b;
});
const details = DETAIL.map((html) => {
const g = document.createElement("div");
g.className = "md";
g.innerHTML = html;
morph.appendChild(g);
return g;
});
blocks.forEach((b, i) => tl.set(b, mbPose(MORPH[0][i]), s));
rise(morph, s + 0.15, 0.6, 30);
tl.fromTo(details[0], { opacity: 0 }, { opacity: 1, duration: 0.35, immediateRender: false }, s + 0.45);
[1, 2, 3].forEach((k) => {
const at = F[k - 1];
// Details out, shapes reflow (staggered from the top-left), details in.
tl.to(details[k - 1], { opacity: 0, duration: 0.15, ease: "power1.in" }, at);
blocks.forEach((b, i) => {
const [x, y] = MORPH[k][i];
tl.to(b, { ...mbPose(MORPH[k][i]), duration: 0.6, ease: "expo.inOut" }, at + 0.05 + ((x + y) / 1300) * 0.12);
});
tl.fromTo(details[k], { opacity: 0, y: 6 }, { opacity: 1, y: 0, duration: 0.3, ease: EASE, immediateRender: false }, at + 0.5);
});
tl.to(morph, { borderColor: "rgba(255, 107, 87, 0.7)", duration: 0.6 }, F[2] + 0.3);
const rings = $$(".ring", el);
tl.to(rings[0], { opacity: 1, duration: 0.6 }, s + 0.2);
const inner = $(".roll-inner", el);
[1, 2, 3].forEach((k) => {
tl.to(inner, { y: -68 * k, duration: 0.55, ease: "power3.inOut" }, F[k - 1]);
tl.to(rings[k], { opacity: 1, duration: 0.6 }, F[k - 1]);
});
// The CRM: rings go red and the camera leans in.
tl.to($(".rings", el), { color: "rgba(255, 107, 87, 0.75)", duration: 0.8 }, F[2]);
camTo(cam, [960, 540, 1.08], F[2], 1.0, "power2.inOut");
// "Make no mistakes." only gets typed after the CRM, as the punchline.
// Until then its line is collapsed and the caret sits at the end of each prompt.
const mnm = $(".mnm", el);
const fixedLine = $(".line.fixed", el);
tl.set(fixedLine, { height: 0, overflow: "hidden" }, s);
tl.to(fixedLine, { height: 68, duration: 0.35, ease: EASE }, F[3]);
// display, not opacity: the live blink animation owns the caret's opacity.
tl.set($$(".roll-inner .caret", el), { display: "none" }, F[3] + 0.2);
typeIn(mnm, prepType(mnm), F[3] + 0.2, 0.7);
// Exit: everything fades except "Make no mistakes.", which glides to center
// and grows into the next slide's headline. The camera eases back to neutral.
const t = lastOf(F);
customExit.add("open-prompts");
const comp = $(".composer", el);
camTo(cam, HOME, t, EXIT, "power3.inOut");
tl.to([morph, $(".rings", el), $(".roll", el), $(".caret", el), $(".send", el)], { opacity: 0, duration: 0.35 }, t);
tl.to(comp, { backgroundColor: "rgba(20, 20, 20, 0)", borderColor: "rgba(255, 255, 255, 0)", boxShadow: "0 0 0 rgba(0,0,0,0)", duration: 0.4 }, t);
// Its line clips while it grows in; let the words fly out of it on exit.
tl.set(fixedLine, { overflow: "visible" }, t);
tl.set($$(".caret", el), { display: "none" }, t + 0.02);
tl.to($(".mnm", el), { x: MNM_BOX.tx - MNM_BOX.x, y: MNM_BOX.ty - MNM_BOX.y, scale: MNM_SCALE, duration: EXIT, ease: "power3.inOut" }, t);
};
build["open-stakes"] = ({ el, s, F }) => {
// "Make no mistakes." arrives exactly where the last slide left it.
const copy = document.createElement("span");
copy.className = "mnm-copy";
copy.textContent = MNM_BOX.text;
copy.style.left = `${MNM_BOX.tx}px`;
copy.style.top = `${MNM_BOX.ty}px`;
$(".cam", el).appendChild(copy);
$$(".words span", el).forEach((w, i) => rise(w, F[0] + i * 0.1, 0.5, 30));
rise($(".stk-why", el), F[1], 0.6, 20);
// When the question lands, the setup steps back so it reads as the turn.
tl.to([copy, $(".stk-need", el)], { opacity: 0.4, duration: 0.6, ease: "power1.out" }, F[1] + 0.1);
// Exit: everything falls away.
customExit.add("open-stakes");
const t = lastOf(F);
tl.to(copy, { y: 90, opacity: 0, duration: 0.4, ease: "power2.in" }, t);
$$(".words span", el).forEach((w, i) => tl.to(w, { y: 90, opacity: 0, duration: 0.4, ease: "power2.in" }, t + 0.05 + i * 0.03));
tl.to($(".stk-why", el), { y: 90, opacity: 0, duration: 0.4, ease: "power2.in" }, t + 0.1);
};
// Bare title, fine to leave up during introductions.
build["title"] = ({ el, s }) => {
camSet($(".cam", el), HOME, s);
rise($(".t-main", el), s + 0.15, 0.8, 36);
// Live only: ridiculous prompts type, pause, erase and rotate while the room fills up.
const ask = $(".t-ask", el);
const prompts = JSON.parse(ask.dataset.prompts);
if (live) {
let i = 0;
let n = prompts[0].length;
let typing = false;
const step = () => {
const text = prompts[i];
if (typing) {
n += 1;
ask.textContent = text.slice(0, n);
if (n < text.length) return setTimeout(step, 45);
typing = false;
return setTimeout(step, 2600);
}
n -= 1;
ask.textContent = text.slice(0, n);
if (n > 0) return setTimeout(step, 18);
i = (i + 1) % prompts.length;
typing = true;
setTimeout(step, 350);
};
setTimeout(step, 3000);
}
};
build["about-me"] = ({ el, s, F }) => {
rise($(".ab-hi", el), s + 0.1);
rise($(".ab-sub", el), s + 0.3, 0.6, 16);
tl.fromTo($(".ab-logo", el), { opacity: 0, scale: 0.9 }, { opacity: 1, scale: 1, duration: 0.7, ease: EASE, immediateRender: false }, s + 0.2);
// Ten years, then three full time, each counting up.
$$(".ab-big", el).forEach((n, i) => {
const at = F[0] + i * 0.35;
const b = $("b", n);
rise(n, at, 0.5, 20);
tl.fromTo(b, { innerText: 0 }, { innerText: Number(b.dataset.count), duration: 0.8, ease: "power2.out", immediateRender: false, modifiers: { innerText: (v) => Math.round(v) } }, at);
});
// The stack, column by column like the tanstack.com menu.
$$(".mm-col", el).forEach((col, c) => {
rise($(".mm-head", col), F[1] + c * 0.1, 0.45, 14);
$$(".mm-lib", col).forEach((n, i) => rise(n, F[1] + 0.1 + c * 0.1 + i * 0.05, 0.45, 14));
});
};
build["about-tanstack"] = ({ el, s, F }) => {
rise($(".ab-hi", el), s + 0.1);
rise($(".ab-sub", el), s + 0.3, 0.6, 16);
tl.fromTo($(".ab-logo", el), { opacity: 0, scale: 0.9 }, { opacity: 1, scale: 1, duration: 0.7, ease: EASE, immediateRender: false }, s + 0.2);
// Every maintainer pops in, left to right.
$$(".tm", el).forEach((n, i) => {
tl.fromTo(n, { opacity: 0, scale: 0.6, y: 16 }, { opacity: 1, scale: 1, y: 0, duration: 0.4, ease: "back.out(1.8)", immediateRender: false }, F[0] + i * 0.03);
});
rise($(".ab-partner", el), F[1], 0.6, 16);
};
// Weekly downloads and the real history behind them, React and Vite for scale.
build["tanstack-stats"] = ({ el, s, F }) => {
rise($(".hc-l", el), s + 0.15, 0.5, 14);
tl.fromTo($$(".hc-grid, .hc-y, .hc-x", el), { opacity: 0 }, { opacity: 1, duration: 0.5, stagger: 0.01, immediateRender: false }, s + 0.25);
const num = $(".hc-head b", el);
const base = Number(num.dataset.count);
const fmt = (v) => Math.round(v).toLocaleString("en-US");
const DRAW = 2.6;
tl.fromTo(num, { opacity: 0 }, { opacity: 1, duration: 0.2, immediateRender: false }, F[0]);
tl.fromTo(num, { innerText: 0 }, { innerText: base, duration: DRAW, ease: "expo.out", immediateRender: false, modifiers: { innerText: fmt } }, F[0]);
// A clip wipes left to right over all three lines, in step with the count.
// Both use a hard ease-out: fast start, long settle.
// The wipe runs exactly across the plotted data, so the line tip and the
// count hit the same progress at the same moment and land together.
const wipe = $(".hc-wipe", el);
const box = $(".hc-line", el).getBBox();
tl.fromTo(wipe, { attr: { width: box.x } }, { attr: { width: box.x + box.width + 2 }, duration: DRAW, ease: "expo.out", immediateRender: false }, F[0]);
tl.set(wipe, { attr: { width: 0 } }, s);
tl.fromTo([$(".hc-ends", el), $(".hc-tlab", el)], { opacity: 0, x: -10 }, { opacity: 1, x: 0, duration: 0.4, immediateRender: false }, F[0] + DRAW);
tl.fromTo($(".hc-dotg", el), { opacity: 0 }, { opacity: 1, duration: 0.25, immediateRender: false }, F[0] + DRAW);
// Live only: after the count lands, keep climbing at the live pace (weekly total / seconds per week).
if (live) tickers.push({ el: num, base, rate: Number(num.dataset.rate), from: F[0] + DRAW, to: s + DECK_SCENE_TIMES[el.dataset.compositionId][1], fmt });
rise($(".ab-up", el), F[1], 0.45, 10);
$$(".hc-side > div", el).forEach((n, i) => rise(n, F[1] + 0.15 + i * 0.1, 0.45, 14));
rise($(".hc-src", el), F[1] + 0.4, 0.4, 8);
};
build["open-cheap"] = ({ el, s, F }) => {
rise($(".l1", el), s + 0.2);
rise($(".l2", el), F[0]);
$$(".chip", el).forEach((chip, i) => {
tl.fromTo(chip, { opacity: 0, scale: 0.6 }, { opacity: 1, scale: 1, duration: 0.45, ease: "back.out(1.6)", immediateRender: false }, F[1] + i * 0.16);
});
if (F[3] !== undefined) rise($(".cheap-l3", el), F[2], 0.6, 16);
// Exit: the friction scatters outward.
const t = lastOf(F);
customExit.add("open-cheap");
$$(".floater", el).forEach((f) => {
const [x, y] = relPos(f, $(".cam", el));
const len = Math.hypot(x - 960, y - 540) || 1;
tl.to($(".chip", f), { x: ((x - 960) / len) * 700, y: ((y - 540) / len) * 500, scale: 1.3, opacity: 0, duration: 0.55, ease: "power2.in" }, t);
});
tl.to([$(".l1", el), $(".l2", el), $(".cheap-l3", el)], { opacity: 0, scale: 0.9, duration: 0.4 }, t + 0.15);
};
build["open-felt"] = ({ el, s, F }) => {
// The headline lands with the rough edges, not before.
rise($("h1", el), F[1] + 0.2, 0.7);
tl.fromTo([$(".trust-chart", el), $(".tc-ylab", el), $(".tc-xlab", el)], { opacity: 0 }, { opacity: 1, duration: 0.5, immediateRender: false }, s + 0.5);
const draw = (line, t, d) => {
const len = Math.ceil(line.getTotalLength());
line.style.strokeDasharray = `${len}`;
tl.set(line, { strokeDashoffset: len }, s);
tl.to(line, { strokeDashoffset: 0, duration: d, ease: "none" }, t);
};
// Someone starts using the app and likes it.
draw($(".tc-rise", el), F[0], 1.1);
tl.fromTo($(".tc-peak", el), { opacity: 0, y: 10 }, { opacity: 1, y: 0, duration: 0.4, ease: EASE, immediateRender: false }, F[0] + 1.0);
// Each rough edge knocks it down a step, until they're gone.
draw($(".tc-fall", el), F[1], 1.8);
$$(".tc-cut", el).forEach((cut, i) => {
tl.fromTo(cut, { opacity: 0, x: -10 }, { opacity: 1, x: 0, duration: 0.3, ease: EASE, immediateRender: false }, F[1] + 0.25 + i * 0.47);
});
tl.fromTo($(".tc-gone", el), { opacity: 0 }, { opacity: 1, duration: 0.4, immediateRender: false }, F[1] + 1.65);
tl.to($(".tc-peak", el), { opacity: 0.4, duration: 0.6 }, F[1] + 0.4);
};
build["open-taste"] = ({ el, s, F }) => {
rise($(".tt-eyebrow", el), s + 0.2, 0.6, 20);
tl.fromTo($(".tt-taste", el), { opacity: 0, scale: 0.92 }, { opacity: 1, scale: 1, duration: 0.7, ease: EASE, immediateRender: false }, s + 0.35);
rise($(".tt-sub", el), F[0]);
// Taste steps aside and trust takes its place on top.
tl.to([$(".tt-eyebrow", el), $(".tt-sub", el)], { opacity: 0, duration: 0.3 }, F[1]);
tl.to($(".tt-taste", el), { opacity: 0, y: 60, scale: 0.6, duration: 0.5, ease: "power2.in" }, F[1]);
tl.fromTo($(".tt-trust", el), { opacity: 0, y: -40 }, { opacity: 1, y: 0, duration: 0.7, ease: EASE, immediateRender: false }, F[1] + 0.3);
rise($(".tt-then", el), F[1] + 0.7, 0.6, 20);
customExit.add("open-taste");
tl.to([$(".tt-trust", el), $(".tt-then", el)], { x: -260, opacity: 0, duration: 0.5, stagger: 0.06, ease: "power2.in" }, lastOf(F));
};
build["open-just"] = ({ el, s, F }) => {
tl.fromTo($(".q", el), { opacity: 0, scale: 0.92 }, { opacity: 1, scale: 1, duration: 0.7, ease: EASE, immediateRender: false }, s + 0.2);
rise($(".sub", el), F[0]);
// Eyes closed, shipping anyway.
rise($(".jd-eye", el), s + 0.1, 0.5, 16);
$$(".jd-toast", el).forEach((n, i) => tl.fromTo(n, { opacity: 0, y: 20, scale: 0.9 }, { opacity: 1, y: 0, scale: 1, duration: 0.35, ease: "back.out(2)", immediateRender: false }, s + 0.6 + i * 0.18));
// Exit: slide away left.
customExit.add("open-just");
tl.to([$(".jd-eye", el), ...$$(".jd-toast", el)], { opacity: 0, duration: 0.3 }, lastOf(F));
tl.to([$(".q", el), $(".sub", el)], { x: -260, opacity: 0, duration: 0.5, stagger: 0.06, ease: "power2.in" }, lastOf(F));
};
build["open-foundations"] = ({ el, s, F }) => {
rise($("h1", el), s + 0.2, 0.7);
const stage = $(".iso-stage", el);
const [pa, pb, pc, app] = [".p-a", ".p-b", ".p-c", ".p-app"].map((c) => $(c, el));
const labels = $$(".fl", el);
// The viewing angle is fixed in CSS (.iso / .iso-z) and never animates.
// Everything below moves only along the stack's vertical axis (z).
const Z = [0, 100, 200, 330];
const HOVER = 450;
const labelY = (z) => 912 - 28 - z * 0.98;
const SMOOTH = "power3.out";
// Fade a plate's flat layers (face and sides), never the 3D plate itself.
const layers = (p) => $$(".face, .side", p);
const face = (p) => $(".face", p);
// Your app hovers with nothing under it.
tl.fromTo(app, { z: HOVER + 120 }, { z: HOVER, duration: 0.9, ease: SMOOTH, immediateRender: false }, s + 0.3);
tl.fromTo(layers(app), { opacity: 0 }, { opacity: 1, duration: 0.5, ease: "power1.out", immediateRender: false }, s + 0.3);
tl.set(labels[3], { y: labelY(HOVER) }, s);
tl.fromTo(labels[3], { opacity: 0, x: 24 }, { opacity: 1, x: 0, duration: 0.6, ease: SMOOTH, immediateRender: false }, s + 0.6);
// Layers build bottom up: Foundations rises into place, the others settle from just above.
const from = [-260, Z[1] + 200, Z[2] + 200];
[pa, pb, pc].forEach((p, i) => {
const at = F[i];
tl.fromTo(p, { z: from[i] }, { z: Z[i], duration: 0.85, ease: SMOOTH, immediateRender: false }, at);
tl.fromTo(layers(p), { opacity: 0 }, { opacity: 1, duration: 0.45, ease: "power1.out", immediateRender: false }, at);
tl.set(labels[i], { y: labelY(Z[i]) }, s);
tl.fromTo(labels[i], { opacity: 0, x: 24 }, { opacity: 1, x: 0, duration: 0.55, ease: SMOOTH, immediateRender: false }, at + 0.3);
});
// The app settles onto the finished stack, its label riding along, then a
// soft lock pulse runs up through the layers.
const t3 = F[3];
tl.to(app, { z: Z[3], duration: 0.9, ease: "power3.inOut" }, t3);
tl.to(labels[3], { y: labelY(Z[3]), duration: 0.9, ease: "power3.inOut" }, t3);
[pa, pb, pc, app].forEach((p, i) => {
tl.fromTo(face(p), { borderColor: "rgba(255,255,255,0.75)" }, { borderColor: i === 3 ? "#f4f2ea" : "rgba(255,255,255,0.16)", duration: 0.7, ease: "power1.out", immediateRender: false }, t3 + 0.75 + i * 0.1);
});
tl.to(labels.slice(0, 3), { color: "#f4f2ea", duration: 0.4, stagger: 0.1 }, t3 + 0.75);
// New layer on top: the prompt you give AI lands above your app.
const prompt = $(".p-prompt", el);
const t4 = F[4];
const ZP = 470;
tl.set(prompt, { z: ZP + 160 }, s);
tl.fromTo(prompt, { z: ZP + 160 }, { z: ZP, duration: 0.9, ease: SMOOTH, immediateRender: false }, t4);
tl.fromTo(layers(prompt), { opacity: 0 }, { opacity: 1, duration: 0.45, ease: "power1.out", immediateRender: false }, t4);
tl.set(labels[4], { y: labelY(ZP) }, s);
tl.fromTo(labels[4], { opacity: 0, x: 24 }, { opacity: 1, x: 0, duration: 0.55, ease: SMOOTH, immediateRender: false }, t4 + 0.3);
// Exit: the whole stage eases down and out, so the angle holds while it leaves.
customExit.add("open-foundations");
const t = lastOf(F);
// Everything but the prompt drops away; the prompt plate carries into the next slide.
tl.to([$("h1", el), ...labels], { opacity: 0, duration: 0.3 }, t);
[pa, pb, pc, app].forEach((p, i) => {
tl.to(p, { z: `-=${140 + i * 30}`, duration: 0.6, ease: "power2.in" }, t);
tl.to(layers(p), { opacity: 0, duration: 0.45, ease: "power1.in" }, t + 0.05);
});
};
build["open-ohand"] = ({ el, s, F }) => {
const wrap = $(".composer-wrap", el);
const comp = $(".composer", el);
const para = $(".spec-para", el);
const line = $(".oh-line", el);
const more = $$(".more", el);
// Each line is "Oh, and use " + a bold, colored name + "." typed in order.
const parts = more.map((l) => [...l.children].map((p) => [p, prepType(p)]));
const hidden = more.length * 68;
// The layout at rest is the end state (paragraph collapsed), so the name
// boxes measured at load match where the names finally sit.
const COLLAPSED = para.offsetHeight;
const FULL = para.scrollHeight;
tl.set(comp, { clipPath: `inset(0px 0px ${hidden}px 0px round 36px)` }, s);
tl.set(para, { height: 0, opacity: 0 }, s);
// Hidden from the first frame; otherwise it flashes in before the rise starts.
tl.set(wrap, { opacity: 0 }, s);
rise(wrap, s + 0.1, 0.6);
// Click 1: the detail pours in.
tl.to(para, { height: FULL, opacity: 1, duration: 1.6, ease: "power2.out" }, F[0]);
// Click 2: but that's not all.
rise(line, F[1], 0.6, 20);
// Click 3: the detail shrinks to a footnote as the tools land, big.
tl.to(line, { opacity: 0, duration: 0.3 }, F[2]);
tl.to(para, { height: COLLAPSED, opacity: 0.4, duration: 0.8, ease: "power3.inOut" }, F[2]);
more.forEach((l, i) => {
const t = F[i + 2] + (i === 0 ? 0.55 : 0);
tl.to(comp, { clipPath: `inset(0px 0px ${hidden - (i + 1) * 68}px 0px round 36px)`, duration: 0.35, ease: EASE }, t);
const chars = parts[i].reduce((n, [, txt]) => n + txt.length, 0);
let at = t + 0.2;
parts[i].forEach(([p, txt]) => {
const d = (0.7 * txt.length) / chars;
typeIn(p, txt, at, d);
at += d;
});
});
// Exit: everything else fades while the three names glide to the center and
// grow. The next slide picks them up at exactly that spot.
const t = lastOf(F);
customExit.add("open-ohand");
tl.set(comp, { clipPath: "inset(-800px -800px -800px -800px round 36px)" }, t);
tl.to(comp, { backgroundColor: "rgba(20, 20, 20, 0)", borderColor: "rgba(255, 255, 255, 0)", boxShadow: "0 0 0 rgba(0,0,0,0)", duration: 0.4 }, t);
const fadeOut = [$(".ask:not(.more)", el), $(".send", el), para, ...more.map((l) => [...l.children].filter((c) => !c.classList.contains("nm"))).flat()];
tl.to(fadeOut, { opacity: 0, duration: 0.3 }, t);
NAME_BOXES.forEach((b) => {
tl.to($(b.sel, el), { x: b.tx - b.x, y: b.ty - b.y, scale: 2, duration: 0.65, ease: "power3.inOut" }, t + 0.05);
});
};
build["open-experience"] = ({ el, s, F }) => {
const field = $(".dots-field", el);
// First stop holds on the names; the click breaks them apart.
const B = F[0];
rise($("h1", el), B + 1.7, 0.7);
// The names arrive centered and doubled, exactly where the last slide left them.
const names = NAME_BOXES.map((b) => {
const copy = document.createElement("span");
copy.className = `nm nm-copy ${b.sel.slice(1)}`;
copy.textContent = b.text;
copy.style.left = `${b.tx}px`;
copy.style.top = `${b.ty}px`;
field.before(copy);
return { ...b, copy };
});
// Sample each word's real glyphs into a dot matrix.
const STEP = 9;
const pts = [];
names.forEach((n, k) => {
const cv = document.createElement("canvas");
cv.width = Math.ceil(n.w * 2) + 20;
cv.height = 136;
const ctx = cv.getContext("2d");
ctx.font = '700 108px "Inter", sans-serif';
ctx.textBaseline = "middle";
ctx.fillStyle = "#fff";
ctx.fillText(n.text, 0, 70);
const data = ctx.getImageData(0, 0, cv.width, cv.height).data;
for (let y = STEP / 2; y < cv.height; y += STEP) {
for (let x = STEP / 2; x < cv.width; x += STEP) {
if (data[(Math.floor(y) * cv.width + Math.floor(x)) * 4 + 3] > 140) pts.push({ k, x: n.tx + x, y: n.ty + y, color: n.color, u: x / cv.width });
}
}
});
// The field keeps each name's color as a band: fill row by row in name order.
pts.sort((a, b) => a.k - b.k || a.x - b.x);
const COLS = 40;
const GX = 32;
const GY = 30;
const rows = Math.ceil(pts.length / COLS);
const left = 960 - ((COLS - 1) * GX) / 2;
const top = 520;
const dots = pts.map((p, i) => {
const dot = document.createElement("i");
const lastRowCount = pts.length - (rows - 1) * COLS;
const rowShift = Math.floor(i / COLS) === rows - 1 ? ((COLS - lastRowCount) * GX) / 2 : 0;
const fx = left + (i % COLS) * GX + rowShift;
const fy = top + Math.floor(i / COLS) * GY;
dot.style.left = `${fx}px`;
dot.style.top = `${fy}px`;
dot.style.background = p.color;
field.appendChild(dot);
// Form the letters with a quick left-to-right sweep, then hand off.
tl.set(dot, { opacity: 0 }, s);
tl.fromTo(dot, { opacity: 0, scale: 0, x: p.x - fx, y: p.y - fy }, { opacity: 1, scale: 1, duration: 0.18, ease: "back.out(2)", immediateRender: false }, B + 0.12 + p.u * 0.3);
tl.to(dot, { x: 0, y: 0, duration: 0.95, ease: "power3.inOut" }, B + 0.85 + p.u * 0.45 + p.k * 0.08);
return { dot, fx, fy };
});
tl.to(names.map((n) => n.copy), { opacity: 0, duration: 0.22, ease: "power1.in" }, B + 0.3);
tl.set(field, { attr: { "data-on": "0" } }, s);
tl.set(field, { attr: { "data-on": "1" } }, F[1]);
rise($(".sub", el), F[1]);
// Exit: every light converges to a single point.
const t = lastOf(F);
customExit.add("open-experience");
tl.set(field, { attr: { "data-on": "0" } }, t);
tl.to([$("h1", el), $(".sub", el)], { opacity: 0, duration: 0.3 }, t);
const cy = top + ((rows - 1) * GY) / 2;
dots.forEach(({ dot, fx, fy }, i) => {
tl.to(dot, { x: 960 - fx, y: cy - fy, scale: 0.4, duration: 0.5, ease: "power3.in" }, t + (((i * 37) % 101) / 101) * 0.15);
});
tl.to(dots.map((x) => x.dot), { opacity: 0, duration: 0.15 }, t + 0.6);
};
// =====================================================================
// Table sequence
// =====================================================================
const POSE = { center: { y: 398, scale: 1 }, top: { y: 0, scale: 0.62 } };
const ROW_H = 78;
const tpl = $("#tpl-orders");
const TICK = '<span class="tick"><svg viewBox="0 0 24 24" fill="none" stroke="#050505" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5" /></svg></span>';
const SELECTED = 1; // the QA test order
function mountApp(slot) {
const variant = slot.dataset.variant;
const orders = tpl.content.firstElementChild.cloneNode(true);
const app = $(".app", orders);
const rows = $$(".row", orders);
rows.forEach((r, i) => {
r.style.top = `${i * ROW_H}px`;
if (variant === "identity") {
r.insertAdjacentHTML("afterbegin", '<span class="hl"></span>');
$(".box", r).insertAdjacentHTML("beforeend", TICK);
}
});
if (variant === "positional") {
// Selection stored by position: a highlight and a checkmark pinned to row slot 1.
$(".grid-body", orders).insertAdjacentHTML("afterbegin", '<div class="sel-slot"></div>');
$(".grid-body", orders).insertAdjacentHTML("beforeend", `<div class="sel-mark"><span class="c-check"><b class="box">${TICK}</b></span></div>`);
}
const ring = variant === "positional" ? "ring-bad pulse-bad" : "ring-good pulse-good";
$(".dialog", orders).insertAdjacentHTML("beforeend", `<span class="${ring}" style="inset: -10px; border-radius: 32px"></span>`);
slot.replaceWith(orders);
const sorted = [...rows].sort((a, b) => Number(b.dataset.total) - Number(a.dataset.total));
const target = variant === "positional" ? sorted[SELECTED] : rows[SELECTED];
$(".d-cust", orders).textContent = $(".c-cust", target).textContent;
$(".d-total", orders).textContent = $(".c-total", target).textContent;
return { orders, app, rows, sorted, variant, picked: rows[SELECTED] };
}
function appSelect(a, t) {
const sel = a.variant === "positional" ? [$(".sel-slot", a.app), $(".sel-mark .tick", a.app)] : [$(".hl", a.picked), $(".tick", a.picked)];
tl.to(sel, { opacity: 1, duration: 0.18, ease: "power1.out" }, t);
tl.fromTo($(".selbar", a.orders), { opacity: 0, y: 12 }, { opacity: 1, y: 0, duration: 0.3, ease: EASE, immediateRender: false }, t + 0.05);
}
function appSort(a, t, d = 0.85) {
tl.to($(".sort-arrow", a.app), { opacity: 1, duration: 0.2 }, t);
a.rows.forEach((r, i) => {
tl.to(r, { y: (a.sorted.indexOf(r) - i) * ROW_H, duration: d, ease: "power3.inOut" }, t);
});
}
function appDialog(a, t) {
tl.to($(".dim", a.app), { opacity: 1, duration: 0.3, ease: "power1.out" }, t);
tl.fromTo($(".dialog", a.orders), { opacity: 0, scale: 0.94, y: 20 }, { opacity: 1, scale: 1, y: 0, duration: 0.4, ease: EASE, immediateRender: false }, t + 0.05);
}
function appAppear(a, t) {
tl.fromTo(a.app, { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 0.6, ease: EASE, immediateRender: false }, t);
tl.fromTo(a.rows, { opacity: 0, x: -20 }, { opacity: 1, x: 0, duration: 0.35, stagger: 0.06, ease: EASE, immediateRender: false }, t + 0.2);
}
// Select, sort, delete. In the fixed run the camera follows the record.
function usageRun(cam, a, s, F) {
const c = addCursor(cam);
const qa = relPos($(".box", a.picked), cam);
const header = relPos($(".grid-head .c-total", a.app), cam);
const del = relPos($(".selbar .btn", a.orders), cam);
const dialogY = relPos($(".dialog", a.orders), cam)[1];
const follow = a.variant === "identity";
tl.set(c, { x: 1560, y: 980 }, s);
tl.to(c, { opacity: 1, duration: 0.25 }, s);
moveTo(c, qa, F[0], 0.85);
click(c, F[0] + 0.9);
appSelect(a, F[0] + 0.95);
camTo(cam, [960, qa[1], 1.45], F[0] + 1.05, 0.75);
moveTo(c, header, F[1], 0.75);
click(c, F[1] + 0.8);
appSort(a, F[1] + 0.9);
if (follow) camTo(cam, [960, qa[1] + 5 * ROW_H - 200, 1.45], F[1] + 0.95, 0.85);
camTo(cam, [960, 560, 1.12], F[2], 0.55);
moveTo(c, del, F[2] + 0.1, 0.7);
click(c, F[2] + 0.85);
appDialog(a, F[2] + 0.95);
camTo(cam, [960, dialogY, 1.55], F[2] + 1.05, 0.7);
}
build["table-prompt"] = ({ el, s, F }) => {
const cam = $(".cam", el);
camSet(cam, HOME, s);
const a = mountApp($(".app-slot", el));
const wrap = $(".composer-wrap", el);
const ask = $("[data-type]", el);
const askText = prepType(ask);
tl.set(a.app, { opacity: 0 }, s);
tl.set(wrap, POSE.center, s);
tl.fromTo(wrap, { opacity: 0 }, { opacity: 1, duration: 0.4, immediateRender: false }, s + 0.1);
typeIn(ask, askText, F[0], 1.6);
click($(".send", el), F[1]);
tl.to(wrap, { ...POSE.top, duration: 0.7, ease: "power3.inOut" }, F[1] + 0.1);
appAppear(a, F[1] + 0.45);
};
build["table-usage"] = ({ el, s, F }) => {
const cam = $(".cam", el);
camSet(cam, HOME, s);
const a = mountApp($(".app-slot", el));
tl.set($(".composer-wrap", el), POSE.top, s);
usageRun(cam, a, s, F);
// Extra beat: point at the wrong record.
if (F[4] !== undefined) {
const arrow = $(".callout-arrow", el);
tl.set(arrow, { opacity: 1 }, F[3]);
$$("path", arrow).forEach((p, i) => {
const len = Math.ceil(p.getTotalLength());
p.style.strokeDasharray = `${len}`;
tl.fromTo(p, { strokeDashoffset: len }, { strokeDashoffset: 0, duration: i ? 0.15 : 0.4, ease: "power2.out", immediateRender: false }, F[3] + (i ? 0.4 : 0));
});
tl.fromTo($(".callout", el), { opacity: 0, y: 14 }, { opacity: 1, y: 0, duration: 0.35, ease: EASE, immediateRender: false }, F[3] + 0.3);
}
};
build["table-rewind"] = ({ el, s, F }) => {
const cam = $(".cam", el);
const [slotBad, slotGood] = $$(".app-slot", el);
const bad = mountApp(slotBad);
const good = mountApp(slotGood);
const wrap = $(".composer-wrap", el);
const append = $(".append", el);
const appendText = prepType(append);
const chip = $(".rewind", el);
const dialogY = relPos($(".dialog", bad.orders), cam)[1];
// Start exactly where the broken run ended, zoomed on the dialog.
camSet(cam, [960, dialogY, 1.55], s);
tl.set(wrap, POSE.top, s);
tl.set(good.app, { opacity: 0 }, s);
tl.set([$(".sel-slot", bad.app), $(".sel-mark .tick", bad.app), $(".selbar", bad.orders), $(".sort-arrow", bad.app), $(".dim", bad.app), $(".dialog", bad.orders)], { opacity: 1 }, s);
bad.rows.forEach((r, i) => tl.set(r, { y: (bad.sorted.indexOf(r) - i) * ROW_H }, s));
// Rewind: undo everything, fast and in reverse.
tl.fromTo(chip, { opacity: 0, scale: 1.3 }, { opacity: 1, scale: 1, duration: 0.25, ease: EASE, immediateRender: false }, s);
camTo(cam, HOME, s + 0.1, 0.7);
tl.to([$(".dialog", bad.orders), $(".dim", bad.app)], { opacity: 0, duration: 0.25, ease: "power1.in" }, s + 0.15);
tl.to(bad.rows, { y: 0, duration: 0.5, ease: "power3.inOut" }, s + 0.4);
tl.to([$(".sel-slot", bad.app), $(".sel-mark .tick", bad.app), $(".sort-arrow", bad.app), $(".selbar", bad.orders)], { opacity: 0, duration: 0.2 }, s + 0.75);
tl.to(bad.app, { opacity: 0, y: 50, duration: 0.4, ease: "power2.in" }, s + 0.95);
tl.to(wrap, { ...POSE.center, duration: 0.6, ease: "power3.inOut" }, s + 1.05);
tl.to(chip, { opacity: 0, duration: 0.25 }, F[0] - 0.25);
typeIn(append, appendText, F[0] + 0.1, 0.9);
click($(".send", el), F[1]);
tl.to(wrap, { ...POSE.top, duration: 0.7, ease: "power3.inOut" }, F[1] + 0.1);
appAppear(good, F[1] + 0.45);
};
build["table-replay"] = ({ el, s, F }) => {
const cam = $(".cam", el);
camSet(cam, HOME, s);
const a = mountApp($(".app-slot", el));
tl.set($(".composer-wrap", el), POSE.top, s);
usageRun(cam, a, s, F);
// Then everything else Table handles: eight named, the wall, and way more.
if (F[5] !== undefined) exitIntoWatermark(el, beatMore(el, "table", F[3], F[4], 8), lastOf(F));
};
// =====================================================================
// Rough library beats: prompt, working app, simulated use reveals the
// problem, rewind and append "Use TanStack X.", same use, one line of why.
// The stage markup (templates in index.html) declares what happens.
// =====================================================================
function mountStage(slot, scene, cam) {
const variant = slot.dataset.variant;
const stage = $(`#${scene.dataset.tpl}`).content.firstElementChild.cloneNode(true);
$$(variant === "bad" ? ".only-good" : ".only-bad", stage).forEach((n) => n.remove());
$$("[data-cls-bad]", stage).forEach((n) => n.classList.add(variant === "bad" ? n.dataset.clsBad : n.dataset.clsGood));
slot.replaceWith(stage);
// data-fit="selector": size an outline to the union of matching elements.
// Measured in stage space, then placed in the ring's own parent.
const stagePos = (n) => {
let x = 0;
let y = 0;
for (let p = n; p && p !== stage; p = p.offsetParent) {
x += p.offsetLeft;
y += p.offsetTop;
}
return [x, y];
};
$$("[data-fit]", stage).forEach((ring) => {
const boxes = $$(ring.dataset.fit, stage).map((n) => {
const [x, y] = stagePos(n);
return [x, y, x + n.offsetWidth, y + n.offsetHeight];
});
if (!boxes.length) return;
const pad = num(ring.dataset.fitPad, 6);
const [px, py] = ring.offsetParent === stage ? [0, 0] : stagePos(ring.offsetParent);
const x0 = Math.min(...boxes.map((b) => b[0])) - pad - px;
const y0 = Math.min(...boxes.map((b) => b[1])) - pad - py;
ring.style.left = `${x0}px`;
ring.style.top = `${y0}px`;
ring.style.width = `${Math.max(...boxes.map((b) => b[2])) + pad - px - x0}px`;
ring.style.height = `${Math.max(...boxes.map((b) => b[3])) + pad - py - y0}px`;
});
const hud = document.createElement("div");
hud.className = "stage abs";
hud.style.inset = "0";
$$(".hud", stage).forEach((n) => hud.appendChild(n));
$(".hud-layer", scene).appendChild(hud);
const cursor = addCursor(stage);
return { stage, hud, variant, cursor, all: (sel) => [...$$(sel, stage), ...$$(sel, hud)] };
}
function showStage(m, t) {
tl.set(m.cursor, { x: 1500, y: 960 }, t);
tl.fromTo(m.stage, { opacity: 0, y: 40 }, { opacity: 1, y: 0, duration: 0.6, ease: EASE, immediateRender: false }, t);
tl.fromTo(m.hud, { opacity: 0 }, { opacity: 1, duration: 0.3, immediateRender: false }, t);
if (m.all("[data-click]").length) tl.to(m.cursor, { opacity: 1, duration: 0.25 }, t + 0.35);
}
function useStage(m, t, scene, cam) {
const { variant, cursor } = m;
const clicks = m.all("[data-click]").sort((a, b) => Number(a.dataset.click) - Number(b.dataset.click));
clicks.forEach((target, k) => {
// data-click-at pins the click moment; otherwise clicks run 1.1s apart.
const at = target.dataset.clickAt !== undefined ? t + Number(target.dataset.clickAt) - 0.65 : t + k * 1.1;
moveTo(cursor, relPos(target, cam), at, 0.6);
click(cursor, at + 0.65);
});
const reveal = clicks.length ? t + (clicks.length - 1) * 1.1 + 0.9 : t + 0.9;
// data-hover-at: the cursor drifts over an element and rests there, no click.
m.all("[data-hover-at]").forEach((target) => moveTo(cursor, relPos(target, cam), t + Number(target.dataset.hoverAt), 0.6));
// Between the first and second click.
const s1 = m.all(".s1");
if (s1.length) {
tl.fromTo(s1, { opacity: 0, scale: 0.96 }, { opacity: 1, scale: 1, duration: 0.35, ease: EASE, immediateRender: false }, t + 0.75);
tl.to(s1, { opacity: 0, duration: 0.3 }, reveal - 0.1);
}
// Typing can pause: "tanner|tanner_dev" with matching "|" separated at and dur.
m.all("[data-type-to]").forEach((el) => {
const text = (variant === "bad" && el.dataset.typeToBad) || el.dataset.typeTo;
const durs = ((variant === "bad" && el.dataset.typeDurBad) || el.dataset.typeDur || "0.7").split("|");
const ats = (el.dataset.typeAt || "0.1").split("|");
text.split("|").forEach((part, i) => typeIn(el, part, t + Number(ats[i]), Number(durs[i])));
});
m.all("[data-out]")
.filter((n) => n.dataset.out === "both" || n.dataset.out === variant)
.forEach((n) => {
const at = n.dataset.outAt ? t + Number(n.dataset.outAt) : reveal - 0.05;
if (n.dataset.to) {
const [dx, dy] = pair(n.dataset.to);
tl.to(n, { opacity: 0, x: dx, y: dy, duration: 0.4, ease: "power2.in" }, at);
} else {
tl.to(n, { opacity: 0, duration: 0.25, ease: "power1.out" }, at);
}
});
m.all(".b").forEach((n) => {
const at = n.dataset.at ? t + Number(n.dataset.at) : reveal;
if (n.dataset.grow) {
const [g0, gd] = pair(n.dataset.grow);
tl.set(n, { opacity: 1 }, t + g0);
tl.fromTo(n, { scaleX: 0 }, { scaleX: 1, duration: gd, ease: "none", immediateRender: false }, t + g0);
} else if (n.dataset.growY) {
const [g0, gd] = pair(n.dataset.growY);
tl.set(n, { opacity: 1 }, t + g0);
tl.fromTo(n, { scaleY: 0 }, { scaleY: 1, duration: gd, ease: "power1.in", immediateRender: false }, t + g0);
} else if (n.dataset.from) {
const [dx, dy] = pair(n.dataset.from);
tl.fromTo(n, { opacity: 0, x: dx, y: dy }, { opacity: 1, x: 0, y: 0, duration: 0.5, ease: "power2.out", immediateRender: false }, at);
} else {
tl.fromTo(n, { opacity: 0, scale: 0.94 }, { opacity: 1, scale: 1, duration: 0.3, ease: EASE, immediateRender: false }, at);
}
});
// data-count="from,to,start,dur": a formatted number that counts up.
m.all("[data-count]").forEach((el) => {
const [from, to, c0, cd] = pair(el.dataset.count);
tl.fromTo(el, { innerText: from }, { innerText: to, duration: cd, ease: "power2.in", immediateRender: false, modifiers: { innerText: (v) => Math.round(Number(v)).toLocaleString("en-US") } }, t + c0);
});
// data-move / data-move-bad / data-move-good="x,y,start,dur": move to an offset.
m.all("[data-move], [data-move-bad], [data-move-good]").forEach((el) => {
const spec = el.dataset[variant === "bad" ? "moveBad" : "moveGood"] || el.dataset.move;
if (!spec) return;
// Several moves can be chained with ";".
spec.split(";").forEach((one) => {
const [x, y, at, dur] = pair(one);
tl.to(el, { x, y, duration: dur, ease: "power2.inOut" }, t + at);
});
});
// data-shake-bad / data-shake-good="start": a short stutter.
m.all(`[data-shake-${variant}]`).forEach((el) => {
const at = t + Number(el.dataset[variant === "bad" ? "shakeBad" : "shakeGood"]);
[10, -8, 6, -4, 0].forEach((x, i) => tl.to(el, { x, duration: 0.07, ease: "none" }, at + i * 0.07));
});
m.all("[data-draw]").forEach((line) => {
const len = Math.ceil(line.getTotalLength ? line.getTotalLength() : 1500) || 1500;
line.style.strokeDasharray = `${len}`;
tl.fromTo(line, { strokeDashoffset: len }, { strokeDashoffset: 0, duration: 0.9, ease: "power2.inOut", immediateRender: false }, reveal);
});
const z = scene.dataset[variant === "bad" ? "zoomBad" : "zoomGood"];
if (z) {
const zt = scene.dataset.zoomAt ? t + Number(scene.dataset.zoomAt) : reveal + 0.35;
camTo(cam, pair(z), zt, 0.8);
// The eyebrow would sit half cut off at the top edge while zoomed.
tl.to($(".eyebrow", scene), { opacity: 0, duration: 0.3 }, zt);
}
}
function roughBeat({ el, s, F }) {
// data-use-holds="e": e extra presenter stops inside each "use" phase.
// The stage markup times its steps between them; the engine skips over them.
const e = num(el.dataset.useHolds, 0);
// data-land-app: the app is already on screen when the slide lands, so the
// first stop is the start of use (no separate "here's the app" click).
if (el.dataset.landApp !== undefined) F = [s + 0.25, ...F];
if (e) F = [F[0], F[1], F[2 + e], F[3 + e], F[4 + e], F[5 + 2 * e], F[6 + 2 * e], F[7 + 2 * e], F[8 + 2 * e]].filter((f) => f !== undefined);
const cam = $(".cam", el);
camSet(cam, HOME, s);
const [slotBad, slotGood] = $$(".stage-slot", el);
const bad = mountStage(slotBad, el, cam);
const good = mountStage(slotGood, el, cam);
const append = $(".append", el);
const appendText = prepType(append);
const chip = $(".rewind", el);
tl.fromTo($(".rc", el), { opacity: 0, y: 20 }, { opacity: 1, y: 0, duration: 0.5, ease: EASE, immediateRender: false }, s + 0.1);
showStage(bad, F[0]);
useStage(bad, F[1], el, cam);
tl.fromTo(chip, { opacity: 0, scale: 1.3 }, { opacity: 1, scale: 1, duration: 0.25, ease: EASE, immediateRender: false }, F[2]);
camTo(cam, HOME, F[2] + 0.1, 0.6);
tl.to($(".eyebrow", el), { opacity: 1, duration: 0.4 }, F[2] + 0.3);
tl.to([bad.stage, bad.hud], { opacity: 0, y: 30, duration: 0.45, ease: "power2.in" }, F[2] + 0.25);
tl.to(chip, { opacity: 0, duration: 0.25 }, F[2] + 1.0);
typeIn(append, appendText, F[2] + 0.75, 0.8);
showStage(good, F[3]);
useStage(good, F[4], el, cam);
camTo(cam, HOME, F[5], 0.7);
rise($(".why", el), F[5] + 0.2, 0.6, 20);
if (F[8] !== undefined) {
const more = beatMore(el, el.dataset.lib || el.dataset.compositionId, F[6], F[7]);
if (more) exitIntoWatermark(el, more, lastOf(F));
}
}
// Side by side: the same prompt twice, plain on the left and with
// "Use TanStack X." on the right, used with the same clicks at once.
// data-duo="x0,y0,x1,y1": the template area to show, scaled to fit each half.
function duoBeat({ el, s, F }) {
const e = num(el.dataset.useHolds, 0);
const cam = $(".cam", el);
camSet(cam, HOME, s);
const [x0, y0, x1, y1] = pair(el.dataset.duo);
const sc = Math.min(840 / (x1 - x0), 590 / (y1 - y0), 1);
$$(".duo-label", el).forEach((n, i) => (n.style.left = `${(i ? 1420 : 500) - ((x1 - x0) * sc) / 2}px`));
const [bad, good] = $$(".stage-slot", el).map((slot, i) => {
const wrap = document.createElement("div");
wrap.className = "abs";
wrap.style.cssText = `inset: 0; transform-origin: 0 0; transform: translate(${(i ? 1420 : 500) - ((x0 + x1) / 2) * sc}px, ${345 - y0 * sc}px) scale(${sc})`;
slot.before(wrap);
wrap.appendChild(slot);
const m = mountStage(slot, el, cam);
wrap.appendChild(m.hud);
return m;
});
tl.fromTo($(".rc", el), { opacity: 0, y: 20 }, { opacity: 1, y: 0, duration: 0.5, ease: EASE, immediateRender: false }, s + 0.1);
$$(".duo-label", el).forEach((n) => rise(n, F[0], 0.5, 20));
showStage(bad, F[0]);
showStage(good, F[0]);
useStage(bad, F[1], el, cam);
useStage(good, F[1], el, cam);
// As the use finishes, the prompt picks up "Use TanStack X." and the why
// line lands on their own, so the last stop holds the finished beat.
const ap = $(".rc .append", el);
if (ap) typeIn(ap, prepType(ap), F[2 + e] - 1.2, 0.7);
rise($(".why", el), F[2 + e] - 0.8, 0.6, 20);
if (F[5 + e] !== undefined) {
const more = beatMore(el, el.dataset.lib || el.dataset.compositionId, F[3 + e], F[4 + e]);
if (more) exitIntoWatermark(el, more, lastOf(F));
}
}
$$(".scene[data-tpl]").forEach((el) => {
build[el.dataset.compositionId] = el.dataset.duo ? duoBeat : roughBeat;
});
// =====================================================================
// Text beats
// =====================================================================
build["more"] = ({ el, s, F }) => {
rise($("h1", el), s + 0.2, 0.7);
$$(".names .floater > span", el).forEach((n, i) => {
tl.fromTo(n, { opacity: 0, y: 40, scale: 0.9 }, { opacity: 1, y: 0, scale: 1, duration: 0.5, ease: EASE, immediateRender: false }, (i < 4 ? F[0] : F[1]) + (i % 4) * 0.12);
});
};
build["flash"] = ({ el, s, F }) => {
const cam = $(".cam", el);
camSet(cam, HOME, s);
rise($(".flash-head", el), s + 0.15, 0.6, 16);
const cols = $$(".ec-col", el);
const cards = $$(".ec", el);
cols.forEach((col, c) => {
$$(".ec", col).forEach((card, r) => {
tl.fromTo(card, { opacity: 0, y: 30, scale: 0.94 }, { opacity: 1, y: 0, scale: 1, duration: 0.35, ease: EASE, immediateRender: false }, F[0] + r * 0.12 + c * 0.035);
tl.fromTo($(".ec-ok", card), { opacity: 0, scale: 0.3 }, { opacity: 1, scale: 1, duration: 0.3, ease: "back.out(2)", immediateRender: false }, F[1] + r * 0.09 + c * 0.05);
});
});
camTo(cam, [960, 700, 0.78], F[2], 1.0);
tl.to(cards, { opacity: 0.25, duration: 0.6 }, F[2] + 0.3);
rise($(".flash-count", el), F[2] + 0.4, 0.6);
tl.fromTo($(".count-n", el), { innerText: 0 }, { innerText: cards.length, snap: { innerText: 1 }, duration: 0.9, ease: "power2.out", immediateRender: false }, F[2] + 0.4);
// Exit: every card collapses into the count, which carries to the next slide.
const t = lastOf(F);
customExit.add("flash");
cards.forEach((card, i) => {
const [x, y] = relPos(card, cam);
tl.to(card, { x: 960 - x, y: 649 - y, scale: 0.1, opacity: 0, duration: 0.45, ease: "power2.in" }, t + (i % 9) * 0.02);
});
tl.to($(".flash-head", el), { opacity: 0, duration: 0.3 }, t);
tl.to($(".count-l", el), { opacity: 0, duration: 0.25 }, t);
tl.to($(".count-n", el), { scale: 1.25, opacity: 0, duration: 0.4, ease: "power2.in" }, t + 0.3);
};
build["savings"] = ({ el, s, F }) => {
const total = $$("#flash .ec").length;
rise($("h1", el), s + 0.2, 0.7);
tl.set($(".cycle", el), { opacity: 1 }, s);
tl.fromTo($(".cy-ring", el), { opacity: 0 }, { opacity: 1, duration: 0.5, immediateRender: false }, s + 0.3);
$$(".cy-node", el).forEach((n, i) => rise(n, s + 0.35 + i * 0.1, 0.4, 16));
rise($(".times", el), F[0], 0.5);
tl.fromTo($(".times .count-n", el), { innerText: 0 }, { innerText: total, snap: { innerText: 1 }, duration: 0.9, ease: "power2.out", immediateRender: false }, F[0] + 0.1);
rise($(".legend", el), F[1], 0.4, 12);
$$(".m-label", el).forEach((l, i) => rise(l, F[1] + 0.1 + i * 0.15, 0.4, 12));
$$(".m-bar.self", el).forEach((b, i) => {
tl.set(b, { opacity: 1 }, F[1] + 0.2 + i * 0.15);
tl.fromTo(b, { scaleX: 0 }, { scaleX: 1, duration: 1.0, ease: "power2.out", immediateRender: false }, F[1] + 0.2 + i * 0.15);
});
$$(".m-bar.ts-bar", el).forEach((b, i) => {
tl.set(b, { opacity: 1 }, F[2] + i * 0.12);
tl.fromTo(b, { scaleX: 0 }, { scaleX: 1, duration: 0.4, ease: "power2.out", immediateRender: false }, F[2] + i * 0.12);
});
};
build["oracles"] = ({ el, s, F }) => {
rise($("h1", el), s + 0.2, 0.7);
rise($(".audit", el), s + 0.4, 0.6);
tl.to($(".scanbar", el), { opacity: 1, duration: 0.4 }, s + 0.6);
$$(".audit-row", el).forEach((r, i) => {
tl.fromTo(r, { opacity: 0, x: -24 }, { opacity: 1, x: 0, duration: 0.45, ease: EASE, immediateRender: false }, F[i]);
});
};
build["intent"] = ({ el, s, F }) => {
rise($("h1", el), s + 0.2, 0.7);
rise($(".pkg", el), s + 0.4, 0.6);
tl.fromTo($(".arrow", el), { opacity: 0 }, { opacity: 1, duration: 0.4, immediateRender: false }, F[0]);
rise($(".agent", el), F[0] + 0.1, 0.5);
$$(".skill.fly", el).forEach((sk, i) => {
tl.fromTo(sk, { opacity: 0, x: -900, y: 54 }, { opacity: 1, x: 0, y: 0, duration: 0.8, ease: "power3.inOut", immediateRender: false }, F[0] + 0.3 + i * 0.18);
});
};
build["trust"] = ({ el, s, F }) => {
rise($(".pill-ex", el), s + 0.1, 0.5, 14);
rise($(".t", el), s + 0.2, 0.7);
$$(".names > span > span", el).forEach((w, i) => {
tl.fromTo(w, { opacity: 0, y: 30 }, { opacity: 1, y: 0, duration: 0.5, ease: EASE, immediateRender: false }, F[i]);
});
};
build["close"] = ({ el, s, F }) => {
// The close has its own big logo, so the corner watermark steps aside.
tl.to($(".watermark"), { opacity: 0, duration: 0.3 }, s);
const cam = $(".cam", el);
camSet(cam, [960, 520, 1.12], s);
const wrap = $(".composer-wrap", el);
const comp = $(".composer", el);
tl.set(wrap, { opacity: 0 }, s);
rise(wrap, s + 0.1, 0.6);
// One click: "Use TanStack." types after "Make no mistakes.", then the
// words turn into the logo and the library families settle in beneath it.
const mnm = $(".close-mnm", el);
// Measure where "TanStack" will sit, before the spans are cleared for typing.
const ts = $(".ca-ts", el);
let tx = 0;
let ty = 0;
for (let n = ts; n && n !== cam; n = n.offsetParent) {
tx += n.offsetLeft;
ty += n.offsetTop;
}
const tsW = ts.offsetWidth;
const tcx = tx + tsW / 2;
const tcy = ty + ts.offsetHeight / 2;
// Type the three pieces in sequence so they stay separate spans.
const parts = [".ca-use", ".ca-ts", ".ca-dot"].map((c) => $(c, el));
const texts = parts.map((p) => prepType(p));
let at = F[0] + 0.2;
texts.forEach((txt, i) => {
const dur = 0.6 * (txt.length / texts.join("").length);
typeIn(parts[i], txt, at, dur);
at += dur;
});
const t = at + 0.35;
camTo(cam, HOME, t, 0.9);
tl.to(comp, { backgroundColor: "rgba(20, 20, 20, 0)", borderColor: "rgba(255, 255, 255, 0)", boxShadow: "0 0 0 rgba(0,0,0,0)", duration: 0.4 }, t);
// display, not opacity: the live caret blink owns its opacity.
tl.set($$(".caret", el), { display: "none" }, t);
tl.to([$(".ask", el), $(".send", el)], { opacity: 0, duration: 0.3 }, t);
// The morph: "Make no mistakes.", "Use" and "." fall away, "TanStack" glides onto the logo's
// wordmark at the same size, then hands off to it as the palm pops in.
const LOGO_Y = 422;
const WORD_CX = 1016;
const WORD_W = 688;
tl.to([mnm, parts[0], parts[2]], { opacity: 0, y: 12, duration: 0.3, ease: "power2.in" }, t);
tl.to(ts, { x: WORD_CX - tcx, y: LOGO_Y - tcy, scale: WORD_W / tsW, duration: 0.8, ease: "power3.inOut" }, t + 0.15);
const logo = $(".close-logo", el);
tl.set(logo, { opacity: 1 }, t + 0.8);
tl.set($(".lg-word", el), { opacity: 0 }, s);
tl.set($(".lg-mark", el), { scale: 0, svgOrigin: "19 25" }, s);
tl.to($(".lg-word", el), { opacity: 1, duration: 0.3, ease: "power1.out" }, t + 0.85);
tl.to(ts, { opacity: 0, duration: 0.3, ease: "power1.in" }, t + 0.9);
tl.to($(".lg-mark", el), { scale: 1, duration: 0.55, ease: "back.out(2.2)" }, t + 0.95);
tl.fromTo($(".fin-glow", el), { opacity: 0, scale: 0.4 }, { opacity: 1, scale: 1, duration: 1.4, ease: "expo.out", immediateRender: false }, t + 0.9);
// Then it rises and the families fill in below, like the start of the talk.
tl.to([logo, $(".fin-glow", el)], { y: -230, scale: 0.72, duration: 0.8, ease: "power3.inOut" }, t + 2.0);
const groups = $(".fin-groups", el);
$$(".mm-col", groups).forEach((col, i) => {
const at = t + 2.4 + i * 0.12;
tl.fromTo($(".mm-head", col), { opacity: 0, y: 16 }, { opacity: 1, y: 0, duration: 0.45, ease: EASE, immediateRender: false }, at);
$$(".mm-lib", col).forEach((n, k) => tl.fromTo(n, { opacity: 0, y: 18 }, { opacity: 1, y: 0, duration: 0.45, ease: EASE, immediateRender: false }, at + 0.08 + k * 0.05));
});
rise($(".fin-thanks", el), F[1], 0.8, 24);
};
// =====================================================================
// Step slides: markup declares what happens on each click.
// Step 0 is on screen when the slide lands; step k plays on click k.
// data-s-in="k" rise in (data-s-stagger="0.08" staggers its children)
// data-s-out="k" fade out
// data-s-type="k" type the element's text (data-s-dur)
// data-s-draw="k" draw an SVG path (data-s-dur)
// data-s-move="x,y,k,dur" move by an offset
// data-s-count="k" count up to data-s-to (data-s-pre, data-s-suf, data-s-dec, data-s-dur)
// data-s-delay shifts the entrance by seconds; data-s-out-delay shifts the exit.
// =====================================================================
function stepBeat({ el, s, F }) {
const T = (k) => (k <= 0 ? s + 0.2 : F[k - 1]);
const at = (n, attr) => T(Number(n.getAttribute(attr))) + num(n.dataset.sDelay, 0);
$$("[data-s-in]", el).forEach((n) => {
const t = at(n, "data-s-in");
if (n.dataset.sStagger) {
// Children start hidden so the container can switch on without a flash.
tl.set([...n.children], { opacity: 0 }, s);
tl.set(n, { opacity: 1 }, t);
tl.fromTo([...n.children], { opacity: 0, y: 24, scale: 0.96 }, { opacity: 1, y: 0, scale: 1, duration: 0.45, ease: EASE, stagger: Number(n.dataset.sStagger), immediateRender: false }, t);
} else {
tl.fromTo(n, { opacity: 0, y: 28 }, { opacity: 1, y: 0, duration: 0.6, ease: EASE, immediateRender: false }, t);
}
});
// Exits are immediate on their click unless data-s-out-delay says otherwise
// (data-s-delay only shifts the entrance).
$$("[data-s-out]", el).forEach((n) => tl.to(n, { opacity: 0, duration: 0.3, ease: "power1.out" }, T(Number(n.dataset.sOut)) + num(n.dataset.sOutDelay, 0)));
$$("[data-s-type]", el).forEach((n) => typeIn(n, prepType(n), at(n, "data-s-type"), num(n.dataset.sDur, 0.6)));
$$("[data-s-draw]", el).forEach((p) => {
const len = Math.ceil(p.getTotalLength()) || 1500;
p.style.strokeDasharray = `${len}`;
tl.set(p, { strokeDashoffset: len }, s);
tl.to(p, { strokeDashoffset: 0, duration: num(p.dataset.sDur, 1.2), ease: "power2.inOut" }, at(p, "data-s-draw"));
});
// data-s-count="k" counts up to data-s-to, formatted with data-s-pre / data-s-suf / data-s-dec.
$$("[data-s-count]", el).forEach((n) => {
const dec = num(n.dataset.sDec, 0);
const fmt = (v) => `${n.dataset.sPre || ""}${Number(v).toLocaleString("en-US", { minimumFractionDigits: dec, maximumFractionDigits: dec })}${n.dataset.sSuf || ""}`;
n.textContent = fmt(0);
tl.fromTo(n, { innerText: 0 }, { innerText: Number(n.dataset.sTo), duration: num(n.dataset.sDur, 2), ease: "power1.inOut", immediateRender: false, modifiers: { innerText: fmt } }, at(n, "data-s-count"));
});
$$("[data-s-move]", el).forEach((n) => {
const [x, y, k, d] = pair(n.dataset.sMove);
tl.to(n, { x, y, duration: d, ease: "power2.inOut" }, T(k) + num(n.dataset.sDelay, 0));
});
}
$$(".scene[data-steps]").forEach((el) => {
build[el.dataset.compositionId] = stepBeat;
});
// Every word carries weight: the tool names in the prompt swell as we talk about them.
build["open-magic"] = (args) => {
stepBeat(args);
const { el, F } = args;
$$(".mw-w", el).forEach((w, i) => tl.fromTo(w, { scale: 1, textShadow: "0 0 0px rgba(255,255,255,0)" }, { scale: 1.12, textShadow: "0 0 24px rgba(255,255,255,0.35)", duration: 0.5, ease: "back.out(2.2)", immediateRender: false }, F[0] + 0.6 + i * 0.18));
// Then they flicker out: easy to leave out.
$$(".mw-w", el).forEach((w, i) => tl.to(w, { opacity: 0.15, scale: 1, duration: 0.35, ease: "power2.in" }, F[1] + 0.2 + i * 0.12));
};
// Start 1.0: the title lands big and centered, then makes room for the chart.
build["start-1"] = (args) => {
stepBeat(args);
const { el, s, F } = args;
const head = $(".s1-head", el);
const sub = $(".s1-sub", el);
tl.set(head, { top: 390, scale: 1.3 }, s);
tl.set(sub, { top: 545 }, s);
tl.to(head, { top: 80, scale: 1, duration: 0.9, ease: "power3.inOut" }, F[0]);
tl.to(sub, { top: 186, duration: 0.9, ease: "power3.inOut" }, F[0]);
};
// Migrate: "Use" backspaces out and "Migrate to" types in its place.
build["start-migrate"] = (args) => {
stepBeat(args);
const { el, F } = args;
const verb = $(".mg-verb", el);
tl.to(verb, { text: { value: "" }, duration: 0.25, ease: "none" }, F[0] + 0.3);
tl.set(verb, { color: "#69bc75" }, F[0] + 0.6);
tl.to(verb, { text: { value: "Migrate to" }, duration: 0.55, ease: "none" }, F[0] + 0.65);
};
// Start: the problem pills fly off the wall and land on the timeline, one per
// stop, then the timeline's own (smaller) pill takes over.
build["start-wall"] = (args) => {
stepBeat(args);
const { el, s, F } = args;
const cam = $(".cam", el);
const center = (n) => {
let x = 0;
let y = 0;
for (let p = n; p && p !== cam; p = p.offsetParent) {
x += p.offsetLeft;
y += p.offsetTop;
}
return [x + n.offsetWidth / 2, y + n.offsetHeight / 2];
};
// The Acme sparkline draws once as the site appears (its ping dot loops in CSS).
const spark = $(".acme-spark path", el);
tl.set(spark, { strokeDashoffset: 400 }, s);
tl.to(spark, { strokeDashoffset: 0, duration: 1.4, ease: "power2.out" }, F[0] + 0.5);
const from = $$(".wall-bad .pchip", el);
const to = $$(".tl-boxes .pchip", el);
from.forEach((chip, i) => {
const target = to[i];
const [cx, cy] = center(chip);
const [tx, ty] = center(target);
const land = F[2] + 0.6 + i * 0.28 + 0.35;
tl.set(target, { opacity: 0 }, s);
tl.to(chip, { x: tx - cx, y: ty - cy, scale: target.offsetWidth / chip.offsetWidth, duration: 0.7, ease: "power3.inOut" }, land - 0.7);
tl.set(target, { opacity: 1 }, land);
tl.set(chip, { opacity: 0 }, land);
});
// Exit (a long one): the fixes and an endless field of more fixes are one
// strip. It starts slow, accelerates to light speed, streaks, and fades.
customExit.add("start-wall");
const t = lastOf(F);
const X = EXIT_LONG["start-wall"];
const mega = $(".mega", el);
tl.fromTo($(".stream-line", el), { opacity: 0, y: 24 }, { opacity: 1, y: 0, duration: 0.6, ease: EASE, immediateRender: false }, t + 0.1);
// Center each row's two fixes, then the rest of the row (hidden until now)
// fades in at the same spacing as the strip starts to move.
$$(".mega-row", el).forEach((row) => {
const [a, b] = row.children;
const w = b.offsetLeft + b.offsetWidth - a.offsetLeft;
row.style.left = `${960 - w / 2}px`;
});
const extras = $$(".mx", el);
tl.set(extras, { opacity: 0 }, s);
tl.to(extras, { opacity: 1, duration: 0.35, stagger: 0.012 }, t + 0.05);
tl.to(mega, { x: -15000, duration: X - 0.15, ease: "expo.in" }, t);
tl.to(mega, { scaleX: 1.6, filter: "blur(10px)", duration: 0.7, ease: "power2.in" }, t + X - 0.85);
tl.to(mega, { opacity: 0, duration: 0.45, ease: "power1.in" }, t + X - 0.5);
tl.to([$(".rc", el), $(".stream-line", el)], { opacity: 0, duration: 0.45 }, t + X - 0.5);
};
// A year ago: the reveal uses the official Start lockup from the 1.0 launch.
// Glow, then the icon builds (bars, the sun rising, rays), the wordmark lands,
// and the prompt types itself.
build["start-year"] = (args) => {
stepBeat(args);
const { el, s, F } = args;
const t = F[3];
const q = (c) => $(c, el);
// Hidden from the scene start so nothing shows before its own entrance.
tl.set([q(".sr-glow"), q(".sr-logo"), q(".sr-word"), q(".sr-label"), q(".sr-composer")], { opacity: 0 }, s);
tl.set($$(".si-ray", el), { opacity: 0, scale: 0.2, svgOrigin: "100 92" }, s);
tl.set([q(".si-bar1"), q(".si-bar2")], { scaleX: 0, transformOrigin: "50% 50%" }, s);
tl.set(q(".sr-rule"), { scaleX: 0 }, s);
tl.set(q(".si-sun"), { y: 60 }, s);
tl.fromTo(q(".sr-glow"), { opacity: 0, scale: 0.4 }, { opacity: 1, scale: 1, duration: 1.4, ease: "expo.out", immediateRender: false }, t);
tl.to([q(".si-bar1"), q(".si-bar2")], { scaleX: 1, duration: 0.5, ease: "power3.out", stagger: 0.08 }, t + 0.15);
tl.fromTo(q(".si-sun"), { y: 60 }, { y: 0, duration: 0.8, ease: "power3.out", immediateRender: false }, t + 0.35);
tl.to($$(".si-ray", el), { opacity: 1, scale: 1, duration: 0.45, ease: "back.out(2.4)", stagger: 0.07 }, t + 0.8);
tl.fromTo(q(".sr-logo"), { opacity: 0, y: 16 }, { opacity: 1, y: 0, duration: 0.5, ease: EASE, immediateRender: false }, t + 0.9);
tl.fromTo(q(".sr-word"), { opacity: 0, y: 40, scale: 0.94 }, { opacity: 1, y: 0, scale: 1, duration: 0.7, ease: "expo.out", immediateRender: false }, t + 1.0);
tl.fromTo(q(".sr-rule"), { scaleX: 0 }, { scaleX: 1, duration: 0.8, ease: "power3.inOut", immediateRender: false }, t + 1.3);
tl.fromTo(q(".sr-label"), { opacity: 0, y: 14 }, { opacity: 1, y: 0, duration: 0.5, ease: EASE, immediateRender: false }, t + 1.6);
tl.fromTo(q(".sr-composer"), { opacity: 0, y: 24 }, { opacity: 1, y: 0, duration: 0.5, ease: EASE, immediateRender: false }, t + 1.75);
const ty = q(".sr-type");
typeIn(ty, prepType(ty), t + 2.1, 0.7);
};
// Before AI: the prompt plate from the stack lands here, tilts flat, and grows
// into what a prompt used to be. Then it collapses to one line and the dice roll.
build["open-before"] = (args) => {
stepBeat(args);
const { el, s, F } = args;
const tilt = $(".pc-tilt", el);
const card = $(".pc-card", el);
// Start in the stack's iso pose, centered where the plate sat (900, 441).
tl.set(tilt, { x: 900 - 500, y: 441 - 560, rotationX: 58, transformPerspective: 5200 }, s);
const spin = $(".pc-spin", el);
tl.set(spin, { rotation: -45, scale: 0.52, height: 720 }, s);
tl.to(tilt, { x: 0, y: 0, rotationX: 0, duration: 1.1, ease: "power3.inOut" }, s + 0.1);
tl.to(spin, { rotation: 0, scale: 1, height: 620, duration: 1.1, ease: "power3.inOut" }, s + 0.1);
// The plate's thickness folds away behind the card as it faces us.
tl.to($$(".pc-side", el), { opacity: 0, duration: 0.4 }, s + 0.8);
tl.to($(".pc-bars", el), { opacity: 0, duration: 0.3 }, s + 0.6);
tl.fromTo($(".pc-text", el), { opacity: 0 }, { opacity: 1, duration: 0.4, immediateRender: false }, s + 0.75);
// Skipping the decisions: the card shrinks to the one-line prompt, centered.
tl.to(tilt, { x: 960 - 500, y: 90, duration: 0.9, ease: "power3.inOut" }, F[2] + 0.2);
tl.to(spin, { height: 150, duration: 0.9, ease: "power3.inOut" }, F[2] + 0.2);
// The dice tumble in, bounce, and settle on new faces.
$$(".die", el).forEach((die, k) => {
const at = F[3] + 0.15 + k * 0.12;
const faces = $$(".die-face", die);
tl.set(die, { opacity: 1 }, at);
tl.fromTo(die, { x: 760 - k * 120, rotation: 760 + k * 140 }, { x: 0, rotation: k ? -8 : 6, duration: 1.3, ease: "power3.out", immediateRender: false }, at);
tl.fromTo(die, { y: -320 }, { y: 0, duration: 1.15, ease: "bounce.out", immediateRender: false }, at);
faces.forEach((f, i) => {
tl.set(f, { opacity: i === 0 ? 1 : 0 }, s);
if (i) {
tl.set(faces[i - 1], { opacity: 0 }, at + i * 0.28);
tl.set(f, { opacity: 1 }, at + i * 0.28);
}
});
});
};
// Builders can outlive their scenes when a beat is cut; skip those.
for (const id of Object.keys(build)) if (document.getElementById(id)) build[id](slide(id));
// =====================================================================
// Letter magic move between consecutive text slides with no shared
// elements: matching letters fly from the old headline to the new one.
// =====================================================================
function splitChars(h) {
// A headline can be both the end of one move and the start of the next; split once.
if (h.dataset.mmSplit) return $$(".mm-c", h);
h.dataset.mmSplit = "1";
const walk = (node) => {
[...node.childNodes].forEach((n) => {
if (n.nodeType === 3) {
const frag = document.createDocumentFragment();
n.textContent.split(/(\s+)/).forEach((part) => {
if (!part) return;
if (/^\s+$/.test(part)) return frag.appendChild(document.createTextNode(part));
const w = document.createElement("span");
w.className = "mm-w";
[...part].forEach((ch) => {
const c = document.createElement("span");
c.className = "mm-c";
c.textContent = ch;
w.appendChild(c);
});
frag.appendChild(w);
});
n.replaceWith(frag);
} else if (n.nodeType === 1) walk(n);
});
};
walk(h);
return $$(".mm-c", h);
}
function charBoxes(chars, cam) {
return chars.map((c) => {
let x = 0;
let y = 0;
for (let n = c; n && n !== cam; n = n.offsetParent) {
x += n.offsetLeft;
y += n.offsetTop;
}
return { c, x, y, ch: c.textContent };
});
}
const killFrom = (target, time) => tl.getTweensOf(target).forEach((tw) => tw.startTime() >= time - 1e-6 && tw.kill());
function magicMove(aId, aSel, bId, bSel) {
const A = slide(aId);
const B = slide(bId);
const aCam = $(".cam", A.el);
const bCam = $(".cam", B.el);
const ha = $(aSel, A.el);
const hb = $(bSel, B.el);
const tA = lastOf(A.F);
const sB = B.s;
// Take over the old headline's exit and the new headline's entrance.
killFrom(ha, tA);
killFrom(hb, sB);
const ac = charBoxes(splitChars(ha), aCam);
const bc = charBoxes(splitChars(hb), bCam);
const ratio = parseFloat(getComputedStyle(hb).fontSize) / parseFloat(getComputedStyle(ha).fontSize);
const used = new Set();
const pairs = [];
bc.forEach((b) => {
const a = ac.find((x) => !used.has(x) && x.ch === b.ch);
if (a) {
used.add(a);
pairs.push([a, b]);
}
});
const matchedB = new Set(pairs.map(([, b]) => b));
// Old slide: everything but the headline fades; matched letters travel.
customExit.add(aId);
const others = [...aCam.children].filter((n) => n !== ha && !n.contains(ha) && !n.classList.contains("grid"));
const siblings = [...(ha.parentElement !== aCam ? ha.parentElement.children : [])].filter((n) => n !== ha);
tl.to([...others, ...siblings], { opacity: 0, duration: 0.35, ease: "power1.in" }, tA);
pairs.forEach(([a, b], i) => {
tl.to(a.c, { x: b.x - a.x, y: b.y - a.y, scale: ratio, duration: 0.7, ease: "power3.inOut" }, tA + Math.min(i * 0.004, 0.1));
});
tl.to(ac.filter((a) => !used.has(a)).map((a) => a.c), { opacity: 0, y: 24, duration: 0.3, ease: "power1.in" }, tA);
// New slide: matched letters are already in place; the rest rise in.
tl.set(hb, { opacity: 1, x: 0, y: 0, scale: 1 }, sB);
const fresh = bc.filter((b) => !matchedB.has(b)).map((b) => b.c);
tl.set(fresh, { opacity: 0 }, sB);
tl.fromTo(fresh, { opacity: 0, y: 26 }, { opacity: 1, y: 0, duration: 0.4, ease: EASE, stagger: 0.012, immediateRender: false }, sB + 0.05);
}
[
["open-felt", "h1", "open-just", ".q"],
["open-just", ".q", "open-foundations", "h1"],
["savings", "h1", "oracles", "h1"],
["oracles", "h1", "intent", "h1"],
["intent", "h1", "trust", ".t"],
]
.filter(([a, , b]) => document.getElementById(a) && document.getElementById(b))
.forEach((p) => magicMove(...p));
if (tickers.length) {
const loop = () => {
const t = tl.time();
tickers.forEach((k) => {
if (t < k.from || t >= k.to) return (k.since = null);
k.since ??= performance.now();
k.el.textContent = k.fmt(k.base + (k.rate * (performance.now() - k.since)) / 1000);
});
requestAnimationFrame(loop);
};
requestAnimationFrame(loop);
}
for (const ref of island.slides) {
const id = ref.sceneId;
if (NO_EXIT.has(id) || customExit.has(id) || !ref.fragments || !ref.fragments.length) continue;
exitDefault(slide(id).el, lastOf(ref.fragments));
}
tl.set({}, {}, TOTAL);
// ---------- registration ----------
// Rendering, snapshots and Studio seek this timeline directly, so every frame
// is deterministic. Inside the live slideshow the controller hard-seeks to
// each hold point; there we register a clock instead and play the visual
// timeline forward in real time to wherever the controller lands. Backward
// moves still jump instantly.
if (!live) {
window.__deckTimeline = tl;
return;
}
const scenes = $$("#root > [data-composition-id]").map((el) => {
const [s, dur] = DECK_SCENE_TIMES[el.dataset.compositionId];
return [s, s + dur, el];
});
// Keep exactly one scene visible even if the runtime has not attached yet.
function showSceneAt(t) {
for (const [s, e, el] of scenes) {
const on = t >= s && t < e;
el.style.visibility = on ? "visible" : "hidden";
el.style.opacity = on ? "1" : "0";
el.style.pointerEvents = on ? "auto" : "none";
}
}
showSceneAt(0);
const clock = gsap.timeline({ paused: true });
clock.set({}, {}, TOTAL);
window.__deckTimeline = clock;
// The HyperFrames runtime parks GSAP's ticker, so this loop runs on
// requestAnimationFrame (with a timer fallback for throttled or background
// tabs) and seeks the visual timeline itself. Moving forward to a new slide
// plays the outgoing slide's exit first, then the incoming entrance.
const lastHold = {};
island.slides.forEach((x) => {
if (x.fragments && x.fragments.length) lastHold[x.sceneId] = lastOf(x.fragments);
});
const sceneOf = (t) => scenes.find(([s, e]) => t >= s && t < e) || null;
let last = null;
let vis = null;
let queue = [];
let seg = null;
function frame(now) {
const t = clock.time();
if (t !== last) {
const prev = last;
last = t;
const sc = sceneOf(t);
const s = sc ? sc[0] : 0;
queue = [];
seg = null;
const cur = vis === null ? prev : vis;
if (prev !== null && prev > t) {
vis = t;
tl.seek(t);
} else {
const from = sceneOf(cur === null ? -1 : cur);
if (from && from !== sc) {
const id = from[2].dataset.compositionId;
const lh = lastHold[id];
if (lh !== undefined && !NO_EXIT.has(id) && cur >= lh - 0.05) queue.push({ from: Math.max(cur, lh), to: lh + (EXIT_LONG[id] || EXIT) });
queue.push({ from: s, to: t });
} else {
let f = cur === null || cur < s ? s : cur;
if (t - f > 6) f = t - 0.6;
queue.push({ from: f, to: t });
}
}
}
if (!seg && queue.length) seg = { ...queue.shift(), t0: now };
if (seg) {
const span = seg.to - seg.from;
const p = span > 0 ? Math.min(1, (now - seg.t0) / (span * 1000)) : 1;
vis = seg.from + span * p;
tl.seek(vis);
if (p >= 1) seg = null;
}
showSceneAt(vis === null ? t : vis);
}
function loop(now) {
frame(now);
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
setInterval(() => frame(performance.now()), 40);
});