-
Notifications
You must be signed in to change notification settings - Fork 154
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 saving #336
Comments
I think it's worth looking into how other SPA routers do this (in particular, sveltekit's router or https://github.com/solidjs/solid-app-router). Also if you don't mind, I would like to merge the new reactivity system before you work on this because that would likely cause a lot of merge conflicts. |
Sure thing, I'll look into those! I completely understand about the new reactive primitives, no problem! (Also thank you so much for all your hard work on them, I have no doubt that they'll be absolutely incredible!) |
For reference, this issue from Solid seems to have a fair bit of discussion on the matter. I think a good solution might be store previous scroll positions in the router in some way and then allow the app to control the behavior from there. That way, Sycamore provides helpers but not lock-ins, which is probably better in the long-run. |
I'd like to tentatively get this in for the 0.8 release |
Yeah that would be great. If you'd like me to do it, I should be able to have a look next week. |
In Firefox (I'm not sure about other browsers from memory), the default behavior when using the forward/back button is to restore the scroll position for greater continuity. However, Sycamore breaks this behavior by resetting the scroll position to the top of the page.
In a way, this is a bug report about that, but it's also a broader feature request for the router to track scroll positions and automatically restore them upon navigating to a page that the user has been to before in the same session. I'm not sure this would be best done by storing every single scroll position, but rather perhaps for the last 10 pages or so. This could even maybe be configured by some router initialization parameter (though that would be a later feature for a breaking release).
Pending confirmation on this design, I'm very happy to work on this.
The text was updated successfully, but these errors were encountered: