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

[framer-route-animation] window should not scroll to top immediately #444

Open
QzCurious opened this issue Mar 13, 2024 · 0 comments
Open

Comments

@QzCurious
Copy link

QzCurious commented Mar 13, 2024

The Problem

It's might be too rough to framer-route-animation example that it's not considering scroll-to-top behavior by <ScrollRestoration />.

bandicam.2024-03-13.10-07-49-128.mp4

About the Causes

Virtually, window would be scrolled to top immediately by <ScrollRestoration /> after location changed. Since all content in html share the same window.scrollY. The scroll-to-top behavior and the animate-{outlet} are happening at same time.

I thought I can capture the end of first {outlet} exit animation by onAnimationComplete and only then "continue" to do scroll-to-top. But re-implementing <ScrollRestoration /> for this one means a lot to me. I may break something I don't even aware of.

We can use useBlocker to stop navigation and continue on onAnimationComplete. But it might not be ideal as:
image

Code

It's a modified version from framer-route-animation example.

The only relevant change is add padding to make page scrollable. I also apply a background for visualize the problem better.

image

codesandbox here:
https://codesandbox.io/p/devbox/remix-example-framer-route-animation-bug-9npqvc?file=%2Fapp%2Froot.tsx%3A30%2C6

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

No branches or pull requests

1 participant