Skip to content

Scroll to top on page view #351

Answered by daun
thescooble asked this question in Help
Mar 22, 2021 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Update: swup 4 now comes with scroll support out of the box.

The below applies to swup 3:

You could either use the swup scroll plugin that will scroll back to the top after each transition, or you could implement a very simple non-animated version of it yourself:

swup.on('contentReplaced', () => window.scrollTo(0, 0))

Keep in mind this won't handle special cases like browser history visits or links with #hashes.

Replies: 2 comments 2 replies

This comment has been hidden.

Comment options

You must be logged in to vote
2 replies
@THRY
Comment options

@daun
Comment options

daun Feb 8, 2024
Maintainer

Answer selected by daun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants