kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.59k stars 64 forks source link

fix: fire `onScroll` from props in `KeyboardAwareScrollView` #339

Closed kirillzyusko closed 8 months ago

kirillzyusko commented 8 months ago

📜 Description

Fire onScroll from props in KeyboardAwareScrollView.

💡 Motivation and Context

Initially I wanted to achieve that as runOnJS(props.onScroll)({ nativeEvent: e }). But in this case I'm getting:

Argument of type '{ nativeEvent: ReanimatedScrollEvent; }' is not assignable to parameter of type 'NativeSyntheticEvent<NativeScrollEvent>'.
  Type '{ nativeEvent: ReanimatedScrollEvent; }' is missing the following properties from type 'NativeSyntheticEvent<NativeScrollEvent>': currentTarget, target, bubbles, cancelable, and 10 more.ts(2345)

And it's really incorrect, because several properties will be missing and js-based handler (not based on Animated.event) may not read expected properties (such as target etc.).

So I wanted to pass onScroll handler from reanimated as onScrollReanimated property. In this case onScroll will be passed from rest props and will be fired correctly.

Closes https://github.com/kirillzyusko/react-native-keyboard-controller/issues/337

📢 Changelog

JS

🤔 How Has This Been Tested?

Tested manually on iPhone 15 Pro.

📝 Checklist

github-actions[bot] commented 8 months ago

📊 Package size report

Current size Target Size Difference
113250 bytes 113786 bytes -536 bytes 📉