-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Reflecting UI changes to the route #104
Comments
The trick is to disable native History API Scroll Restoration behavor and control scroll manually. |
If location key does not exist that means the page is opened first time and we usually scroll to top in this case (as for non SPA apps). |
For me changing line 163 of () => onRenderComplete(route, { ...location, key: Object.keys(scrollPositionsHistory).pop() }), @frenzzy I took a look at |
You need to decide in which case you don't need to scroll. For example you may skip scrolling if path wasn't changed or if if (!(previousLocation.pathname === location.pathname && action === 'REPLACE')) {
window.scrollTo(scrollX, scrollY);
} |
That should do the job but my question is since |
let previousLocation = history.location;
function onLocationChange(location) {
// here you have both location and previousLocation
previousLocation = location;
} |
Thanks a lot you are so helpful. |
Sometimes this would be grate to have UI state in route. for example in a list that is filtered with some check boxes. When the user clicks on a checkbox I like the route to change so that the user is able to share that route or bookmark it. I don't want to use
#
since Google will ignore it. currently if I do something like this:It will change the position of my scroll. How can I implement such a thing?
The text was updated successfully, but these errors were encountered: