Fix shaky scrolling of LazyColumn when the items are of varying size #362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
This mostly re-implements commit
which broke smooth content scrolling in LazyColumn when not all items are of the same size.
The problem with that commit was that on each mouse-drag event it did (conceptually)
but when some items are larger than others
scrollScale
can change significantly between the mouse-drag events, so you could havecontentPosition
decrease even whendragDelta
was always positive.What we want to do instead is to always add to
contentPosition
:The problem that commit was attempting to solve (JetBrains/compose-multiplatform#643) is solved in this commit in a different way:
Note that this trades-off smooth thumb scrolling for smooth content scrolling, as you can't currently have both (because
LazyScrollbarAdapter.scrollOffset
is discontinuous)Testing
Test: Manually on the reproducer submitted in the bug report, and also via unit tests.
Note that the existing unit test was faulty in the sense that it passed even in the presence of the behavior the commit was meant to fix. It was faulty in two ways: the mouse events it was generating were missing the scrollbar thumb, and it was scrolling in the wrong direction for the test.
Issues Fixed
Fixes: JetBrains/compose-multiplatform#2337