-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
Plans & Suggestions for v2.0.0 #150
Comments
Hi @KingSora , i suggest that you keep browser support but in a modular way or maybe have a separate version/release to support it but if all future features isn't feasible in older IEs and if current version 1 of library is stable or will be eventually in the future then dropping IE support is not that bad Keep up the great work! 💪👌 |
Hi. Please consider supporting css-modules. The desired API could look like this:
<Scrollbar
options={{
<cssModules?>: true/[false], //if true, import theme stylesheet and use generated class-names, else use unscoped class-names
<theme?>: ['dark']/'other themes...', //defines which built-in theme to require
<classMap?=null>: {
host: 'additionalClassName',
//...
viewport: 'additionalClassName'
}
}}
> What is the gist of this:
If you need any clarification or have any concerns, let's discuss them |
Hey @KingSora, This is a great project. Huge thanks to you for your efforts! I'm considering OverlayScrollbars as a solution to a long standing problems we've had with Chromium scrollbars on Spotify. The most important features for us are performance and control over styling. |
@tryggvigy cool! I'll give my best to achieve the goals vor |
For React version, I would like to access ref to scrollable div, i.e. I know that there is an option to access this element by |
It's fairly easy to do this today <OverlayScrollbarsComponent
ref={ref => {
myScrollNodeRef.current = ref.osInstance().getElements().viewport;
}}
> |
Thank you for your answer @tryggvigy, I do it in similar way now: const osInstance = scrollbarsRef.current?.osInstance()?.getElements("viewport");
const scrollbarsViewportRef = osViewport ? { current: osViewport } : null;
...
<OverlayScrollbarsComponent ref={scrollbarsRef} but it looks like a workaround not the long-term react-way solution. I believe that API of any react component which renders any DOM node should have an ability to pass a ref of that node to an app. Unfortunately React team does not provide recommendations for developers how to create components to make them compatible to each other. |
@seleckis there are some issues I have with designing such a API. I could simply use a In react you have I'm aware that it would be "more beautiful" when the lib would behave like a "true" react lib, but since this isn't the case and I want to have the |
@KingSora I see, alright, thank you |
This comment has been minimized.
This comment has been minimized.
Dropping support for IE8-10 seem absolutely natural. Nowadays the minimum reasonable expectation is IE11 (and only for government office whose computers, etc). And even IE11 is questionable (see: IE11 Mainstream End Of Life in Oct 2020 https://www.swyx.io/writing/ie11-eol ) A good compromise would be adopt a more plugin/extension architecture (optional support for the scroll method, IE11, etc), so that the core library is more focused and easier to maintain. |
This comment has been minimized.
This comment has been minimized.
@NechiK feel free to create a corresponding issue here in github where we can discuss such things :) Short update for Thanks to the IE drop, I could get rid of many lines of fallback and compatibility code. |
Would it be out of scope to consider just adding virtualization capabilities into an optional dependency, rather than trying to support any virtual scroller? I feel like it might be more effort to support virtual scrolling libraries, than just rolling your own. |
@Nikey646 thanks for you suggestion! I've thought about that too, but in the end I came to the conclusion, that support for virtual-scrolling libraries can't be added as a plugin, because its too much interweaved with the initialization process. I'll realize this support in a general way. Please don't think about it as a solution per library (the code-base won't grow with every supported virtual-scroller). The solution I'm aiming for is a initialization process, which is so flexible, it can work nicely with the structure most (if not all) virtual-scroller libraries have. This initialization process is a bit more complex than the "normal" one, but it is optional and for "more experienced users". With this new optional system, there is also support for almost any kind of library (dropdowns, grids etc.) because most of them follow a core pattern structure (one host element, and one viewport element). I'll also definitely give my best to design this system in the most lightweight way possible. |
I would like to suggest one option for better styling and customization. Material-UI for React has a very powerful API for complex component customization. They provide classes object, that one can use to assign a custom class to nested elements. The same approach could be used to customize parts of the scrollbar or host element. Here is more information: https://material-ui.com/customization/components/ Also, for react wrapper, it would be great to support css in js approach for base styles instead of loading global external stylesheet. I could help with that if you accept contributions. It's basically just converting existing stylesheet into css in js equivalent, and leaving option for providing css-in-js solution to be used to that (so that you don't couple with any of them). |
@vdjurdjevic Thanks for you suggestion! The plugin right now offers almost infinite possibilities of style customization, you just have to write your own theme which is documented here. OverlayScrollbars will always follow the approach that JS (logic) and CSS (styling) are two things which won't be mixed. That beeing said, the core library will also be always dependent on its stylesheet, because it is the most straight forward way to implement it, without adding additional complexity. The workflow should be:
This is something everyone can do, no matter which project structure is used. In terms of customization I still have to decide whether I'll implement someting like @Media-Evil suggested. |
Well, I don't know what kind of benefits you compare with sass, but css in js is not just about how you write your css, it's about better dynamic styles, minimal css in production, more confidence when refactoring, modifying, deleting parts of css, automatic vendor prefixing, etc. But anyway, I am not talking about core lib, just react wrapper. Core lib should stay the way it is, compatibility with any environment. What @Media-Evil suggested is similar to what I suggested with classes property. It could be added to core lib since it's just another option to set different parts of class names. I will try to explain better why this is needed. As you said, "The plugin right now offers almost infinite possibilities of style customization, you just have to write your own theme which is documented here". And you are right, it can be customized, but you have to write a global theme with complex selectors to target parts you want, and it's impossible to do without checking documentation every time. For example, you have to target
You can use this object to optionally assign additional classes to parts of the element tree, and this can be part of generic core packing, it's not coupled to any css technology. This way we could at least generate this customization classes with css in js and change them dynamically, and load default css with an external stylesheet. |
@vdjurdjevic ouh, my bad! I interpreted your first proposal as if you want replace the stylesheet completely with CSS in JS stuff. The one thing which was bothering me the most was that this object would be just really big and verbose and would enlarge the already large options object. This was, because I thought this object should have default values: {
host: 'os-host',
scrollbarHorizontal: {
scrollbar: 'os-scrollbar-horizontal',
track: 'os-scrollbar-horizontal-track',
handle: 'os-scrollbar-horizontal-track-handle'
}
/* ... */
} But then I thought again about it, and what if the default value for everything is just I think this would benefit everyone, since users which don't need that functionality don't get that code shipped per default and users which need it, simply can use the extension inside their project. The plugins options object isn't touched since each extension can have its own defined options. Also this can then be used with the core library and with ever wrapper, because every wrapper supports the extension system already. In the end code would look something like that: // vanilla initialization
OverlayScrollbars(/* element */, { /* options */ }, {
"cssInJsExtension": {
host: 'os-host',
scrollbarHorizontal: {
scrollbar: 'os-scrollbar-horizontal',
track: 'os-scrollbar-horizontal-track',
handle: 'os-scrollbar-horizontal-track-handle'
}
/* ... */
}
});
// react
<OverlayScrollbarsComponent
options={{ /* options */ }}
extensions={{
"cssInJsExtension": {
host: 'os-host',
scrollbarHorizontal: {
scrollbar: 'os-scrollbar-horizontal',
track: 'os-scrollbar-horizontal-track',
handle: 'os-scrollbar-horizontal-track-handle'
}
/* ... */
}
}}
>
</OverlayScrollbarsComponent> Obviously the strings would come from your CSS module or CSS in JS lib. What do you think about this? |
That's exactly what I am talking about :) Everything is optional, that's why I used Partial<{}> for type example. That way, it does not add an extra burden for users that just use defaults, and for those that want to customize, only handle, for example, it provides an easy and straight forward way, that can be done fast without checking theming documentation. And since these class names are just strings, it does not matter if one writes them in sass, on in style tag in index.html, or use Emotion CSS function to generate it at runtime. That's the approach that MaterialUI uses and it's extremely powerful in my opinion. It's the first material implementation that I stumbled upon that allows me to fully customize every component and fit it to my product design and avoid building Gmail clone :D Now, I think that this is more option than extension semantically, but I don't mind if you make it as you proposed. My only concern is the ability to change it at runtime. Can you update extension settings at runtime? Can we do something like this with extension settings?
This is needed for dynamic styling. For example, I have 3 variants of the scrollbar in my application. I pick one of them based on the property. Or if I want to adjust it when the user switches from light to dark theme. Or provide user with the ability to tweak colors, sizes, etc. Now for the react world, my proposal was to also add as an option not to include and bundle css file and load it as an external stylesheet but to provide it as css in js. For example, default option would be current one, where you include .css file and use OverlayScrollbarsComponent. Now, we could create another repository, styled-overlayscrollbars that uses styled-components and bundles all styles with react component instead of being dependant on external stylesheet for default styling. That way users that already use styled-components just need to install that package and use OverlayScrollbarsComponent without importing external stylesheet. It saves a network request and makes it more react way, component approach, where a component is isolated and does not rely on global stuff. |
@vdjurdjevic The reason why I choosed the extension approach over the options approach is because even if the options are optional, their implementation inside the code-base is required. So users which won't ever use this functionality still have the code shipped because other users might do. Thats also the reason why I'll move the
You're right, but technically all extension-options are a way to extend the options object in a way where the required code is shipped separated from the code-base so users can decide whether to use it or not.
This is something every extension author has to implement by himself. I'll elaborate a concept for this in the future, so that it isn't as laborious as it would be now. But the general answer is yes if its implemented. |
Ok, I am ok with that approach. As long as API like that is available, I don't mind how it's implemented. Just small detail, you named it cssInJsExtension in example. It should be something like 'customStyles' or something like that. It's generic class name API, not css in js. My opinion is that it should be part of the core, as an option, since I think that customization is more often used than not, at least people need to adjust colors. And also, it's a few if statements to apply those classes if provided, code it won't affect bundle size as much. When do you think some preview version of v2 could be available? I would like to start experimenting with it as soon as possible. I am about to start some internal project next month, where I can play with unstable stuff. I see that @tooppaaa has submitted a pull request for function based implementation of react component, so I could join forces with him to implement react components (both default and textarea), and also css in js version for the most popular css in js solutions. |
@vdjurdjevic The extension name was just a name I came up with, it definitely has no relation to the real name of the extension.
Yes, but you also can customize it directly with "global" styles, without any dependencies on css modules or anything like that. In this regards I really wanna stay as basic as possible and offer more possibilities as extension (thats why I made this system in the first place). I'm not really sure when |
Great, looking forward to it :) I have one more question. Since you are dropping support for older browsers, will css file get smaller? I am thinking of making my own react wrapper with v1 until v2 is ready. I would move all styles in js. Current one is pretty big, i am just wondering if something can be omitted. |
I made wrapper for material ui users with v1. You can check it out if you want :) https://www.npmjs.com/package/@vdjurdjevic/material-scrollbars |
Branch vor |
Took a look. Pretty nice infra foundation laying. Unrelated, but I ended up picking OverlayScrollbars to solve our problems and they are now in use on open.spotify.com! Thanks! We did see a statistically significant drop in framerate but it was acceptable. The added JS work on the main thread is not much (although it's expensive when considered that 16ms is all you have each frame fro 60fps scroll. We have a few scroll-locked animations that are expensive and we certainly drop more frames with the overlay scrollbars in combination with those animations) but it's easier to cause unnecessary browser repaints. It was necessary to force .#{$theme-name} .os-viewport {
transform: translateZ(0);
} I benchmark our scrolling framerate using https://gist.github.com/bvaughn/1fc166d5cb3f8c174a1552eeaeeaa0e6 and then compare the results with a t-test: If you want to consider any of the performance or benchmarking aspects for 2.0 or the future I'm happy to talk more about that. Overall, I'm very satisfied with OverlayScrollbars. |
@tryggvigy thank you very much for that insight! It would be very helpful for me, if we could talk more about that, so that I can improve in those areas even more in Currently the plugin is doing most of the work inside the update code, and during scrolling I'm trying my best to use the cache produced by it. In the future I plan to decrease the javascript which is running during scrolling to I'm really proud and happy that |
sounds great! Thank you for your time and contributions to the web ecosystem. |
Alright, thank you! |
I've published Its almost feature complete, in case you discover something which doesn't seem to be supported but you think its crucial for the plugin, please also don't hesitate to write it here. Expecting feedback of any kind! 😺 |
@AgentSmith0 nope.. I've noted it for the next beta (should be easy to implement) |
Thanks for fixing the first bug I mentioned, is it also possible to fix #357 in v2, or do I still need to use the workaround? EDIT: fixed |
Is it possible to get a callback for the scroll event in v2? |
@KingSora the link to the readme seems to be broken. Would love to read up on the summary of changes in the beta |
@tryggvigy I merged the |
Hi @KingSora, I'm currently looking for a custom scrollbar library just like this, however my caveat is I'm looking for a scrollbar that allows overflow-x: visible on the scrollable content (image below for clarity). I don't think this was possible on v1 of your library. Is this possible with v2? JScrollpane does actually allow this if you put |
@aaronstezycki It is possible - I am using it in this way myself |
@aaronstezycki this should be possible with Edit: I'm not sure what you wanna achieve but depending on the usecase it might not be possible with both versions |
@KingSora Is there a |
@AgentSmith0 no, and I'll only make it an "opt-in" plugin, so its treeshakeable. I've Published |
Depending on the feedback I think Whats still missing:
|
Great! I have PR upgrading to the beta version in our repo but haven't had time to finish it yet! I'll try to do that soon and report any issues if I find any :) |
published the last beta version 2.0.0-beta.3 where I fixed |
I'm sorry I havent gotten around to giving feedback. I made a PR a couple of weeks ago upgrading to v2 in our project. Ran into some problems with custom styling which are probably solvable on my end. I hope I get some time to take a closer look and write a response here in a reasonable amount of time. Life's busy these days :) |
@tryggvigy Take your time :) |
Do you have any plan to support solidjs component? I'm really looking forward to this |
@luatdolphin yes, I am.. but first I'll finish react, vue, angular and svelte |
Read the details about this release in the corresponding changelogs:
They include things like Thanks everyone for beeing patient and hopefully @tryggvigy in the changelog are all breaking changes listed, also the ones related to styling. This should help you to migrate your styles. |
I had a problem when I used overlayscrollbars-solid component based on the framework solidjs start. The returned error is "An unhandler error occured: TypeError: s.template is not a function." |
@luatdolphin working on it... It would be better if you open separate issues in the future so I can track them properly :) |
@KingSora congrats on the major update being released. |
@bjarkihall Before the initialization you can use whatever native scroll api you want.. so |
@luatdolphin I've published In case you have further issues, please open separate issues and don't post them here. |
Since @tryggvigy I would still appreciate feedback from your side, since it offers a great opportunity to improve the plugin :) |
@KingSora Any updates on textarea support? |
Good day!
In this issue I want to start a discussion what you'd expect from
v2.0.0
of this plugin and what my plans are. Please feel free to post any suggestions or wishes you have, I'm open for everything! Also if you think any of my ideas are bad or aren't making much sense, this is the right place to adress it.Alright, lets start! My plans for
v2.0.0
:Browser support
IE8
, ideally I would drop alsoIE9 and IE10
soIE 11
would be the "lowest standard". This change would make the library smaller since less compatibility code is required.Breaking Changes
Currently I don't like how the instances work. Destroyed instances are basically useless. This shall change in
v2.0.0
as instances will be always of use, even if you decide todestroy
it, it will only destroy the generatedDOM
,EventListeners
,Observers
and so on. The instance itself can still be managed and you can also still utilize thescroll
function, so you don't always have to do a awkward check which scroll function (native or plugin) you should use.Instance management, this change can only be done if we support
IE 11
as the lowest standard. Instad of applying a new property to a DOM element aWeakMap
should be used for instance management.The scroll function. Currently the scroll function is relatively big and I don't really know how many users really needs it, so this change should definitely be discussed! The plan is to make it
optional
as astatic
method. So the standard lib comes without it but, you can always decide to download the extensions to use it. The usage would look something like this:scroll
function changes the same would also apply to thescrollStop
function. Thescroll
andscrollStop
function would come in one extension, so you don't have to download two separate extensions since both are essential for scrolling animations.Features
Scrollbars management: Currently the scrollbars are applied inside the
host
element. Since this request was posted a few times in the past, it could be possible to pass a DOM element to which the scrollbars should be applied. (So scrollbars could be applied also outside of the generated DOM) This feature is also related to the Compatibility with other libraries feature since the DOM structure of such libraries sometimes requires a different parent element for the scrollbars.Compatibility with other libraries. Yeah, yeah, currently its hard to use
OverlayScrollbars
with other libraries for things likevirtualization
orGrids
, thats because often these libraries weren't designed with optional custom scrollbars in mind.I don't know exactly how it will turn out, but I think its possible that
OverlayScrollbars
can offer the possibility that at least aviewport
element can be passed somehow and then The library can adapt to that. The complex part is, that any library is designed differently and some libraries offer more elements than just aviewport
and some don't. So I would also add the possibility to pass following elements:host
,viewport
andcontent
, whereviewport
is required and the others are optional.Thats it for now! Thanks for your attention and please submit your ideas or any feedback you have.
@Grsmto @MarcosRakesh @Windvis @hamed-ehtesham @parsisolution @Acccent
#55
The text was updated successfully, but these errors were encountered: