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

Any way to scrollBy with smooth option? #387

Open
vu0tran opened this issue Feb 20, 2024 · 3 comments
Open

Any way to scrollBy with smooth option? #387

vu0tran opened this issue Feb 20, 2024 · 3 comments

Comments

@vu0tran
Copy link

vu0tran commented Feb 20, 2024

I see the interface scrollToIndex takes optional parameter "smooth" but I'm not seeing the same interface for scrollBy(offset). Can someone help confirm? Thanks

@inokawa
Copy link
Owner

inokawa commented Feb 20, 2024

Hi, it's not implemented yet because it wasn't requested until now.
What situations do you need it for?

@vu0tran
Copy link
Author

vu0tran commented Feb 23, 2024

specifically for mobile. When the keyboard comes up, I want to smoothly scroll the scrollview down by Y pixels to match the keyboard resize :)

@inokawa
Copy link
Owner

inokawa commented Feb 26, 2024

Thanks!

As a workaround, you can use native scrollBy instead of VList's scrollBy like:

useEffect(() => {
  const handle = document.querySelector('.handle');
  handle.scrollBy({ top: 1000, behavior: 'smooth' });
}, [])

<VList className="handle">
  {...}
</VList>

or with Virtualizer:

const ref = useRef<HTMLDivElement>(null);

useEffect(() => {
  ref.current.scrollBy({ top: 1000, behavior: 'smooth' });
}, [])

<div style={{ overflowY: 'auto'}} ref={ref}>
  <Virtualizer>
    {...}
  </Virtualizer>
</div>

It seems that correct usecase so maybe we should add smooth option to VList's scrollBy.

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

No branches or pull requests

2 participants