Shopify / flash-list

A better list for React Native
https://shopify.github.io/flash-list/
MIT License
5.54k stars 283 forks source link

scrollToIndex() not accounting for padding in horizontal FlashList and initialScrollIndex not accurate #1311

Open trevorpfiz opened 2 months ago

trevorpfiz commented 2 months ago

Current behavior

https://www.loom.com/share/75347ae785e342b3ae08237c1a089620?sid=84d33c94-5093-496d-98a4-d7f2de061bd2

Expected behavior

I would expect scrollToIndex to account for the horizontalPadding in a horizontal FlashList. I would also expect initialScrollIndex to scroll to the last item and have it be in the center of the screen like the inverted lists starting at the first item.

To Reproduce

https://snack.expo.dev/@elektrikspark/thrilled-orange-stroopwafels https://github.com/trevorpfiz/flashlist-bugs-demo

Platform:

Environment

1.7.1 and 1.7.0

Reach out if more information is needed! Thanks!

hmust92 commented 1 month ago

I am running into the same issue. Whenever i provide the initialScrollIndex prop, it just doesn't take the padding I apply as part of contentContainerStyle into account. If I do not provide this prop, it seems to start off perfectly fine.