Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

336
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda