-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initialScrollIndex
and estimatedFirstItemOffset
don't work together
#671
Comments
Also wanted to mention that if |
I have a similar issue. It actually does get close to the right index, but has a slight flicker for a second. |
any solution guys ? |
As a temporary workaround I’ve added an effect that scrolls to the initial index after a delay in mount. function useScrollToInitialIndexOnce({
initialScrollIndex,
shouldScroll,
flashListRef,
afterMs,
}: {
/**
* Will only scroll once if this value is defined
*/
initialScrollIndex: number | undefined;
shouldScroll: boolean;
flashListRef: React.RefObject<FlashList<any>>;
afterMs: number;
}) {
const hasScrolled = useRef(false);
useEffect(() => {
if (isDefined(initialScrollIndex) && shouldScroll && !hasScrolled.current) {
const index = initialScrollIndex;
hasScrolled.current = true;
setTimeout(() => {
flashListRef.current?.scrollToIndex({
animated: true,
index,
});
}, afterMs);
}
}, [shouldScroll, initialScrollIndex, afterMs, flashListRef]);
} I set the And I added the ref check because in our app the other params could change during the time that hook is mounted and that shouldn’t cause any additional scrolls. |
@david-arteaga thanks, |
This seems to be happening on iOS only but looks like a real issue. We'll try looking into this. |
It is also android issue |
Same issue here. I have some custom insets and offsets, this seems to affect the position of the card when scrolled to as well. |
@fortmarek I was wondering if you've had the opportunity to look into this matter. Your assistance would be greatly appreciated. Thanks! |
Has anyone figured out a solution to this issue? |
I do not think it will be performant for a large list because the initial scroll can be too much. In my use case, I have paging enabled as well |
I’ve used it with a list with about 5k images in rows of 3 (so about 1.6k rows) and it’s worked fine for that. At least I haven’t seen any visual jankyness. Haven’t profiled it though. I did provide heights for all elements ( But yeah, it’s a workaround, not a fix 🥲 |
I'm using scrollToOffset instead and calculating the offset I need manually
However, the 200ms was too small on web. I needed to bump it up to 500ms on an MBP M1X, so it'll be even flakier on smaller devices. Anyone know a timing signal I can use to determine readiness? @naqvitalha this has been open for two years and still quite broken with a deep rooted issue in RecyclerListView. Any plans to fix it soon? |
Current behavior
When providing both
initialScrollIndex
andestimatedFirstItemOffset
, the content is not scrolled the right amount. TheestimatedFirstItemOffset
value is ignored.This is the recording from this snack: https://snack.expo.dev/@david.arteaga/faulty-initialscrollindex-with-estimatedfirstitemoffset
The
initialScrollIndex
is set to3
, so theItem 3
item should be at the top of the list, but it's not.RPReplay_Final1668051117.MP4
If the header is removed then
initialScrollIndex
behaves as expected.Expected behavior
The
estimatedFirstItemOffset
should be considered when calculating the initial offset wheninitialScrollIndex
is provided.To Reproduce
Run this snack on iOS:
https://snack.expo.dev/@david.arteaga/faulty-initialscrollindex-with-estimatedfirstitemoffset
Platform:
I have not tested on Android.
Environment
1.1.0
The text was updated successfully, but these errors were encountered: