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.78k stars 214 forks source link

Native scrollbar is visible on mobile view #545

Closed vakers2 closed 1 year ago

vakers2 commented 1 year ago

Describe the bug Native scrollbar is visible on mobile view.

Expected behavior Only native or custom visible

Examples I am using this code in my project:

    const options = {
        scrollbars: {
            theme: 'os-theme-custom',
            autoHide: 'scroll',
        },
    };
    const [initialize] = useOverlayScrollbars({ options, defer: true });

    useEffect(() => {
        initialize(document.body);
    }, [initialize]);

Also this issues exists on demo page. image

Environment

Additional context Not sure if I need some additional options to fix this issue

KingSora commented 1 year ago

@vakers2 Good day :)

I'm not observing this to be honest.. Are you able make a live example for me so I can inspect the issue in the browser? Also on mobile please make sure that you are not zoomed in, because otherwise the scrollbars will always appear (its impossible to hide those because those are not normal scrollbar but more of a possibility to move a zoomed in viewport)

vakers2 commented 1 year ago

Hi @KingSora , if you meant that you don't observe it on demo page, then these are the steps that I used in my chrome browser:

KingSora commented 1 year ago

@vakers2 OverlayScrollbars evaluates its environment only once when the first instance is created. Every subsequent initialization is using the already evaluated environment.

So when you change the browsers environment (which is not really possible outside of the browsers dev tools) the plugin won't know if it already initialized within the previous environment. - This means every time you start emulating a mobile screen or a different device please also refresh the page so the plugin can adapt.

Please try it again with that knowledge and report back if it still happens.

vakers2 commented 1 year ago

I see, It works correctly on demo page then. Thank you. Do I need to use

cancel: {
   nativeScrollbarsOverlaid: true,
 }

for OverlayScrollbars to work the same way in my app?

KingSora commented 1 year ago

This option will force the plugin to cancel initialization in case the native system scrollbars are overlaid already. Android, iOS and macOS are systems where the system scrollbars are overlaid 99% of the time.

You can add that if you want this behavior, but you don't have to.

vakers2 commented 1 year ago

Thank you.

dannybeckett commented 5 months ago

Another possible workaround is detailed in #622