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
Scroll position restoration #273
Comments
Good day @agusterodin Because this feature is relying on a non modified |
Hi - thank you for your great plugin and spending so much time on it. I have a comment that goes into a similar direction: I have added your plugin into an application - and figured out after a while that in Chrome and other webkit browsers the function, that an URL-Hash usually has (scrolling to the container with the respective ID), does not work anymore. I use your plugin for elements inside the body - not for the body-Element itself. I assume the problem is the same as you mentioned above - the modification of the body element. I can currently only say, that commenting out the lines for the initialization fixes the problem. I would like to stick with your plugin - but I don't understand fully what to do with the advice of "defining the rootScroller". If you have time to answer - great. Otherwise you'd have another item to look at when doing the re-write. I would try another library then. Best and thank you Karl. |
I see that 2.x is in beta. Do you know if 2.x supports scroll position restoration? |
@agusterodin Yes it should.. I'll release v2. probably at the end of the month, but feel free to test it until then :) |
|
Worked perfectly! Because of your improvements I was able to remove lines like this from my links:
^ this type of thing led to janky jittering when the link was clicked and route was changed, even when OverlayScrollbars was completely disabled and uninitialized. This allows Next/Link (in Next.js) to do it's thing which fixes scroll restoration and janky jitter when scrolling back up on link click. Thanks!!! |
Happy to hear that! :) |
Is your feature request related to a problem? Please describe.
Browsers (like Chrome) have started to support scroll position restoration when navigating through single page application history. All of my React projects do this without me needing to do anything and is performed by the browser via history api as far as I know. This is obviously only supported on the page body scroll position. Instantiating OS on my project's body causes the browser's scroll position restoration functionality to break.
Describe the solution you'd like
Retain body scroll position restoration when using OS on body element. It would also be cool if you could do it on embedded components (non-body) when needed as well like Gatsby does with a hook (https://www.gatsbyjs.com/docs/scroll-restoration/). That would be a pain to implement since at a glance of the source Gatsby scroll restoration hook is tied in at the router level and uses session storage as well.
Describe alternatives you've considered
Implementing custom logic to capture scroll position on a per page basis. Seems like a dead end solution as even the maintainer of react-router ripped his implementation out a long time ago in favor of stock browser functionality (https://reactrouter.com/web/guides/scroll-restoration).
Additional context
https://developer.mozilla.org/en-US/docs/Web/API/History/scrollRestoration
The text was updated successfully, but these errors were encountered: