swup / scroll-plugin

A swup plugin for smooth scrolling 🏄‍♂️
https://swup.js.org/plugins/scroll-plugin
MIT License
3 stars 8 forks source link

`swup.scrollTo()` method needs review #30

Closed hirasso closed 2 years ago

hirasso commented 2 years ago

While cleaning up I noticed that the docs about swup.scrollTo() are outdated:

https://swup.js.org/api/methods#scrollto

Which lead me to think closer about it. The current implementation in Scroll Plugin allows setting the animated argument, which doesn't really make sense here, since animating the scroll position would be the whole point of using the method in the first place.

We should probably rather discuss if we want to allow targeting a specific element to be scrolled, something like this (Pseudo Code):

swup.scrollTo(2000, {target: window|HtmlElement})

Making this possible would need enhancements of gmrchk/scrl, to add the possibility to target and handle specific elements other than window.

This is somewhat related to #26 .

hirasso commented 2 years ago

@daun any opinion on this?

hirasso commented 2 years ago

Just corrected the docs for now, see PR above.

daun commented 2 years ago

I agree about extending the method to allow targeting other elements but we'd need to wait for upstream changes to the underlying scroll library, no?

hirasso commented 2 years ago

Already created a PR for that: https://github.com/gmrchk/scrl/pull/1