Loading...
document.startViewTransition(() => {
list.innerHTML = renderItems(items);
});if (!document.startViewTransition) {
list.innerHTML = renderItems(items);
} else {
document.startViewTransition(() => {
list.innerHTML = renderItems(items);
});
}Feature-detect startViewTransition() so browsers without it still update the DOM, just without the animation.
startViewTransition(), so there is nothing to animate.document.startViewTransition and runs the DOM update directly when it is missing.prefers-reduced-motion.No, document.startViewTransition() handles same-document updates. Cross-document transitions are turned on in CSS with the @view-transition at-rule.
Style the ::view-transition-old() and ::view-transition-new() pseudo-elements in CSS, and give elements a view-transition-name to animate them separately.
Yes, the returned ViewTransition object has ready, updateCallbackDone and finished promises you can await.