React native synchronize two flatlist smoothly

Viewed 2076

I have two flatlist, one contains the data (dataScroll) and the other the checkboxes (checkScroll) for every data item.

The reason for this is that the checkboxes have to be always visible while the user scrolls horizontaly on the dataScroll (I put the dataScroll in a horizontally scrollable scrollview).

Demo:

expo snack demo

Tried so far:

On dataScroll's scroll event, I got the y offset and moved the checkScroll to that y position.

handleDataScroll = ({ nativeEvent: { contentOffset: { y } } }) => {
    this.checkScroll.scrollToOffset({ offset: y, animated: true });
}

It (almost) does the job, but there is a huge delay between the 2 flatlist while scrolling.

--

I read that maybe the use of animated components the way to go, but I couldn't figure out how the animation works in react native.

So I'd like to get some help on how should I bind the two flatlist together so that if I scroll on one list, the other follows it with no (or at least minimal) delay.

If only the dataScroll flatlist is scrollable that's ok too.

0 Answers
Related