-
Notifications
You must be signed in to change notification settings - Fork 58
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
fix: always save the initial scroll position even if no scrolling occurs #293
Conversation
Sorry for taking so long to get to this. Is there a reason we need to save the new position, though? If e.g. we don't have a saved position after a transition, then the "saved position is missing" handler will still calculate the same [0, 0], no? How does this come up? |
The feature I am trying to implement in an app is the following
The logic for this is in the app, but the effect of it is that This is the change to Rudy where I'm adding scroll restoration support: respond-framework/rudy#65 The relevant part is that |
I've updated this - the code to save the initial position now waits until the window scroll position is updated in the case that this is asynchronous |
50e6cb2
to
90683a5
Compare
90683a5
to
73b6ecc
Compare
OK, I've added a failing test which this change fixes - hopefully that clarifies the situation. |
thanks! |
Browsers (at least the latest chrome) don't dispatch the
scroll
event unless the scroll position is set to a different value. This gives rise to a bug where if the scroll position is not[0, 0]
andshouldUpdateScroll
requests to set the scroll position to what it already is, then thescroll
event will never happen and the scroll position will not be saved for the new location.The fix is to save the scroll position immediately after setting it (after a transition) and when adding a scrollable element. At this time the position may not have updated yet, but if it does update then the saved position will be overridden..