Skip to content

Update withIO.js#23

Open
gauravkumar1007 wants to merge 2 commits intozhbhun:masterfrom
gauravkumar1007:master
Open

Update withIO.js#23
gauravkumar1007 wants to merge 2 commits intozhbhun:masterfrom
gauravkumar1007:master

Conversation

@gauravkumar1007
Copy link
Copy Markdown

Problem: Native scroll mapping does not work on IOFlatList when using Animated.event with useNativeDriver: true
Animated.event( [{ nativeEvent: { contentOffset: { y: scrollY } } }], { useNativeDriver: true }, );

the mapped Animated.Value (e.g. scrollY) often does not update on the native animated path, so anything that depends on it—interpolate, translateY, opacity, etc.—does not follow the scroll.

Expected Behavior: Same as Animated.FlatList: with useNativeDriver: true, scroll contentOffset should drive the linked Animated nodes on the UI thread so header parallax, sticky UI, and other scroll-linked animations stay smooth and in sync.

Fix: Animated.event / useNativeDriver: true with IOFlatList (and other IO scrollables) by forwarding refs to the inner list

Animated.createAnimatedComponent(IOFlatList) could not reliably drive contentOffset → Animated.Value on the native thread (useNativeDriver: true). This change forwards the merged ref from Animated (and any consumer ref) to the underlying FlatList / ScrollView, so native animated scroll listeners attach to the real scroll view instead of the intersection-observer wrapper.

1. React.forwardRef – the HOC returns a forward-ref component.
2. captureScrollerRef – the inner list’s ref callback sets this.scroller.current and forwards the outer ref (Animated’s merged ref + your listRef) to that same FlatList instance.
3. forwardedRef is stripped from props before {...restProps} so it is not passed down to FlatList.
4. Wrapper View keeps collapsable={false} so the IO root view is not flattened away on Android.

Intersection logic still uses nativeRef on the wrapper View for root.node; scroll + Animated use the list instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant