-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Global OverlayScrollbars #485
Comments
Good day @ferferga Please describe your usecase specific usecase.. With your description I'm not sure whether this feature would make sense. Right now you could just do something like: // you could use any selector you like
document.querySelectorAll('[data-overlayscrollbars-initialize]').forEach((elm) => {
OverlayScrollbars(elm, {});
}); Which would initialize If you are using a specific component framework (like And in case your framework is unsuported you could also write a component yourself. The code for that is really short and easy. (You can use the existing framework components as reference) |
@KingSora That enables it for all the elements that match that attribute when the app starts, but not the elements with that attribute that could be created beforehand. It doesn't dispose the instance if one of the elements that matches that attribute is removed from the DOM tree after the instance initialization. As I mention in my issue, I can create my own Mutation Observer and do this manually, but I think it's a really common use case for people to just set OverlayScrollbars in body and expect every inner scrollbar to be an OverlayScrollbar one. Although maybe I'm using this library in the wrong way: what I want to do is to have all the scrollbars in my page with OverlayScrollbars. Targeting body just renders an OverlayScrollbar in the body element, all the children element that needs scrollbars use native scrollbars. |
@ferferga sorry for letting you wait, had some work to do in the past weeks.. I understand your need for this feature but I think your usecase might not be as common as you think, at least not in the way you're describing it.. And since this code change would increase the size of the package by a substential amount let me explain why I most likely won't add it to the core package. How was this problem approached until today? Since you're the first one to request this feature, there must have been a solution or a different way to approach this problem. The usualy way of how such a plugin is initialized goes like this:
This flow should be always possible, since you usually know when those actions happen because something has to trigger them. You know when the page loads from the browser. Since you had to program any lazy loading or swapping of dom elements you also know when those things happen. In case you are using All of this leads me to the conclusion that a
Something which could be interesting for you though is a |
@KingSora No worries about the delay, we all have our lives :) Let me summarise my reply in points:
Before going with the manual OverlayScrollbar initialization approach I explained before, I tested the Vue component precisely to check if that helped with my issue. However, it didn't. Is that the expected behaviour for the framework components and we're dealing with a bug now? In case it's not a bug and I simply misunderstood your sentence... Are you open for a PR in the Vue component to do this? Should be easy by watching component's
I didn't take a deeper look at the code and doesn't know the feasibility of my proposals, but hopefully these are the middle-ground we're aiming at? Thank you very much in advance. |
@ferferga I belive there is a missunderstanding of what the Vue Component (or any other framework component does).. Is your expectation that the Component tracks its children and applies the plugin to all child elements which have overflow? |
@ferferga anything new here? :) |
I'd love to have this as well. I have about 100 containers that are either always scrollable or can dynamically become scrollable. |
@ferferga Yes, exactly that. Apologize for the long time to reply, opened the notification and since it got marked as read I completely forgot! 😅 |
@aleksey-hoffman @ferferga I'm open for creating a package which could help with your issues. Something like
The function would receive a set of options / configuration possibilities for customization and to improve performance.. such as:
The function would return an object with a That beeing said, I would have one concern which relates to frameworks like I made some tests for vue, react and angular:
Click on the As you can see, sometimes in vue3 and react the unknown elements are removed when the state is changed and sometimes not. It often depends on certain factors which you can't really influence. |
@KingSora good job on thinking it through. Perhaps, the best solution would be to create framework specific plugins that would inject initialization into hooks. It's quite a complex problem, I wouldn't want you to spend a huge amount of time on it, I'm not even sure if this is a popular problem. Perhaps wrapping all potentially scrollable elements manually wouldn't be that difficult, since I only need to do it once, even if there's 100 of them |
Hi Everyone, Really appreciate the work here. Is there any plans to add this feature? |
Hey everyone, Thank you for the great package! |
@lwolle I'll update the readme and docs as soon as I can :) |
Is your feature request related to a problem? Please describe.
I want to have the same overlay scrollbars, with the same settings across my app, without having to take care of instantiating it manually.
Describe the solution you'd like
A
deep
key (with a boolean value) for the OverlayScrollbar instance options that chooses between adding thedata-overlayscrollbars-initialize
attribute and the overlayed scrollbars to every child (recursively) of the target element during the instantiation of the instance.Describe alternatives you've considered
Creating my own Mutation Observer and doing all this process manually.
Additional context
An additional attribute
data-overlayscrollbars-deep-ignore
can be added so that element and its descendents are ignored, in case the user wants to instantiate a different OverlayScrollbars instance with a different set of options from the global one.For frameworks like Vue, a directive could be used instead.
An additional option
replaceGlobalAPIs
to use in conjuction withdeep
that replace global APIs likewindow.scrollTo
with functions that keep the same APIs intact, but call the scrolling to the global OverlayScrollbars instance would be nice.The text was updated successfully, but these errors were encountered: