Challenge - 5 Problems
View Transitions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat happens when a view transition is triggered in Astro?
Consider an Astro component that uses the View Transitions API to animate between two states. What is the visible effect when the transition starts?
Astro
const startTransition = () => {
document.startViewTransition(() => {
// Change DOM or state here
});
};Attempts:
2 left
💡 Hint
Think about what the View Transitions API is designed to do visually.
✗ Incorrect
The View Transitions API animates the change between the old and new DOM states smoothly, providing a seamless visual effect.
📝 Syntax
intermediateWhich code snippet correctly starts a view transition in Astro?
Choose the correct syntax to start a view transition that updates the DOM inside the callback.
Attempts:
2 left
💡 Hint
Look for correct function call syntax with arrow function and braces.
✗ Incorrect
Option D uses the correct syntax: a function call with an arrow function and braces to update the DOM.
🔧 Debug
advancedWhy does this view transition code cause no animation?
Given this code snippet, why does the view transition not animate as expected?
const updateContent = () => {
document.startViewTransition(() => {
// No DOM changes here
});
};
Astro
const updateContent = () => {
document.startViewTransition(() => {
// No DOM changes here
});
};Attempts:
2 left
💡 Hint
Think about what triggers the animation in the View Transitions API.
✗ Incorrect
The API animates between the old and new DOM states. If no DOM changes happen, there is nothing to animate.
❓ state_output
advancedWhat is the state of the DOM during a view transition?
During a view transition started by startViewTransition, what DOM states are visible to the user?
Attempts:
2 left
💡 Hint
Consider how the API creates a smooth visual effect between states.
✗ Incorrect
The API overlays snapshots of old and new DOM states and animates between them, blending both visually.
🧠 Conceptual
expertWhich scenario best uses the View Transitions API in Astro?
Choose the scenario where using the View Transitions API provides the most benefit.
Attempts:
2 left
💡 Hint
Think about when smooth visual transitions improve user experience.
✗ Incorrect
Animating page content changes during navigation creates a smooth user experience, which is the main use case for the API.
