For some reason calling scrollTo({x: 50})
on ScrollView
and scrollToOffset({offset: 50})
on FlatList
has no animation on Android only.
const scrollViewRef = useRef<ScrollView>(null);
...
const handleOnPress = useCallback(
(data) => {
scrollViewRef.current.scrollToOffset({offset: getOffset(data)});
...
},
[getOffset]
);
...
<ScrollView
ref={scrollViewRef}
...
>
<MyItem onPress={handleOnPress}/>
<ScrollView/>
The same problem happens when using FlatList
with the proper adjustments.
Turns out I had two calls to the
scrollTo
method (somewhere else in the code), equivalent example:And for some reason this caused the Android animation not to work.