Isometric line figures that answer the pointer. For React and for anything with a DOM.
Site: the home's blocks rise, unblur and fade on their own clocks, so none twitches as it settles
Lucas Marques691eae3eb3e0
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.cssindex 7fcdc8a..3a58e7f 100644--- a/apps/site/app/globals.css+++ b/apps/site/app/globals.css@@ -147,10 +147,14 @@ em { font-style: italic; }.hero-actions { margin-top: 20px; display: flex; gap: 8px; }@media (min-width: 768px) { .hero-title { font-size: 64px; } }-.hero-rise > * { animation: rise 750ms var(--ease-out) both; animation-delay: calc(var(--i) * 90ms + 60ms); }-.enter { animation: rise 850ms var(--ease-out) both; animation-delay: var(--d, 0ms); }+/* Rise, blur and fade end in that order. The rise and the blur end in steps: moving text is drawn on whole device+ pixels, so the last pixel of travel lands as a hop, and Chrome draws no blur under 0.4px, so the last of it goes+ in one frame. The hop comes under the blur, the blur goes while the block still fades in, and the fade ends it. */+.hero-rise > * { animation: fade 750ms var(--ease-out) both, unblur 560ms var(--ease-out) both, rise 380ms var(--ease-out) both; animation-delay: calc(var(--i) * 90ms + 60ms); }+.enter { animation: fade 850ms var(--ease-out) both, unblur 640ms var(--ease-out) both, rise 440ms var(--ease-out) both; animation-delay: var(--d, 0ms); }.enter-hint { animation: hint 220ms var(--ease-out) both; }-@keyframes rise { from { opacity: 0; transform: translateY(12px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }+@keyframes unblur { from { filter: blur(6px); } to { filter: none; } }+@keyframes rise { from { transform: translateY(12px); } to { transform: none; } }@keyframes hint { from { opacity: 0; transform: translateY(2px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }@keyframes fade { from { opacity: 0; } to { opacity: 1; } }diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.tsindex ff45c22..8400480 100644--- a/apps/site/test/site.spec.ts+++ b/apps/site/test/site.spec.ts@@ -410,6 +410,34 @@ test("on a phone the sidebar is one strip under the top bar, and it follows theexpect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390);});+test.describe("on a 2x screen", () => {+ test.use({ deviceScaleFactor: 2 });++ // Both of the rise's last changes come in steps. Text is drawn on whole device pixels as it moves, so its last pixel of+ // travel is a hop; and Chrome draws no blur under 0.4px, so the blur goes from soft to sharp in one frame. Each reads as+ // a twitch on a block that looks settled, so both happen while the block is still fading in.+ test("the home's blocks come home before their blur clears, and clear it while still fading in", async ({ page }) => {+ await page.goto("/");+ const blocks = page.locator(".hero-rise > *, .enter");+ expect(await blocks.count()).toBeGreaterThanOrEqual(7);+ const late = await blocks.evaluateAll((els) => els.flatMap((el) => {+ const anims = el.getAnimations();+ anims.forEach((a) => a.pause());+ const end = Math.max(...anims.map((a) => Number(a.effect!.getComputedTiming().endTime)));+ for (let t = 0; t <= end; t += 1000 / 120) {+ anims.forEach((a) => (a.currentTime = t));+ const style = getComputedStyle(el);+ const blur = parseFloat(style.filter.match(/blur\(([\d.]+)px\)/)?.[1] ?? "0");+ const away = Math.abs(new DOMMatrixReadOnly(style.transform === "none" ? undefined : style.transform).m42) * devicePixelRatio;+ if (blur < 0.4 && away >= 0.5) return [`${el.className} moves sharp at ${Math.round(t)}ms`];+ if (Number(style.opacity) >= 0.9 && blur >= 0.4) return [`${el.className} is still blurred at ${Math.round(t)}ms`];+ }+ return [];+ }));+ expect(late).toEqual([]);+ });+});+test.describe("without JavaScript", () => {test.use({ javaScriptEnabled: false });