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

feat: link view transitions #1217

Merged
merged 6 commits into from
Feb 15, 2025
Merged

Conversation

pmelab
Copy link
Contributor

@pmelab pmelab commented Feb 7, 2025

Alternative approach to #1207. Instead of integrating view transitions for each route change, they are just optionally added to the Link click event.

  • Less intrusive
  • Other cases (e.g. programmatic navigation) can be handled on the application level.
  • Does not support browser prev/next buttons.

Copy link

vercel bot commented Feb 7, 2025

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

1 Skipped Deployment
Name Status Preview Updated (UTC)
waku ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2025 2:27am

Copy link

codesandbox-ci bot commented Feb 7, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@dai-shi
Copy link
Owner

dai-shi commented Feb 7, 2025

Is this a temporary solution until React provides ViewTransitioin?

@pmelab
Copy link
Contributor Author

pmelab commented Feb 7, 2025

Is this a temporary solution until React provides ViewTransitioin?

Yes. It's not perfect, but maybe good enough until then.

@dai-shi
Copy link
Owner

dai-shi commented Feb 13, 2025

I'm not super familiar with view transitions, but when we use it, do we use isPending from useTransition as well? Looking at the code, it feels a little bit overlapping.

@dai-shi
Copy link
Owner

dai-shi commented Feb 15, 2025

Let me add some commits.

Copy link
Owner

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My change makes it less handy, but I would like it as a temporary solution.

@dai-shi dai-shi merged commit 79a14af into dai-shi:main Feb 15, 2025
26 checks passed
@pmelab
Copy link
Contributor Author

pmelab commented Feb 15, 2025

Sorry, that was too fast for me. I still had it on my list to investigate if this works for all cases.

I'm not super familiar with view transitions, but when we use it, do we use isPending from useTransition as well? Looking at the code, it feels a little bit overlapping.

startViewTransition takes a snapshot, executes the transition callback, waits for any promise that was returned and then transitions to the new DOM state. I think in our case it would wait for changeRoute to only, but this is not actually the full
transition if the route takes longer to resolve, right?

I'll create some new tests for that when I have some time.

@dai-shi
Copy link
Owner

dai-shi commented Feb 15, 2025

I thought the example was working well.
Isn't it working?

I still had it on my list to investigate if this works for all cases.

Oops, sorry about it.

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.

2 participants