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

SimpleBar + Scroll to Top #671

Open
livegp opened this issue Jul 8, 2023 · 2 comments
Open

SimpleBar + Scroll to Top #671

livegp opened this issue Jul 8, 2023 · 2 comments
Labels

Comments

@livegp
Copy link

livegp commented Jul 8, 2023

Hello!
Thanks for the great library.
How to combine SimpleBar and Scroll to Top

There is a Scroll to Top function that works only if SimpleBar is not connected.
What settings are needed to fix this?

@livegp livegp added the question label Jul 8, 2023
@palyvodaBoi
Copy link

Hey! I am also interested in this

@Grsmto
Copy link
Owner

Grsmto commented Jun 10, 2024

Not sure what you meant by "if SimpleBar is not connected" but with the vanilla JS API it works like this:

const simpleBar = new SimpleBar(document.getElementById('myElement'));

simpleBar.getScrollElement().scrollTo(x, y)

for React

const scrollableNodeRef = React.useRef();

// then in a useCallback or useEffect
scrollableNodeRef.current.scrollTo(x, y);

<SimpleBar scrollableNodeProps={{ ref: scrollableNodeRef }}>
  // your content
</SimpleBar>;

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

No branches or pull requests

3 participants