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

228
Visualizações
Framer motion page transition depending on state

My Problem:

I want to controll the page transition behavior based on state. My state is the URL the user is coming from.

Examples:

A user coming from Component1 going to Component2 --> slide Component1 out and at the same time slide Component2 in. A user coming from Componen3 going to Component2 --> fade Component3 out and at the same time fade Component2 in.

The issue is that setting the transition dynamically makes the transition type change during the transition as it's not waiting for the transition to finish. Also, some transitions need exitBeforeEnter to be true to fade accordingly. The slide page transition on the other hand needs it to be turned off for a transition without a gap. Working with only one transition slide or fade works like a charm. You will find the logic for switching the page-transition-stye in Component1. If you want to see the transition working replace variantsFade with variantsSlide.

What I tried:

Using useContext to keep track of the BroserHistory --> prevRoute and currRoute And setting the variants based on state as soon as the URL changes.

What I'm looking for:

A solution to allow switching between slide transitions with exitBeforeEnter=false and fading transition with exitBeforeEnter=true based on state while route switching.

Sandbox-Link: https://codesandbox.io/s/different-page-transition-kkp81n?file=/components/Component1.tsx

about 4 years ago · Juan Pablo Isaza
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