Hide the navigation loader when the page is shown #1359
Merged
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.
What does this PR do? 🛠️
When the user clicks the back button, the previous page is not necessarily reloaded. Most of the time, the previous page and its entire state are "popped" from a history stack. There is a a
pageshow
event that is fired every time a page is shown, however, and that event subscription persists in the history state. By subscribing to that event when page A is first loaded, then when the user navigates to page B and clicks the back button to come back to page A, we can know that page A is – from the user's perspective – reloading. When this event fires, we hide the navigation loader.Note
This
pageshow
event is fired after the page is visually restored for the user, so there is a quick flash of the navigation loader before it is hidden. There is an experimentalpagereveal
event that is fired before visual rendering, but it is not through the standards process yet and is not widely-supported outside of Chrome.Sometimes the browser will evict a page's state from the browser stack (for example, to reclaim memory if there are too many pages in the stack). In that case, the page is reloaded from scratch. In this case, the navigation loader will be hidden by default.