Prevent early scrolling during history navigation (experimental). #301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When handling a history change event, save the current position and scroll to
that (current) position immediately after handling the event to prevent the
browser from incorrectly scrolling too early.
The browser default behavior is to scroll to the position when
pushState
wascalled just after firing a
popState
event. This is okay only if usingpushState
to move around a single page or if all content can be renderedsynchronously during the
popState
event handling. Since navigation contentupdates are asynchronous (either from cache or from network), avoid this early
scroll by immediately scrolling back to the current position after the event.
The proper position is then (re)set once the content is updated.
For now, guard this behavior behind the
experimental-scroll-position
config.Progress on #285.