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

osInstance.scroll is not a function #479

Closed kobe651jp closed 1 year ago

kobe651jp commented 1 year ago

I'm trying to handle scroll to top/bottom.But getting error as follows.

TypeError osInstance.scroll is not a function

my usage

<OverlayScrollbars
  ref={scrollRef}
>
  <BiArrowToBottom
    className="absolute bottom-1 right-1 cursor-pointer"
    onClick={() => {
      console.log("scrollRef", scrollRef);
      const osInstance = scrollRef.current.osInstance();
      osInstance?.scroll({ top: "100%" });
    }}
  />

in my console showing image

I thing get osInstance working fine.but scroll is not function! Is my usage wrong?

KingSora commented 1 year ago

Good day @kobe651jp

The scroll function is not implemented in v2 yet.. You can use the browser native scroll functionality like:

osInstance().elements().viewport.scrollTop = 10;
// or
osInstance().elements().viewport.scrollIntoView();
// or 
osInstance().elements().viewport.scroll({ top: 10 });
kobe651jp commented 1 year ago

This is working perfectly! Thank you very much.