quire-io/scroll-to-index

Skip scroll animation

Closed this issue · 4 comments

I have a list with hundreds of images, it takes a good few seconds to jump to a specific image at the bottom so I wonder if we can add an option to skip the scroll animation.

since the search scrolling is based on flutter's layout mechanism. we can only scroll to an offset and see if our cell index is inside the viewport right after a frame of triggering scroll. that's why the scroll to method only return the Future not Void. so spending the few seconds for scrolling is because: we search, stop, check and so on again, util we get it in the viewport.

if your cell is fixed height, you can use SliverFixedExtentList or ListView with item extent, and use jumpTo() with the cell * item height to get this feature. because Flutter knows your whole state with fixed cell, they do the optimization to just right calculate the whole final layout offset without calculate each passed cells.

How about list view with various height? Is it still possible to use jumpTo to skip the animation scroll when using scrollToIndex ?

Hi @saputraiqbal, you can refer to this comment #38 (comment).

I see so it is not possible to add this feature then.
My cell is indeed fixed height and SliverFixedExtentList or ListView seems like a good fit but I want to skip animation only when the total number of items is larger than a specific number and keep the animation when it is below the threshold.
Anyway, thanks for your suggestions! I will try a different approach then...