Astro + Native Cross-Document View-Transitions → No Backward Animations
This demo shows a first (incomplete) step to enable native cross-document view transitions on an Astro site. Other demos will improve the situation step by step. See the link at the bottom of the page or the overview.
These pages might look familiar to you, seasoned astronaut! It’s because they are based on the blog template you can select when running npm create astro
.
What got changed?
- Obviously, the demo content got replaced.
- All
<main>
tags include atransition:animate="slide"
directive, generating Astro’s default CSS for sliding view transition animations. - This demo does not use the
<ViewTransitions/>
component. To activate native cross-document view transitions, the following code was added to the end ofBaseHead.astro
.
Click on the Home, Blog, or About links in the header of this page. You’ll see the content slide in smoothly from the right, even when using the browser’s back button. No matter what, Astro’s default backward animation won’t activate.
Let’s improve this in the next demo (or return to the overview).