Sub topic 16
Debugging transitions in DevTools
This chapter assumes you have built a transition with document.startViewTransition(), that you know the ::view-transition pseudo-element tree, and that you have used view-transition-name. The examples use Chrome DevTools. Other Chromium-based browsers offer similar panels.
Why transitions are hard to debug
A transition runs for a few hundred milliseconds. The pseudo-elements exist only while it runs, so you can't inspect them at rest. Your first task is to slow the transition down or freeze it.
Freeze and inspect the pseudo-element tree
- Open DevTools and open the Animations panel from the three-dot menu under More tools.
- Trigger the transition. The panel records the animations and lists them.
- Click the pause button. While the animations are paused, the Elements panel shows a
::view-transitionnode under<html>. - Expand the tree. You will see
::view-transition-group,::view-transition-image-pair,::view-transition-oldand::view-transition-newfor each name. - Select a pseudo-element to read its computed styles. Drag the timeline scrubber to step through the animation.
If you can't use the panel, slow every group from CSS while you debug and remove the rule afterwards:
::view-transition-group(*) {
animation-duration: 5s;
}Log the lifecycle
The three promises on the ViewTransition object show where a transition stops.
async function debugTransition(update) {
const transition = document.startViewTransition(update);
transition.updateCallbackDone.catch((err) => {
console.error('update callback failed:', err);
});
transition.ready
.then(() => console.log('ready: pseudo-elements exist'))
.catch((err) => console.warn('skipped before ready:', err.name));
await transition.finished.catch(() => {});
console.log('finished');
}If ready rejects but updateCallbackDone resolves, the DOM updated and the animation was skipped. If updateCallbackDone rejects, the error is in your update function.
Common problems and what to check
| Symptom | Likely cause | What to check |
|---|---|---|
| No animation, DOM still updates | Duplicate `view-transition-name` | The console reports the duplicate. Search your styles and inline styles for repeated names. |
| Shared element does not move | Name missing in the old or new state | In the callback, confirm one element has the name before the capture and one after the update. |
| Transition cut short | A new `startViewTransition()` call interrupted it | Look for `AbortError` in the `ready` and `finished` logs. |
| Element not clipped by its parent | Snapshots render in a layer above the page | Parent `overflow` does not clip the pseudo-elements. Animate `clip-path` on the group instead. |
| Element flashes or jumps in stacking order | Named elements are captured separately from their parents | Check `z-index` and whether a parent effect such as `opacity` or `filter` was lost in the snapshot. |
Exercise
A card grid gives every card the style view-transition-name: card. A click on any card starts a transition, but nothing animates and the content still changes. What is wrong, and how do you confirm it?
Show answer
Several elements share the name card, which is a duplicate view-transition-name. The browser skips the transition, but the DOM update still runs. Confirm it by reading the console warning and by checking that transition.ready rejects. Fix it by setting a unique name per element, for example card-${id}, or by naming only the clicked card.