This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
Fix back button when using the data-url feature #18
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.
Hello again!
As we discussed on #17, here's the fix for the back button. Thanks for taking time with this!
Pseudo code:
Other notes:
I updated your history.pushState so it creates events with unique info.
As before, clicking multiple smooth scroll links will update the URL fragment each time. Clicking back between them changes the URL and position to the previous fragment. So *onpopstate isn't needed in this case, even though it still fires.
Test cases
Test A:
Page position should be at the top of the page.
Test B:
Page position should be the same as when you left the smooth scroll page.
Test C:
Page position should be at the top of the page. (Some may prefer that the position return to where you clicked the link. I understand, but that's hard and this behavior is still better than the back button doing nothing.)
Test D:
Page should load with the #bazinga element at the top.