Created
October 4, 2019 18:58
-
-
Save AsimKarel/ccdb126e2db0f9b16d3bbb9d18bf3cf9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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