Open Piinks opened 1 year ago
I believe that's correct. I traced the code a little and the jumpiness corresponds to big updates to the ScrollMetrics minScrollExtents property which occur while the thumb is being dragged.
I think the behavior is more pronounced since https://github.com/flutter/flutter/pull/111250
IIRC, before then, it was possible for the mouse pointer to be separated from the thumb. Since that change, they are kept together.
I think just deferring an update to the scrollbar painter until the drag gesture ends is the right approach here. @TahaTesser do you agree? If so I can send a PR right quick for this.
My PR https://github.com/flutter/flutter/pull/111250 was reverted and then @xu-baolin took it over in https://github.com/flutter/flutter/pull/112434.
I think just deferring an update to the scrollbar painter until the drag gesture ends is the right approach here. @TahaTesser do you agree? If so I can send a PR right quick for this.
Sounds good
Oh right, no wonder I had a hard time finding it via the git blame. Thanks for weighing in!
When scrolling from 1318.9 to 1337.0, the scroll metrics suddenly shrink, causing the wrong new position value to be calculated.
Maybe we should adjust the value in this case.
Just came out with a solution and will check whether it suits all the metrics change cases.
Thanks @xu-baolin!
Updated:
https://github.com/flutter/flutter/pull/121786 resolved the original issue in accordance with native behavior, but I am leaving this open to see if folks want the option for the first idea we had for this. If you would like the option to have the scrollbar update after the drag is released, add a :+1:
For more context see: https://github.com/flutter/flutter/pull/121786#discussion_r1129803106
Also related: https://github.com/flutter/flutter/issues/97676
OP:
Investigating https://github.com/flutter/samples/issues/1680
I suspect (if the scrollbar is being dragged) that the scroll metrics are being updated while drag is active on the scrollbar, leading to the jumpy behavior in the video. The list is not a fixed extent list, so as items are being added, the max scroll extent is changing in real time.
If so, we should defer updating the scrollbar with new metrics until after dragging ends to the user does not get flung around while holding onto the scrollbar.