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

Scrolls to incorrect position on Firefox when using anchor link

andrew-ireland opened this issue · comments

Hi Georgy, congrats on the refactor of Swup — it appears really well thought out! I really like the plugin architecture especially.

I've just built a new site using this version, but in testing have noticed that when using an anchor link from another page the Scroll Plugin isn't hitting the correct spot in Firefox. It scrolls to the correct position in Safari and Edge.

I'm using the following options (the issue occurs with doScrollingRightAway set to false as well):

    new SwupScrollPlugin({
      doScrollingRightAway: true, // default false
      scrollFriction: .35, // default 0.3
      scrollAcceleration: 0.04, // default 0.04
    })

Could this be a bug, or is there some sort of user error on my behalf I'm missing? Happy to provide a link to my staging site if that's helpful.

Thanks for your help.

Hi @andrewjireland, I'm glad you like it, really like the separated logic myself.

There are some issues with Firefox scrolling swup/swup#95.
However, that should not affect the scroll plugin when it's not triggered by the back/forward button.
I think I'm able to replicate this behavior. Firefox probably needs some more time to render the element before checking where it's placed, so delaying the call of scrollTo by one tick should do the trick, but I'm gonna need to investigate a bit on this. If you (or anyone else) would like to pitch in and create a PR, that would be awesome too.

In any way, thank you for reporting!

The issue seems to be gone in recent Firefox versions; I'll close this for now. If anyone is still seeing this problem, feel free to reopen.