Skip to content

Instantly share code, notes, and snippets.

@AsimKarel
Created October 4, 2019 18:58
Show Gist options
  • Select an option

  • Save AsimKarel/ccdb126e2db0f9b16d3bbb9d18bf3cf9 to your computer and use it in GitHub Desktop.

Select an option

Save AsimKarel/ccdb126e2db0f9b16d3bbb9d18bf3cf9 to your computer and use it in GitHub Desktop.
currentIndex = 0;
scrollNext = () => {
if (this.currentIndex !== this.state.data.length - 1) {
this.flatListRef.scrollToIndex({
index: this.currentIndex + 1,
animated: true,
});
}
};
scrollPrevious = () => {
if (this.currentIndex !== 0) {
this.flatListRef.scrollToIndex({
index: this.currentIndex - 1,
animated: true,
});
}
};
onViewableItemsChanged = ({viewableItems, changed}) => {
if (changed[0].isViewable) {
this.currentIndex = changed[0].index;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment