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.71k stars 215 forks source link

OverlayScrollbars.scroll() function from v1 not present in v2 #603

Closed richard-viney closed 6 months ago

richard-viney commented 6 months ago

The docs say The scroll function is missing. Planned as a plugin. (WIP) - is there a workaround for this or alternatives to achieve a similar thing?

This is blocking the upgrade from v1 to v2 for us (though v1 is still working completely fine).

Thanks.

KingSora commented 6 months ago

Good day @richard-viney :)

It depends on how you used the old scroll function - it provided many "goodies" which you (depending whether you used them) would need to adapt yourself.

Generally you can scroll like this:

const { scrollOffsetElement } = osInstance.elements();
// using the native scrollTo function: https://developer.mozilla.org/en-US/docs/Web/API/Element
scrollOffsetElement.scrollTo({ top: 100, left: 100, behavior: 'smooth' });

If you want to scroll to a certain element you can use the element.scrollIntoView function for that.

In case you need more features you currently have to adapt them on your own.

KingSora commented 6 months ago

@richard-viney does that solve your problem? :)

richard-viney commented 6 months ago

Yep it does, thanks!