Reset scroll position when navigating to a new page
See original GitHub issueFirst 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:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
https://github.com/ItalyPaleAle/svelte-spa-router/issues/57