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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546---layout: "@/layouts/ExplainerLayout.astro"demoTitle: "View Transition Example: Different Images & Aspect Ratios"demoText: "This example demonstrates a view transition between images with different sizes and aspect ratios."title: "How does it work?"---
Aside from the images, the current example differs only slightly from the [previous example](/demo/BasicIM/). The changes only alter the size constraints of the article image.
```diff lang="css" article div { padding: 1rem;- max-width: 50%;+ max-width: 40%; } article img { margin: auto;- height: min(512px, 66vh);+ width: min(400px, 50vw); border-radius: 8px; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5); }```
## Inspection Chamber Insights
The browser generated default animations for the view transition API are rather fast. You have 0.25 seconds to seen what's going on.
<span class="light:sl-hidden"></span><span class="dark:sl-hidden"></span>
With the inspection chamber, you can examine the details of the default morph animation.
The graphic below is from [Mechanics of Default View Transition Animations](/basics/default-animations/#how-the-boxes-morph). This exactly fits our example: the group's outline (orange) gradually widens and shortens in height.
<style>{`td {vertical-align: top; text-align: right;}`}</style><div style="margin-left:calc(50% - 8em); width: fit-content"><table><tr><td>0%</td><td>50%</td><td>100%</td></tr><tr><td><svg width="60" height="80"><g><rect x="10" y="10" width="40" height="60" stroke="#B0860044" stroke-width="2" stroke-dasharray="2 4" fill="none"/><rect x="10" y="10" width="40" height="60" stroke="#532476" stroke-width="2" stroke-dasharray="8 6" fill="none"/><rect x="10" y="10" width="40" height="27" stroke="#27531744" stroke-width="2" stroke-dasharray="8 6" fill="none"/></g></svg></td><td><svg width="70" height="95"><g><rect x="10" y="10" width="50" height="50" stroke="#B0860088" stroke-width="2" stroke-dasharray="2 4" fill="none" /><rect x="10" y="10" width="50" height="75" stroke="#53247688" stroke-width="2" stroke-dasharray="8 6" fill="none"/><rect x="10" y="10" width="50" height="33" stroke="#27531788" stroke-width="2" stroke-dasharray="8 6" fill="none" /></g></svg></td><td><svg width="80" height="110"><g><rect x="10" y="10" width="60" height="40" stroke="#B0860044" stroke-width="2" stroke-dasharray="2 4" fill="none" /><rect x="10" y="10" width="60" height="90" stroke="#53247644" stroke-width="2" stroke-dasharray="8 6" fill="none"/><rect x="10" y="10" width="60" height="40" stroke="#275317" stroke-width="2" stroke-dasharray="8 6" fill="none" /></g></svg></td></tr></table></div>
In real, the middle picture of the last row looks like this:
<style>{`#mix img {max-height:66vh; width:auto}`}</style><span id="mix"></span>
The [next example](/demo/BasicIM3/) shows an alternative styling that is less overwhelming.