Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

340
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda