software-mansion / react-native-reanimated

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

onMomentumEnd of useAnimatedScrollHandler not fired for Android #5416

Closed itsramiel closed 3 months ago

itsramiel commented 10 months ago

Description

onMomentumEnd of useAnimatedScrollHandler is not fired for Android unless onMomentumScrollEnd is set on Animated.ScrollView

Previous related issues https://github.com/software-mansion/react-native-reanimated/issues/303, https://github.com/software-mansion/react-native-reanimated/issues/2735, and https://github.com/software-mansion/react-native-reanimated/issues/5058 but the issue is still valid

Steps to reproduce

Run the following reproducible:

import {View} from 'react-native';
import Animated, {useAnimatedScrollHandler} from 'react-native-reanimated';

function App() {
  const onScroll = useAnimatedScrollHandler({
    onMomentumEnd: () => {
      console.log('end hook');
    },
  });

  return (
    <View style={{flex: 1}}>
      <Animated.ScrollView
        // uncomment the line under me for things to work
        // onMomentumScrollEnd={() => console.log('end inline')}
        onScroll={onScroll}>
        {Array.from({length: 20}).map((_, index) => (
          <View
            key={index}
            style={{
              height: 150,
              backgroundColor: 'cyan',
              marginVertical: 12,
              borderRadius: 4,
            }}
          />
        ))}
      </Animated.ScrollView>
    </View>
  );
}

export default App;

Snack or a link to a repository

https://snack.expo.dev/@ramiel99/arrogant-violet-waffle

Reanimated version

3.5.4

React Native version

0.72.7

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

tomekzaw commented 10 months ago

Should be fixed with #3948.

itsramiel commented 10 months ago

@tomekzaw the PR been a draft for almost a year. Any plans to finalize it?

tomekzaw commented 10 months ago

@itsramiel I wasn't particularly happy about the approach and I'll need to rethink it. Also, there's a one-liner workaround for this so it's not as urgent as other topics that we're currently working on.

Iuriy-Budnikov commented 4 months ago

The same issue with ios :(

szydlovsky commented 3 months ago

Hey @itsramiel @Iuriy-Budnikov, the issue is already fixed on newer Reanimated versions (I'd suggest 3.10, 3.11 or 3.12)