robert-luoqing / flutter_list_view

MIT License
47 stars 17 forks source link

Uncorrect `animateToIndex` animation #21

Closed krida2000 closed 4 months ago

krida2000 commented 1 year ago

If call animateToIndex to element in end of the list, then animation will be uncorrect.

Problem https://user-images.githubusercontent.com/71345244/209559725-76ba3cbf-fff7-4798-9b6d-50dfbae38655.mp4

I have fixed it by folowing changes:

Fix ![image](https://user-images.githubusercontent.com/71345244/209559773-2a9fedcb-7aed-489d-8002-ead890a65e62.png)
robert-luoqing commented 1 year ago

Thanks @krida2000, Could you please uncomment the line and test it to check whether is working fine?

jumpToIndex(index, offset, basedOnBottom);

The "jumpToIndex(index, offset, basedOnBottom);" is used to guarantee jump to correct position. The scrollOffset in position?.animateTo may not accurracy. bacause we didn't know the further item's height. So the jumpToIndex can ensure jump to correct position.

In this time, jumpToIndex is very important to ensure correct position the list view jump to finally.

robert-luoqing commented 1 year ago

BTW, Could you please show me the animateToIndex you have wrote? include its parameters.

Thanks,

krida2000 commented 1 year ago

@robert-luoqing In screen all changes that I made.

If uncoment jumpToIndex(index, offset, basedOnBottom);, animation still be uncorrect. I think similar changes should be added to the _handleJump function to fix animation.