Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vtbag/website. The @vtbag website. ⭐️ Please star to support this work! ⭐️
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576---import Demo from "@/layouts/DemoLayout.astro";---
<Demo title="View Transition Example: Custom Animation, Page 2 of 2" backlink='/basics/examples/#basicac' prev="/demo/BasicC1/" next="/demo/BasicMC1/" description="A custom cross-document view transition animation that shrinks the old image on exit and enlarges the new image on entry." image="/bag-og.png"> <link rel="preload" href="/chamber.webp" as="image" slot="early-head" /> <p> You now see page two of this example. For details see below. </p> <h2>My other lovely picture</h2> <img id="image" width="200" height="200" src="/chamber.webp" alt="The Inspection Chamber" /> <a class="nav-button right" href="/demo/BasicAC1/">Next</a>
<style is:inline slot="late-head"> @media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; }} h2 + img { view-transition-name: img } ::view-transition-old(img) { animation: 1s zoom-out forwards; } ::view-transition-new(img) { animation: 1s reverse zoom-out; } @keyframes zoom-out { 40% { transform: scale(0.5); opacity: 0.5; } 60% { transform: scale(0.5); opacity: 0.5; } 100% { transform: scale(0); opacity: 0; } } .nav-button { position: fixed; transform: translateY(-150px); padding: 10px 20px; background-color: #007bff; color: white; border: none; cursor: pointer; font-size: 16px; border-radius: 5px; } .nav-button.right { right: 20px; } #image { display: block; margin: 0 auto; mask-image: radial-gradient( ellipse at center, white 35%, transparent 71% ); } :active-view-transition { cursor: pointer; } </style></Demo>