diff --git a/src/components/itemDetail/itemDetailLayout.tsx b/src/components/itemDetail/itemDetailLayout.tsx index 4dea39d..057138b 100644 --- a/src/components/itemDetail/itemDetailLayout.tsx +++ b/src/components/itemDetail/itemDetailLayout.tsx @@ -93,9 +93,9 @@ const ItemDetailLayout = ({ return ( diff --git a/src/main.tsx b/src/main.tsx index eff775c..9b631b7 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -44,7 +44,11 @@ const router = createRouter({ }, defaultPreload: false, defaultPreloadStaleTime: 0, - defaultViewTransition: false, + // Only animate real page changes; search-param updates (typing in the + // search field) must not trigger a transition on every keystroke. + defaultViewTransition: { + types: ({ pathChanged }) => (pathChanged ? ["page"] : false), + }, scrollRestoration: true, scrollRestorationBehavior: "auto", }); diff --git a/src/styles/global.scss b/src/styles/global.scss index d390774..7788e9f 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -98,6 +98,49 @@ body { opacity: 0.35; } +/* Fast, compositor-driven page transitions. */ +@supports (view-transition-name: none) { + ::view-transition-old(root), + ::view-transition-new(root) { + animation-duration: 160ms; + animation-timing-function: cubic-bezier(0.2, 0, 0, 1); + animation-fill-mode: both; + } + + ::view-transition-old(root) { + animation-name: routeFadeOut; + } + + ::view-transition-new(root) { + animation-name: routeFadeIn; + } +} + +@media (prefers-reduced-motion: reduce) { + ::view-transition-old(root), + ::view-transition-new(root) { + animation: none !important; + } +} + +@keyframes routeFadeOut { + from { + opacity: 1; + } + to { + opacity: 0; + } +} + +@keyframes routeFadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + .fadeIn { animation: 0.5s fadeInPage forwards; }