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

Is it possible to restore the scroll position at page refresh? #214

Open
gapplef opened this issue Aug 28, 2019 · 3 comments
Open

Is it possible to restore the scroll position at page refresh? #214

gapplef opened this issue Aug 28, 2019 · 3 comments

Comments

@gapplef
Copy link

gapplef commented Aug 28, 2019

I'm using Hexo to generate my personal website, and the theme NexT I used provide PJAX support. After enable PJAX, the scroll position back to top of the page on every refresh.
Is it possible to restore the scroll position at page refresh?

@bjoernhasse
Copy link

I am having the same issue. Does anyone have an idea how to fix it?

@bjoernhasse
Copy link

Okay I found the reason for this behavior:

Pjax sets scrollRestoration to 'manual':

pjax/index.js

Line 26 in 7940a6e

history.scrollRestoration = "manual";

You can configure this by setting 'scrollRestoration' to false:

  new Pjax({
    scrollRestoration: false,
  });

@gapplef
Copy link
Author

gapplef commented May 16, 2020

@bjoernhasse This solved my problem, thanks!

According to the README

scrollRestoration (Boolean, default: true)
When set to true, Pjax will attempt to restore the scroll position when navigating backwards or forwards.

What does this mean?

gapplef added a commit to gapplef/hexo-theme-next that referenced this issue Aug 2, 2020
Fix the problem that scroll position can't restored at page refresh after PJAX enabled.
For reference, see MoOx/pjax#214
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

No branches or pull requests

2 participants