Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place of scroll track #38

Closed
leereichardt opened this issue May 8, 2018 · 8 comments
Closed

Place of scroll track #38

leereichardt opened this issue May 8, 2018 · 8 comments

Comments

@leereichardt
Copy link

Is it possible to put the scroll bars on the outside of the container? Quite often I require the scroll content to be laid out exactly as is but nicely scrollable, but with OverlayScrollbars, it often places the scrollbar over the content.

@KingSora
Copy link
Owner

KingSora commented May 8, 2018

Good day! - There was an issue similar to yours: #17

Basically it is possible and the plugin doesn't require the scrollbars to be inside. The problem is the managment of the scrollbars.

Personally I think this feature isn't necessary since the plugin gives you enough freedom to customize the padding to the content and the scrollbars. It's only a matter of how you take advantage of it.
To demonstrate this, I've created two fiddles, one in which the scrollbars are outside and one in which the padding is used in a way in which it just looks like the scrollbars are outside.

A demo where it just looks like the scrollbars are outside: https://jsfiddle.net/bedam73j/
A demo where the scrollbars are outside: https://jsfiddle.net/bedam73j/2/

If you compare them side by side (and ignore that I set a different background color of the #wrapper for better visibility), you won't notice any difference. It's just a matter of how you organize your structure. The managment of the scrollbars is just much more straight forward if they stay inside the container, so you don't have anything floating somewhere in your DOM. This can cause more problems than it solves.

@KingSora
Copy link
Owner

I'll close this issue. If you have any other questions related to this topic or if this problem isn't solved by my answer please feel free to reopen.

@sujith-sairam
Copy link

sujith-sairam commented Sep 29, 2023

@KingSora Have you overcomed this issue in the latest version ? If it is ..kindly tell me how to implement it.

@KingSora
Copy link
Owner

@sujith-sairam Yes, in v2 you can have the scrollbars outside of the host element and everything will work without problems.

You can do that by defining a scrollbars slot in the initialization:

OverlayScrollbars({ 
 target: document.querySelector('#target'),
 scrollbars: {
   slot: document.querySelector('#scrollbarsSlot'),
 },
}, {});

Or you can just move the generated scrollbars after the initialization to your desired container(s):

OverlayScrollbars(document.querySelector('#target'), {}, {
  initialized: (osInstance) => {
    const { scrollbarHorizontal, scrollbarVertical } = osInstance.elements();
    
    document.querySelector('#scrollbarHorizontalSlot').append(scrollbarHorizontal.scrollbar);
    document.querySelector('#scrollbarVerticalSlot').append(scrollbarVertical.scrollbar);
    
    // you could even clone scrollbars:
    const clonedScrollbarHorizontal = scrollbarHorizontal.clone();
    document.querySelector('#scrollbarHorizontalSlot').append(clonedScrollbarHorizontal.scrollbar);
  }
});

@sujith-sairam
Copy link

@KingSora Thanks for your reply it would be helpful if you provide docs for v2 like the one you provide for v1.

@KingSora
Copy link
Owner

@sujith-sairam The docs for v1 required a really long time to create.. I sadly just don't have the same amount of time right now as I had back then.. But I'm working on it

@sujith-sairam
Copy link

@KingSora .os-host-scrolling class name in styling is not available in v2 , i need to perform an styling action while scrolling ,is there any way to achieve it ??

@KingSora
Copy link
Owner

KingSora commented Oct 2, 2023

@sujith-sairam You can add any class in the scroll event to achieve the desired behavior.

Please open an discussion or a new issue if you have further questions...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants