swup / swup

Versatile and extensible page transition library for server-rendered websites 🎉

Home Page:https://swup.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimize default scroll behavior without scroll plugin

daun opened this issue · comments

Describe the problem

Currently, a default installation breaks normal scroll behavior for normal visits as well as hash changes. We're basically forcing people to install the scroll plugin.

I think we should emulate default browser behavior as much as possible by default:

  • Hard-scroll to the top on page visits
  • Let the browser handle hash changes normally unless the scroll plugin is installed
  • Let the browser handle hash changes if the target ID is not found

Then, users can install the scroll plugin for advanced functionality, like animated scroll and remembered positions on history visits.

Describe the proposed solution

  • Find a way of not defaultPreventing the click event in case it is a same-page hash change
  • Reset scroll top to 0 after contentReplaced

How important is this feature to you?

  • Would make the life of newcomers a lot easier

Implemented in #688