Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add page transition component #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ismamz
Copy link

@ismamz ismamz commented Nov 21, 2024

This is an implementation of the next-transition-router library.

It uses the auto-detect feature for simpler integration.

status-page-transitions.mov

Copy link

vercel bot commented Nov 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
satus-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 7:46pm

Copy link

vercel bot commented Nov 21, 2024

@ismamz is attempting to deploy a commit to the darkroom Team on Vercel.

A member of the Team first needs to authorize it.

@clementroche
Copy link
Member

clementroche commented Nov 21, 2024

Hey @ismamz thank you for your PR, we're trying to have this feature for a long time.

Let me see if i understand it well:

  • preventDefault every the link click
  • trigger exit animation
  • navigate programatically using next/router
  • trigger enter animation

@ismamz
Copy link
Author

ismamz commented Nov 21, 2024

Hey @ismamz thank you for your PR, we're trying to have this feature for a long time.

Let me see if i understand it well:

  • preventDefault every the link click
  • trigger exit animation
  • navigate programatically using next/router
  • trigger enter animation

Hi @clementroche, I know you've been working on this. I think this may be a good solution for this stack, even if you migrate away from GSAP.

Correct, that's how it works. Just a few additions:

  • preventDefault all links is optional, you can use a Link component for more control
  • each stage of the transition is tracked in a state

@clementroche
Copy link
Member

clementroche commented Nov 21, 2024

That works well for global "curtain" page transition however still not ideal for more complex page transition (eg: https://www.thomasmonavon.com/gregory-lalle) since we can have both pages (previous/next) visible at the same time. I know it's currently impossible with Next.

Also would be cool if we could trigger page enter/leave directly through the page, I think it's doable with a hook such as

function HeroAboutPage() {
  useTransitionRouter({
    onEnter: (timeline) => {
      // animate your page hero in
     timeline.add(...)
    },
     onLeave: (timeline) => {
      // animate your page hero out
     timeline.add(...)
    }
  })
}

@ismamz
Copy link
Author

ismamz commented Nov 21, 2024

@clementroche yes, it works well with the "curtain" effect, but also if you want to do something with the elements in the current view before leaving the page.

That example is really smooth! You can create complex transitions with "shared" elements using GSAP and Flip, for example. Here, I built an example: https://github.com/ismamz/next-continuity-transition. It requires "manual" work, but it's possible 😅

output.mp4

I've thought about a similar hook, and it's something that could be implemented. In that example, it would seem to be directly tied to GSAP (timeline). The idea was to make it agnostic to an animation library, but I will work on that!

@eloquent-peasant
Copy link

eloquent-peasant commented Nov 27, 2024

@ismamz "It works great; however, there is a bug. Let's say I have two links: / and /work. If I click on /work, the transition works fine, but if I click on /work again, the transition will always be present and will not fade away. any possible fixes?"

@ismamz
Copy link
Author

ismamz commented Dec 1, 2024

@ismamz "It works great; however, there is a bug. Let's say I have two links: / and /work. If I click on /work, the transition works fine, but if I click on /work again, the transition will always be present and will not fade away. any possible fixes?"

@eloquent-peasant I’m not sure I understand correctly. If you click on the current page, there’s no transition because you’re not navigating to a new page; that’s the expected behavior. I think this is a library-related issue. If you prefer, you can open an issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants