fix: always save the initial scroll position even if no scrolling occurs#293
fix: always save the initial scroll position even if no scrolling occurs#293taion merged 3 commits intotaion:masterfrom
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
scrollevent 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]andshouldUpdateScrollrequests to set the scroll position to what it already is, then thescrollevent 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..