-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Loading more items in mode: reverse #162
Comments
Hi, I'm developing a prop in #147 for similar purpose, which will switch keeping position from bottom not top when items are shifted/unshifted. It's almost working but the api isn't finalized yet. And it still cause jump in edge case. As you pointed out, positioning can be improved in reverse scrolling but I'm bit wary to implement them because each people may have different use cases. reverse-jump.mov |
This is fantastic. My issues that I can't workaround are 2:
|
If you just want to stay at bottom when items added, scrollToIndex with end align may work: const ref = useRef<VListHandle>(null).
useEffect(() => {
ref?.current.scrollToIndex(elements.length - 1, "end");
}, [elements.length]
return <VList ref={ref}>{elements}</VList> virtua/stories/advanced/Chat.stories.tsx Lines 69 to 72 in 691183a
Sticking to bottom automatically might be better, and it is actually implemented as jump handling for scrollToIndex , but it's not exposed as props yet. |
@inokawa we are doing a release later today with virtua for our message list (for https://noor.to) is there anyway I can make a PR or for you to expose this as an option? we're loving virtua so far. |
That's sounds nice! The stick to bottom during imperative scrolling logic is here. PRs are welcome but I doubt it would not work for other purpose as it is, because it's designed to work with imperative scrolling and the jump compensation in this lib is very timing dependent. Lines 213 to 227 in 691183a
|
Hey @inokawa , great! Is there a way to track "Reverse scroll in iOS Safari"? |
For a note, I changed the compensation logic described in #162 (comment) to work in more situations in |
Is your feature request related to a problem? Please describe.
I use virtua in a chat message list and when scroll hits the top we load more messages. But we lose scroll state and either jump to offset: 0 at top or far bottom.
Describe the solution you'd like
It should have a way to pin scroll to top most item in the viewport so user doesn't feel any jumps.
Describe alternatives you've considered
Using a useLayoutEffect to scroll to that item manually works but is janky and not smooth.
Additional context
In general, mode: reverse scroll positioning can be improved, eg. to load at the bottom initially and not top, keep at bottom when item sizes change, etc. We can implement most of these given flexible APIs. What's important is user shouldn't feel any frames in a between state that preserves like a jump.
The text was updated successfully, but these errors were encountered: