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

Closed
opened 2019-08-28 04:27:32 -05:00 by gapplef · 3 comments
gapplef commented 2019-08-28 04:27:32 -05:00 (Migrated from github.com)

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?

I'm using Hexo to generate my personal website, and the theme [`NexT`](https://github.com/theme-next/hexo-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 commented 2020-05-15 02:56:21 -05:00 (Migrated from github.com)

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

I am having the same issue. Does anyone have an idea how to fix it?
bjoernhasse commented 2020-05-15 16:36:41 -05:00 (Migrated from github.com)

Okay I found the reason for this behavior:

Pjax sets scrollRestoration to 'manual':
7940a6e3e5/index.js (L26)

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

  new Pjax({
    scrollRestoration: false,
  });
Okay I found the reason for this behavior: Pjax sets scrollRestoration to 'manual': https://github.com/MoOx/pjax/blob/7940a6e3e595dae970f670b0abfc2cc03d74d614/index.js#L26 You can configure this by setting 'scrollRestoration' to false: ```js new Pjax({ scrollRestoration: false, }); ```
gapplef commented 2020-05-16 00:42:12 -05:00 (Migrated from github.com)

@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?

@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?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#214