demo · v140

Cleanup Race

Common pattern: a view transition runs, then a .finished handler resets the box style. Pre-140 the reset happened a frame too late and showed a tiny flicker. Click below to fire the transition; the log records the order of events.

hero
const vt = document.startViewTransition(() => box.classList.toggle("alt"));
vt.finished.then(() => {
  log("finished resolved");
  box.classList.add("cleanup");          // tiny scale animation
  requestAnimationFrame(() =>
    log("rAF after finished — does the cleanup paint cleanly?"));
});

see also