0
0
Angularframework~20 mins

Route transition animations in Angular - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Route Animation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
Understanding basic route transition animation triggers
Given the Angular animation trigger below, what will happen when the route changes from 'home' to 'about'?
Angular
import { trigger, transition, style, animate } from '@angular/animations';

export const slideInAnimation = trigger('routeAnimations', [
  transition('home => about', [
    style({ transform: 'translateX(100%)' }),
    animate('300ms ease-in', style({ transform: 'translateX(0%)' }))
  ])
]);
ANo animation occurs because the trigger is incorrect.
BThe old route slides out to the left over 300ms.
CThe new route fades in with no sliding effect.
DThe new route slides in from the right over 300ms.
Attempts:
2 left
💡 Hint
Look at the initial style and the animate style in the transition.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in this route animation definition
Which option contains the correct syntax for defining a route transition animation in Angular?
Angular
import { trigger, transition, style, animate } from '@angular/animations';

export const fadeAnimation = trigger('fadeAnimation', [
  transition(':enter', [
    style({ opacity: 0 }),
    animate('500ms', style({ opacity: 1 }))
  ])
]);
Atransition(':enter', [style({opacity: 0}), animate('500ms', style({opacity: 1}))])
Btransition('enter', [style({opacity: 0}), animate('500ms', style({opacity: 1}))])
Ctransition(':enter', style({opacity: 0}), animate('500ms', style({opacity: 1})))
Dtransition(':enter', [style({opacity: 0}), animate('500ms', {opacity: 1})])
Attempts:
2 left
💡 Hint
Check the use of brackets and the special ':enter' state syntax.
state_output
advanced
2:00remaining
What is the final opacity after this route transition animation?
Consider this Angular animation for route transitions. What will be the opacity of the component after the animation completes when transitioning from 'login' to 'dashboard'?
Angular
import { trigger, transition, style, animate } from '@angular/animations';

export const fadeRouteAnimation = trigger('fadeRoute', [
  transition('login => dashboard', [
    style({ opacity: 0 }),
    animate('400ms ease-out', style({ opacity: 1 }))
  ])
]);
A1 (fully opaque)
B0 (fully transparent)
C0.5 (semi-transparent)
DAnimation does not change opacity
Attempts:
2 left
💡 Hint
Look at the final style in the animate() call.
🔧 Debug
advanced
2:00remaining
Why does this route animation not trigger on navigation?
Given this Angular route animation code, why does the animation not run when navigating between routes?
Angular
import { trigger, transition, style, animate } from '@angular/animations';

export const slideAnimation = trigger('slideAnimation', [
  transition('* => *', [
    style({ transform: 'translateX(-100%)' }),
    animate('300ms ease-in', style({ transform: 'translateX(0%)' }))
  ])
]);

// In component template:
// <div [@slideAnimation]="getRouteAnimationData()">...</div>

// getRouteAnimationData() returns the current route's 'animation' data property.
AThe animation trigger name does not match the template binding.
BThe transition '* => *' is invalid syntax and prevents animation.
CThe getRouteAnimationData() method returns undefined, so no animation state changes.
DThe component is missing the BrowserAnimationsModule import in the app module.
Attempts:
2 left
💡 Hint
Check what the animation trigger depends on to detect changes.
🧠 Conceptual
expert
2:00remaining
How does Angular determine when to run route transition animations?
In Angular, what mechanism triggers route transition animations to run when navigating between routes?
AAnimations run only if the route component implements a special animation interface.
BAngular compares the 'animation' data property of the activated routes and triggers animations when they differ.
CAnimations run automatically on every route change without any configuration.
DAngular triggers animations based on URL string comparison only.
Attempts:
2 left
💡 Hint
Think about how Angular uses route data to control animations.