Keep the scroll position with back button / browsing back
See original GitHub issueHello, when I click a link in the bottom of a page I will be on the bottom of the next page, I fixed that with the scroll plugin but when when I go back, the scroll position is allways the top of the page, so in the both case Swup is doing the opposite of what I want, I am doing something wrong ?
Here is my config :
const options = {
plugins: [
new SwupScriptsPlugin({
head: false,
body: false
}),
new SwupScrollPlugin({
doScrollingRightAway: true,
animateScroll: true,
}),
new SwupPreloadPlugin(),
new SwupDebugPlugin(),
],
animateHistoryBrowsing: false,
animationSelector: '[class*="transition-"]',
containers: ["#swup"],
cache: false,
linkSelector:
'a[href^="' +
window.location.origin +
'"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup])',
skipPopStateHandling: function(event) {
if (event.state && event.state.source == "swup") {
return false;
}
return true;
}
};
const swup = new Swup(options);
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How can I retain the scroll position of a scrollable area when ...
During page unload, get the scroll position and store it in local storage. Then during page load, check local storage and set that...
Read more >Restore the scroll position when browser back button is clicked
When I've looked at the product and clicked the Google Chrome back button, the scroll position is back at the beginning of the...
Read more >How to return to the same scroll position when using browser's ...
Here's a snippet of code that I use to save the scroll position. I use it when a user has navigated away from...
Read more >Restore the scroll position when browser back button is clicked
Clicking on the internal link and scroll. Hit the browser back button, and your scroll position changes back to the original position.
Read more >Chrome no longer saves scroll position when going back on ...
go to a non-Wiki site; scroll down away from the top; click on a link to another page; navigate back; confirm that my...
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
I first struggled with this as well. You have to save the scroll positions of previous pages. This is how I’m doing it. It only works when navigating back though. Forward navigation doesn’t work …
And in the scroll plugin I had to define this. Otherwise there’s some weird scrolling up and down happening.
@gmrchk The scroll position actually doesn’t work on Chrome either. Or maybe I’m doing something wrong on my end?