petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.25k stars 301 forks source link

Question: Is it possible to scrollToIndex with a transition? #64

Closed Ethorsen closed 3 years ago

Ethorsen commented 4 years ago

Something like domEl.scrollIntoView();

ex. elmnt.scrollIntoView({block: 'start', behavior: 'smooth'});

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

Thx

petyosi commented 4 years ago

Yes, It is implemented but not released yet, I will publish a version in a week or two. There is a caveat though - if the item is far from its expected location, the list will “double jump”. I will update the issue once the release is out.

petyosi commented 4 years ago

Now that I gave the caveat above a thought, this could be avoidable.

Ethorsen commented 4 years ago

Very nice. Let me know if you need any help with this matter, even if only for testing.

uffou commented 4 years ago

Is smooth scrolling possible now?

savkelita commented 4 years ago

Is smooth scrolling possible now?

Yes it is! Sorry i’m on mobile device, but this may help as instant solution: https://github.com/petyosi/react-virtuoso/blob/8605ccb6be82b868b78ba1c2b1f2919e1bcdabab/src/EngineCommons.ts#L6 focus is on behavior.

petyosi commented 3 years ago

v1 beta improved the smooth scroll to index behavior - give it a try. Installation instructions are available in #203.