swup / scroll-plugin

A swup plugin for smooth scrolling 🏄‍♂️

Home Page:https://swup.js.org/plugins/scroll-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I'm not even sure if this is a issue, but I need help

artyor opened this issue · comments

If I click on a link to load new page, and once the page is loaded, it will keep scroll position of old page.
Meaning, if my button is somewhere in middle or bottom of the 1st page, and I click it, the new page will be scrolled down already...
Is this by default?

PS.
I'm able to fix this with window.scrollTo(0, 0); when refreshing JS with swup events...but I want to understand if this is by purpose or Im doing something wrong, cause I cant see why would it keep scroll position

Hi, sorry for the delay. You're likely referring to the page being scrolled down and scrolling to the top while you already see the new page. This is by design and can be adjusted with the Scroll plugin options. In particular, you need to set the animateScroll to false for this not being the case. You can adjust the scroll options of the plugin on the go as well, to have the animated scrolling at some times, while not others.

swup.plugins.find(pluginInstance => pluginInstance.name === 'ScrollPlugin').options.animateScroll = false;

Closing as part of the cleanup, but feel free to reopen if you're still having problems.