function spaNavigate(data) {
// View Transition APIに未対応なブラウザ用のFallback
if (!document.startViewTransition) {
updateTheDOMSomehow(data);
return;
}
// View Transition APIを使った遷移
document.startViewTransition(() => updateTheDOMSomehow(data));
}
::view-transition
└─ ::view-transition-group(root)
└─ ::view-transition-image-pair(root)
├─ ::view-transition-old(root)
└─ ::view-transition-new(root)
::view-transition-old(root),
::view-transition-new(root) {
animation-duration: 5s;
}
.main-header {
view-transition-name: main-header;
}
#card1 { view-transition-name: card1; }
#card2 { view-transition-name: card2; }
#card3 { view-transition-name: card3; }
#card4 { view-transition-name: card4; }
#card5 { view-transition-name: card5; }
…
#card20 { view-transition-name: card20; }
#cards-wrapper > div {
view-transition-class: card;
}
html::view-transition-group(.card) {
animation-timing-function: var(--bounce);
}
html::view-transition-group(.card)
) が適用される