I have a flatlist with a bunch of item in it now when I press the button the flatlist scrolls down using ref and scrollToIndex method. But the scroll animation is faster than what i need is there anyway to increase the scroll animation duration?
This is the code for scrollup (up swipe gesture) function
const scrollUp = () => {
console.log("Up Gesture", currentIndex);
if (currentIndex <= DATA.length - 1) {
if (currentIndex != DATA.length - 1) {
flatlistRef.current.scrollToIndex({
index: currentIndex + 1,
animated: true,
viewOffset: 200,
});
setCurrentIndex(currentIndex + 1);
}
}
}
This is jsx returned
return (
<>
<StatusBar hidden={true} />
<Button title="click me" style={{ position: 'absolute', zIndex: 20, top: 20, }} onPress={() => scrollUp()} />
<AnimatedFlatList
{...{ onScroll, ListFooterComponent, ListHeaderComponent, onScrollEndDrag }}
ref={flatlistRef}
overScrollMode='never'
// scrollEnabled={false}
scrollEventThrottle={1}
data={DATA}
style={{ width: WINDOW_WIDTH, height: WINDOW_HEIGHT, backgroundColor: 'black' }}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index }) => {
return <SinglePost aspectRatio={item.aspectRatio} uri={item.imgUrl} y={y} index={index} />
}}
/>
</>
);
Any help would be really appreciated, I have been working on the bug for past few day yet I did not manage to find any clear solution :(