fluttercandies / flutter_scrollview_observer

A widget for observing data related to the child widgets being displayed in a ScrollView. Maintainer: @LinXunFeng
https://pub.dev/packages/scrollview_observer
MIT License
440 stars 46 forks source link

scrolling fast on web show bad index item #31

Closed rmasarovic closed 1 year ago

rmasarovic commented 1 year ago

Hi i try your example and when i scroll fast with mouse on web i see different item on screen and different values are printing on observer update

this is screen

image

and this is last print on console firstChild.index -- 14 displaying -- [14] item - 14 - -20 - 456 visible -- true firstChild.index -- 24 displaying -- [24] item - 24 - -20 - 456

any idea what is wrong?

LinXunFeng commented 1 year ago

Thx for feedback, please upgrade to version 1.13.1, or pull the latest code.

rmasarovic commented 1 year ago

i try it and when i using mouse wheel this index dont work

image

firstChild.index -- 51 displaying -- [51, 52, 53, 54, 55, 56, 57, 58] item - 51 - -8.336594410433463 - 474.33659441043346 item - 52 - 46.66340558956654 - 389.33659441043346 item - 53 - 131.66340558956654 - 334.33659441043346 item - 54 - 186.66340558956654 - 249.33659441043346 item - 55 - 271.66340558956654 - 194.33659441043346 item - 56 - 326.66340558956654 - 109.33659441043346 item - 57 - 411.66340558956654 - 54.33659441043346 item - 58 - 466.66340558956654 - -30.663405589566537

LinXunFeng commented 1 year ago

It works fine on macos, this problem seems to only occur on windows. 🧐

rmasarovic commented 1 year ago

hm i try it on mac and some

Snímka obrazovky 2023-06-03 o 15 46 32

i think this edge-case depence when use mouse wheel scroller

LinXunFeng commented 1 year ago

I have tried to fix this problem on the fix_observe_web branch and tested it, you can try it again after pulling the code.

rmasarovic commented 1 year ago

I tried it and out of 100 attempts, it failed 1 time, but I haven't find the pattern yet, but still it's perfect now.

What else did I notice when I scroll a lot and then I go away from the page, the observer keeps printing values to console. it normal behavior? image

LinXunFeng commented 1 year ago

Yes, this is normal behavior, because there was a lot of printing in the Example, and the IDE did not process it in time.

This bug is caused by scrolling in Flutter Web with mouse wheel is not smooth.

Related issues:

The problem has not been solved yet, so for now, i use delay to solve it.

The key code is here: observer_widget.dart#L148

Future.delayed(const Duration(microseconds: 1), () {

Could you please replace microseconds with milliseconds in this line of code, and try it again?

Future.delayed(const Duration(milliseconds: 1), () {
rmasarovic commented 1 year ago

i try it and maybe this is the best solution for now

LinXunFeng commented 1 year ago

Thank you, version 1.13.2 has been released to fix the above issues.