react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

How do we attach onScroll to an animated event?

Open saransh-malik opened this issue 2 years ago • 3 comments

I want to animate my header while the list inside the bottom panle is being scrolled. With the earlier library I was simply attaching the onScroll event of the panel to the AnimatedEvent, but with this library on v4 when I try to do that I get an error of runOnJS, saying attempt to call runOnJs with an object that is not a host function.

Is there some other way to achieve, I couldn't really find anything about this, so if anyone can help me out.

This is what I want to do onScroll, basically capture the scrollY position and use that to update my variable which in turn animates my header.

onScroll = Animated.event([
    {
      nativeEvent: {
        contentOffset: {
          y: this.scrollPosition,
        },
      },
    },
  ])

saransh-malik avatar Sep 01 '22 08:09 saransh-malik

@saransh-malik: hello! :wave:

This issue is being automatically closed because it does not follow the issue template.

github-actions[bot] avatar Sep 01 '22 08:09 github-actions[bot]

I think this is because of runOnJS here https://github.com/gorhom/react-native-bottom-sheet/blob/cebae97c56f0b2ff31c247b1fce5cbe8172b6554/src/hooks/useScrollHandler.ts#L39

enagorny avatar Sep 02 '22 15:09 enagorny

Here is a little explanation: https://github.com/gorhom/react-native-bottom-sheet/pull/952#issuecomment-1161614075

davidnum avatar Sep 04 '22 22:09 davidnum

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 05 '22 09:10 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Oct 10 '22 09:10 github-actions[bot]