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

224
Views
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
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!