Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
how can i trigger animation of a component in another component

Hello everyone I have a top-nav-component that is responsible for showing and hiding top navigation and it has a nice slide-in-out animation I want to add page transition to my routes. my routeroutlet is presented in AppComponent

but first, I want my top-nav-component to close first and then page transition happens I don't know how to first close top-nav-component and then do the page transition I am pretty new to angular

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One way could be trigger animations on route change. https://angular.io/guide/route-animations

Then time them with delays with stagger or delay. https://angular.io/api/animations/stagger https://angular.io/guide/animations#animation-metadata-duration-delay-and-easing

Let us imagine that current state is so, that user is on a route and top-nav-component is showing.

Animation would be following.

  1. 250ms + 250ms (500ms) to open or close animate top-nav-component
 animate('250ms', style({ height: '*' })),
      query('.menu-item', [
        stagger(-50, [
          animate('250ms ease', style({ opacity: 1, transform: 'none' })),
        ]),
      ])
  1. For the component on route change we give animation where 750ms is time to play route change animation and 500ms is the delay (to wait for top-nav animation).
animate('750ms 500ms ease', style({ [direction]: '100%' }))

enter image description here

You can add longer delay for a more noticeable gap.

Working example: https://stackblitz.com/edit/angular-route-animations-bvhn4c?file=src%2Fapp%2Froute-animations.ts

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!