KingSora / OverlayScrollbars

A javascript scrollbar plugin that hides the native scrollbars, provides custom styleable overlay scrollbars, and preserves the native functionality and feel.
https://kingsora.github.io/OverlayScrollbars
MIT License
3.83k stars 214 forks source link

The scroll changes from the section to the top of the page on url with fragment #652

Closed winkcor closed 3 months ago

winkcor commented 3 months ago

Describe the bug When open link with fragment at the first load of page(not refreshing) default scroll of page is the target section but after loading the scroll bar it change the scroll to top of the page

To Reproduce Steps to reproduce the behavior:

  1. copy a link that have an fragment to section that need to scroll to reach
  2. open the link in new page
  3. now you can see that page scroll get to the top from that section

Expected behavior Do not change the scroll position from the section to the top page on the first load

Examples CodeSandbox On codeSandbox can't open new page but if you set the fragment and then hit Split panel you can see changing the scroll

I make speed of this video slow so can see the scroll change. url: /#3

https://github.com/KingSora/OverlayScrollbars/assets/111268227/157f20f4-89c4-4e94-bb15-f7f8d5b0a5d6

KingSora commented 3 months ago

Good day @winkcor :)

I've identified the issue and will publish a fix soon, thanks for the report!

KingSora commented 3 months ago

@winkcor I've published v2.9.0 which includes a fix for this issue. Please try it out and give feedback :)

KingSora commented 3 months ago

@winkcor I've just noticed that you are using scroll-behavior: smooth. v2.9.0 fixed this behavior but didn't take this style into account. I've now published v2.9.1 which fixes this behavior together with scroll-behavior: smooth :)

winkcor commented 3 months ago

Hi @KingSora Yes, version 2.9.1 fixed the problem. thanks a lot.