Skip to content

polish: smooth site-name scale animation on photography page transition - #403

Open
kiennt23 wants to merge 1 commit into
mainfrom
polish/smooth-site-name-scale
Open

polish: smooth site-name scale animation on photography page transition#403
kiennt23 wants to merge 1 commit into
mainfrom
polish/smooth-site-name-scale

Conversation

@kiennt23

Copy link
Copy Markdown
Contributor

Summary

Closes #337

Fixes the slight snap when the site-name scales from 32px → 50px (via transform: scale(1.5625)) on home → photography navigation.

Root Cause

The FLIP animation completes and calls onComplete, which used a 50ms setTimeout before adding the wide-layout class. This was a race condition — sometimes the browser batched the site-name visibility restore and the scale change into a single paint frame, skipping the CSS transition entirely.

Fix

Replaced setTimeout(() => ..., 50) with double requestAnimationFrame — this guarantees the browser paints the site-name at scale(1) before wide-layout adds scale(1.5625), ensuring the CSS transform 0.4s ease transition always fires.

// Before (race condition)
setTimeout(() => document.body.classList.add("wide-layout"), 50);

// After (guaranteed paint cycle)
requestAnimationFrame(() => requestAnimationFrame(() => {
  document.body.classList.add("wide-layout");
}));

The reverse direction (photography → home) was already smooth — the 400ms delay matches the FLIP duration, so no change needed there.

@kiennt23
kiennt23 force-pushed the polish/smooth-site-name-scale branch 14 times, most recently from 6760351 to 5fb8bf8 Compare April 22, 2026 01:25
@kiennt23
kiennt23 force-pushed the polish/smooth-site-name-scale branch from 5fb8bf8 to 7c76bfa Compare April 22, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

polish: smooth site-name scale animation on photography page transition

1 participant