question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reset Scroll Position after page is loaded

See original GitHub issue

Description

Each time i load new page, the scroll position stays same as it was on the previous page. I want to reset the scroll position each time page is reloaded.

Environment

Gatsby version: 1.9.130 Node.js version: 6.10.2 Operating System: mac OS High Sierra

File contents (if changed):

gatsby-config.js: package.json: gatsby-node.js: gatsby-browser.js: gatsby-ssr.js:

Steps to reproduce

I’ve tried all solutions mentioned here: https://stackoverflow.com/questions/33188994/scroll-to-the-top-of-the-page-after-render-in-react-js and none of it helped. (i was adding those to html.js)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
ryanwiemercommented, Jan 28, 2018

@monsieurnebo, not sure if this is helpful or not but instead of dealing with the issue that you described I decided to simply force it to start at the top every time. Not very elegant but it was better than the current behavior for my use case.

https://github.com/ryanwiemer/rw/blob/907ee95cc39c97eb560ec39b02a7b76ad116d5c9/gatsby-browser.js#L4-#L10

7reactions
KyleAMathewscommented, Jan 30, 2018

This should restore the correct behavior folks https://github.com/gatsbyjs/gatsby/pull/3775

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - How to reset the scroll position after loading of different ...
I've created the service app-scroll.service which looks like this: ... constructor() { } scrollToTop(){ const container = document.
Read more >
Memorize Scroll Position Across Page Loads - CSS-Tricks
The trick is to throw the scroll position into localStorage right before the page is exited, and when loaded, grab that value and...
Read more >
How to reset the scrolling position when the page is updated?
Ie if you scrolled to the middle of the page and updated it, the browser remembers this position. It is required that when...
Read more >
jQuery | How can maintain scroll position after height of body ...
I have a one-page website and if user access path/#contact it will scroll to that section and after slider finish to load the...
Read more >
List - How to reset scroll position after dataSource is updated
Hi mps Developer,. You can accomplish this by using the following methods: scrollTo, scrollTop. The idea is to use the scrollTop method before ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found