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 when navigating to a new page

See original GitHub issue

First of all, thanks for this awesome static route lib 😃

I’m wondering if there’s a cleaner way than window.scrollTo(0,0) when navigating to a new page from a page that has been scrolled even a tiny bit down? Since if I don’t do this, the new page will be shown with the previous scroll position.

Am I missing anything or is this the right way to do it? Cheers.

edit: Did a quick search but forgot to remove filters. Seems like others are also doing the scroll resetting manually #26

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ItalyPaleAlecommented, Nov 3, 2019

See also #26

Yes that is probably the best way. The router will not do that for you as we cannot make assumptions about your app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to reset scroll position after navigating to a new route #170
Then in your route config, simply add a settings: {noScrollToTop: true} to the routes that should not scroll to top. 3
Read more >
how to reset scroll position in a div using javascript
My problem is when I scroll down the content of div (view) and click another tab, the content disappears (but the content is...
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, ... then switch to another tab, it opens midway down...
Read more >
Reset Scroll position on change of Routes — React - Medium
The issue was when we scrolled to the bottom and click on any links or menu item to route another page, the next...
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 >

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