-
Notifications
You must be signed in to change notification settings - Fork 18
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
[question] scroll position #45
Comments
@nichoth nope so far this lib only does routing and all stuff related with that. E.g. instrument the history API, handle links to trigger the router, etc. I'm not sure what the story is about scroll position. I haven't given it much though, but figured virtual doms would handle this. Could you perhaps provide some more information on this? How does persisting scroll position work, and what's the use case? Should we handle it? |
I've always used single-page which passes you the previous scroll position when the route changes, but it is a lower level module. I would like to better encapsulate this functionality, not sure how though. Here is an example of it in use, where we jump to that position after rendering the new view. https://github.com/nichoth/tiny-thunder/blob/master/src/lib/routes/index.js#L19 |
@nichoth would it be viable to save scrollposition on a per-view basis? perhaps with a lil history listener + subscription or something? |
It makes sense for scroll position to be part of UI state like everything else. We need a hook somewhere during page changes that gets the scroll position when someone leaves a view. Then the view needs to go to the scroll position iff the user got there via the back button. So the minimum that we need to know from the router is if the route was triggered via back button or click. Maybe we don't want to save scroll state in the router. I will eventually do more work on this, because I have to figure it out for my project. |
Yeah I think that's fair. Though scrollstate can also a thing on a per-component basis, but I feel like that might be a bit more of an edge case. What do you think the right API for this would be? |
When we use the back and forward buttons we expect the scroll position to be where we left off at. How do you handle scroll position? Does this library provide a mechanism for it?
The text was updated successfully, but these errors were encountered: