Bird
0
0

What is the effect of this Angular animation snippet?

medium📝 component behavior Q5 of 15
Angular - Animations
What is the effect of this Angular animation snippet?
trigger('fadeToggle', [transition(':leave', [animate('500ms', style({opacity: 0}))])])
AThe element instantly disappears without animation
BThe element fades in over 500ms when added to the DOM
CThe element fades out over 500ms when removed from the DOM
DThe element slides up when removed
Step-by-Step Solution
Solution:
  1. Step 1: Identify the transition ':leave'

    This means the animation runs when the element is removed from the DOM.
  2. Step 2: Understand the animation details

    The element's opacity animates to 0 over 500ms, causing a fade out effect.
  3. Final Answer:

    The element fades out over 500ms when removed from the DOM -> Option C
  4. Quick Check:

    Fade out on leave = A [OK]
Quick Trick: ':leave' triggers animation when element is removed [OK]
Common Mistakes:
  • Confusing ':leave' with ':enter'
  • Expecting fade in instead of fade out
  • Ignoring animation timing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes