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

feat: export cancelScroll handle #595

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bytemain
Copy link

@bytemain bytemain commented Jan 5, 2025

I am creating an AI Chat-like app. The last item is growing in height when the AI generates some message.

At a very special moment (not always reproducible), when the last item is growing in height and I use the wheel to scroll up, the scrollbar will first scroll up and then immediately snap to the bottom.

After doing some research, this is caused by waitForMeasurement: when a user triggers a scrollToIndex, virtua will do scrolling and listen for the UPDATE_SIZE_EVENT event within the next 150ms. If at the same time, the last item is resizing, it will fire an action ACTION_ITEM_RESIZE to make the scroller scroll to the latest position. So if a user scrolls up within this 150ms, their operation will be overwritten by the latest scroll to the bottom.

here I add a new cancelScroll method to release the 150ms listener when user scroll up.

Creating a demo will consume amount of my time, So I didn't provide one, if you need a reproducible demo or have any question, please let me know

@bytemain
Copy link
Author

bytemain commented Jan 6, 2025

May have another fix, when virtua detected user's scroll event, it will cancel the unfinished resize event listener

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

Successfully merging this pull request may close these issues.

1 participant