Skip to content
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

Restore scroll position on reload #4

Merged
merged 2 commits into from
Apr 28, 2021
Merged

Restore scroll position on reload #4

merged 2 commits into from
Apr 28, 2021

Conversation

PaperStrike
Copy link
Member

@PaperStrike PaperStrike commented Apr 27, 2021

See next-theme/hexo-theme-next#74 (comment) for initial motivation.

PR Type

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Documentation.
  • Translation.
  • Other... Please describe:

What is the current behavior?

Scroll position is not restored on page reload.

What is the new behavior?

On page reload, set history.scrollRestoration to auto to make browser restore the scroll position.

PaperStrike added a commit to PaperStrike/hexo-theme-next that referenced this pull request Apr 27, 2021
@PaperStrike
Copy link
Member Author

PaperStrike commented Apr 28, 2021

Just found a similar nuxt/nuxt#5080 🎉, except that the load event is not needed here.

They keep using it in:
https://github.com/nuxt/nuxt.js/blob/8e2cad5a8fd7c4fa731fea92d762b650ee5ce095/packages/vue-app/template/router.scrollBehavior.js#L8-L22

@PaperStrike PaperStrike merged commit 4997080 into master Apr 28, 2021
@PaperStrike PaperStrike deleted the scroll-reload branch April 28, 2021 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant