Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9.0] useAnimatedScrollHandler does not fire events from FlashList onScroll #5941

Closed
efstathiosntonas opened this issue Apr 26, 2024 · 20 comments · Fixed by #5960
Closed
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@efstathiosntonas
Copy link
Contributor

efstathiosntonas commented Apr 26, 2024

Description

Events are not being captured by useAnimatedScrollHandler from FlashList@1.6.4 onScroll prop at least on react-native@0.73.7 on Paper.

Steps to reproduce

  1. Install 3.9.0
  2. Add onScroll handler on an Animated FlashList
  3. useAnimatedScrollHandler won't listen to events

By replacing FlashList with FlatList works with no issues.

Let me know if you need a repro, I guess you already got FlashList setup/tests on your setups.

Snack or a link to a repository

nope

Reanimated version

3.9.0

React Native version

0.73.7

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS labels Apr 26, 2024
@NigelBreslaw
Copy link

Here is a reproduction https://snack.expo.dev/@nigelbreslaw/ra-flashlist-issue

@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided and removed Missing repro This issue need minimum repro scenario labels Apr 28, 2024
@fadi-quader-mox
Copy link

I can reproduce this issue on 3.9.0 release

@MDG-RHawkins
Copy link

MDG-RHawkins commented Apr 29, 2024

Seeing same issue using:

"react-native": "0.71.15",
"react-native-reanimated": "^3.3.0",
"@shopify/flash-list": "^1.4.3",

However we only noticed the issue at first on Android as it was causing scrolling to not work at all. For iOS the scroll still functioned but the custom animation did not fire. In our case as the animation was only visible in a small number of scenarios it was not picked up in QA initially.

@felixaa
Copy link

felixaa commented Apr 29, 2024

Same issue here. useAnimatedScrollHandler is not firing when using

const AnimatedFlashList = Animated.createAnimatedComponent(FlashList)

@szydlovsky
Copy link
Contributor

Hi everyone! We have identified the issue and can tell where the problem lies - but the potential fix has brought up many more questions than we thought and we are currently discussing what to do. Stay tuned ™️

@szydlovsky szydlovsky linked a pull request Apr 30, 2024 that will close this issue
3 tasks
@szydlovsky
Copy link
Contributor

szydlovsky commented Apr 30, 2024

Hello again - the fix will probably be merged in quite a while since polish May holidays start soon. But do not worry, if you need the fix badly, you can install Reanimated from @szydlovsky/rework-animatedComponent-tags branch.

@ElSeniorMikael
Copy link

@szydlovsky is the version 3.10.0 fixing the problem with useAnimatedScrollhandler not firing ?

@szydlovsky
Copy link
Contributor

@ElSeniorMikael no - the release 3.10.0 had a different purpose: #5963 (comment). The PR with fix will probably be reviewed next week. Until then you can install Reanimated the way I mentioned above.

@emzet93
Copy link

emzet93 commented May 2, 2024

Here is patch created from @szydlovsky PR. Can be used with patch-package:

react-native-reanimated+3.10.0.patch

@quocluongha
Copy link

I also experience this issue in the latest version (3.11.0)

@khayym
Copy link

khayym commented May 7, 2024

I encountered the same issue on version 3.11.0, however, it worked fine on version 3.8.1

@szydlovsky
Copy link
Contributor

szydlovsky commented May 8, 2024

Hey everyone! As the fix got merged it should be available in the next nightly build at around 2AM CEST time - see npm page. It will also be there in the next stable version/patched version.

@efstathiosntonas
Copy link
Contributor Author

efstathiosntonas commented May 9, 2024

hey guys, sorry for being a party pooper but I encountered an issue with the entire screen being detached when displaying an overlay after applying the patch. It's like the entire tree is gone, even the status bar is being hidden on both iOS and Android.

rn 0.73.8, reanimated 3.11.0 with the patch for 3.10.0 mentioned above, gesture-handler 2.16.2

I cannot share the code I'm using since it's rarther complex and it's a private repo. Let me know if we can communicate in another way. It seems that it does not like things being inside a ternary. If i remove the patch everything goes back to normal but ofcourse no scroll events on Flashlist.

The main concept is this:

  const panStyle = useAnimatedStyle<ViewStyle>(() => ({
    transform: [
      {
        translateY: translateY.value
      },
      {
        scale: scale.value
      }
    ]
  }));


  <Overlay>
  {children}
   {overlay === "whatever" ?
     <Animated.View pointerEvents="auto" style={styles.absoluteFill}>
        <Animated.View style={styles.absoluteFill}>
          <View style={styles.flex}>
            <TapGestureHandler
              maxDist={32}
              onHandlerStateChange={({ nativeEvent: { state } }) => {
                if (state === State.END) {
                  setOverlay("none");
                }
              }}
            >
              <Animated.View style={[styles.flex, panStyle]}>
              {some_other_stuff}
              </Animated.View>
  ...all other closing tags
  : null}
  </Overlay>

@szydlovsky
Copy link
Contributor

@efstathiosntonas Hi! Which patch did you use? This one is imperfect and I'd rather suggest latest nightly version - there was some stuff missing in the patch.

@szydlovsky
Copy link
Contributor

Alternatively, there is a "final patch" as well: link

@efstathiosntonas
Copy link
Contributor Author

let me give it a shot. I used the 3.10.0, I missed the 3.11.0 one.

@efstathiosntonas
Copy link
Contributor Author

@szydlovsky after applying patch 3.11.0 life got back to normal 😅. Thank you!

@szydlovsky
Copy link
Contributor

@efstathiosntonas That's a relief 😅

@losh11
Copy link

losh11 commented May 11, 2024

Unfortunately useAnimatedScrollHandler doesn't seem to be firing for me with 3.11.0. I downgraded to 3.8.1 and it works. Would appreicate any assistance getting this to work.

const AnimatedFlashList = Animated.createAnimatedComponent(FlashList);
  const translationY = useSharedValue(0);
  const animatedHeaderStyle = useAnimatedStyle(() => {
    return {
      opacity: interpolate(translationY.value, [0, 100], [1, 0]),
    };
  });

const scrollHandler = useAnimatedScrollHandler(event => {
  translationY.value = event.contentOffset.y;
});

Standard stuff right?

@szydlovsky
Copy link
Contributor

@losh11 Have you even tried reading the discussion above? The fix will be present, perhaps, in 3.12 version. Until then, you can either install latest nightly build or manually install a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.