hyochan/react-native-masonry-list

onEndReached doesn't trigger onEndReachedThreshold's exact scroll position.

daseuls opened this issue · 1 comments

Describe the bug
Hi,
I want to make infinite scroll with onEndReachedThreshold and onEndReached.
But when I use onEndReachedThreshold and onEndReached, it triggers onEndReachedThreshold's inaccurate scroll position.
I add my code and video here.

  return (
    <SafeAreaView style={styles.container}>
      <MasonryList
        keyExtractor={(item, index): string => `${item.id}${index}`}
        numColumns={2}
        data={imageList}
        renderItem={({item}) => (
          <ImageItem item={item} onPressBookmarkBtn={onPressBookmarkBtn} />
        )}
        onEndReachedThreshold={0}
        onEndReached={() => console.log('onEndReached !')}
        onMomentumScrollBegin={() => setIsLoading(true)}
      />
    </SafeAreaView>
  );

Screenshots
https://user-images.githubusercontent.com/71131248/179920395-b28b3aa2-7b6c-4b78-abbe-ab8aeb69a892.mp4

Desktop (please complete the following information):

  • OS: Mac OS Big Sir
  • Browser: Chrome
  • Version: 91

Smartphone (please complete the following information):

  • Device: iphone 13
  • OS: IOS 15.5

@daseuls Hello. Thanks for issuing this. I've just investigated the problem and this was caused by falsy detection in js when 0 is passed to props on onEndReachedThreshold.

I've managed to fix this in #43, which will be released to 1.3.2. Feel free to issue any other problems afterward.