software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.67k stars 1.27k forks source link

useAnimatedScrollHandler with refreshControl not working #5972

Closed SumitSharmaJii closed 1 month ago

SumitSharmaJii commented 2 months ago

Description

useAnimatedScrollHandler is not working on Android with RefreshControl similar to https://github.com/software-mansion/react-native-reanimated/issues/3937

Steps to reproduce

<Animated.ScrollView 
    onScroll={scrollHandler}
    refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}> {children}  </Animated.ScrollView>

Snack or a link to a repository

https://snack.expo.dev/OAXfUmXwP1DilS_uErLED

Reanimated version

3.10.0

React Native version

0.74.1

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Santhosh-Umapathi-Beautyze commented 2 months ago

Same issue on Android

Reanimated version 3.11.0

Does not even gets called.

  const onScroll = useAnimatedScrollHandler({
    onScroll: event => {
      const currentOffset = event.contentOffset.y;
      //Scroll not outside of top bounds
      if (currentOffset > 0) {
        isScrollingUp.value = scrollY.value > currentOffset;
        scrollY.value = currentOffset;

        isAtBottom.value =
          currentOffset >=
          event.contentSize.height - event.layoutMeasurement.height;
      }
    },
  });
<Animated.FlatList
        ListEmptyComponent={ListEmptyComponent}
        ListHeaderComponent={<HomeHeader navigation={navigation} />}
        ListFooterComponent={<HomeFooter />}
        ref={flatListRef}
        contentContainerStyle={styles.contentContainer}
        showsVerticalScrollIndicator={false}
        onScroll={onScroll}
        onEndReached={hasMore ? onNextPage : null}
        onEndReachedThreshold={2}
        onRefresh={onRefresh}
        refreshing={false}
        scrollEventThrottle={16}
        data={data}
        keyExtractor={(item, index) => `${item.id}-${index}`}
        renderItem={renderItem}
        initialNumToRender={5}
        removeClippedSubviews
      />
bogdanovic91 commented 2 months ago

same issue here on Android

Ravnravn commented 2 months ago

This patch fixes the issue on 3.11.0

szydlovsky commented 1 month ago

Hello everyone, the patch @Ravnravn mentioned is already included in 3.12 version - please upgrade Reanimated and it should be gone 👍