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

Instant scrolling when changing pages #880

Open
RodrigoJuliano opened this issue Oct 5, 2021 · 6 comments
Open

Instant scrolling when changing pages #880

RodrigoJuliano opened this issue Oct 5, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@RodrigoJuliano
Copy link

Is your feature request related to a problem? Please describe.
If you enable smooth scrolling via css styles, forward navigation makes a animated smooth scroll to the top of the page when loading the page.

Describe the solution you'd like
I think this scroll should always be instantaneous.

One way to get this is by passing the 'behavior' parameter to the scroll function.
Change this:

if (wasPush) scrollTo(0, 0);

To:

 if (wasPush) scrollTo({ top: 0, behavior: 'instant' }); 

Additional context
Relates to #496

@RodrigoJuliano RodrigoJuliano added the enhancement New feature or request label Oct 5, 2021
@RodrigoJuliano
Copy link
Author

A complementary suggestion: If the navigation link includes a hash link, then scroll to the element with that id instead of the top

@developit
Copy link
Member

I thought the default behavior of scrollTo(0,0) was instant? Are you seeing this on a specific browser?

@RodrigoJuliano
Copy link
Author

I use chrome. The default behavior is 'auto' which should be instantaneous according to the documentation, but in practice it is not. mdn/content#2719

@developit
Copy link
Member

When I test this locally, I am not seeing smooth scrolling - it's instant. Maybe you have a script or extension that is intercepting this and applying smooth scrolling?

@RodrigoJuliano
Copy link
Author

RodrigoJuliano commented Oct 5, 2021

I tested it with an empty project and on Edge, and it still happened. Did you add scroll-behavior: smooth; ?

@developit
Copy link
Member

Ah - sorry, I had missed that you were asking for this as a way to override global scrolling-behavior:smooth.

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

No branches or pull requests

2 participants