Is there a plan to support onStartReached for version 0.72+? #952
Unanswered
chinamcafee
asked this question in
Q&A
Replies: 5 comments 1 reply
-
@chinamcafee did you find any workaround? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Any plans to support this prop soon ! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Any updates? so exited to see this feature! |
Beta Was this translation helpful? Give feedback.
0 replies
-
This feature is much needed! 🙏 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I wrote a workaround for this prop const canMomentum = useRef(false);
const onMomentumScrollBegin = useCallback(() => {
canMomentum.current = true;
}, []);
/**
* @shopify/flash-list doesn't support onStartReached
* Implement a workaround with using {onMomentumScrollEnd}
*
* https://reactnative.dev/docs/virtualizedlist#onstartreachedthreshold
* How far from the start (in units of visible length of the list) the leading edge of the list must be from the start of the content to trigger the onStartReached callback. Thus, a value of 0.5 will trigger onStartReached when the start of the content is within half the visible length of the list.
*/
const onMomentumScrollEnd = useCallback(
({ nativeEvent: { contentOffset, layoutMeasurement } }: NativeSyntheticEvent<NativeScrollEvent>) => {
if (!canMomentum.current) return;
const onStartReachedThreshold = props.onStartReachedThreshold ?? 0.5;
const distanceFromStart = contentOffset.y;
if (distanceFromStart <= layoutMeasurement.height * onStartReachedThreshold) {
onStartReached();
}
canMomentum.current = false;
},
[props.onStartReachedThreshold],
);
return (
<FlashList
{...flashListProps}
inverted
onMomentumScrollBegin={onMomentumScrollBegin}
onMomentumScrollEnd={onMomentumScrollEnd}
// onStartReached={onStartReached}
/>
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use React Native 0.72 and the new prop onStartReached of FlatList is useful for me. But it seems that onStartReached is not supported in FlashList. Is there a plan to support onStartReached or is there any workaround?
Beta Was this translation helpful? Give feedback.
All reactions