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
onScroll
on KeyboardAwareScrollView
is not fired
#337
Comments
This is not fixed. onScroll does NOT fire from KeyboardAwareScrollView. @kirillzyusko please reopen this. I even pulled in 1.10.3 which was the version that supposedly fixed this issue to make sure it was not just a regression. It remains broken on that version, too. |
@z1haze thanks for bringing it up 👀 May I kindly ask you to test #408 and see whether it fixes the problem or not? I believe it should fix because I just tested example app and had the same issue as you - and this PR resovles the problem. But I'm more than sure that previous approach was working - most likely with a new release of RN or REA it's not working now, but again it was working before 👀 😅 . |
Hey @kirillzyusko. Checking your solution, would it not be more effective to use a normal scroll callback? const onScroll = useCallback((event:NativeSyntheticEvent<NativeScrollEvent>) => {
position.value = event.nativeEvent.contentOffset.y;
onScroll2?.(event);
}, [onScroll2]); Is there an underlying purpose for using the reanimated hook for the callback? Edit: |
Yeah, it will update the value on UI thread synchronously. In your case it'll be updated on JS thread and it will not be as efficient as updating on UI thread. Potentially it's possible to use your solution (I am reading scroll shared value only when keyboard movement happens - that value is not driving any animation, so it's okay to miss some frames during update), but of course I need to check that there is no performance hits 😅 |
That makes sense. I originally tried the Aside from that, if the regular callback works, it seems less "hacky" to do that since you can pass the entire event rather than just the nativeEvent properties. |
Yeah, for sure 👍 I changed a code in my PR - would you mind to test it and confirm whether it fixes the problem in your project? 👀 |
I've been using the JS implementation since this morning. Everything seems to be fine. My only concern was that it would mess with something since it is not longer using Reanimated's hook. I also wasn't sure what was going on with that mystery |
@DaltonPelkey
I think it shouldn't. And you are right - this implementation looks less hacky so let's try this 👀 I'll merge PR tomorrow 👍 |
@kirillzyusko we could not find anywhere that prop was being used. Could you shed some light on that? |
@z1haze the ScrollView was coming from Reanimated. So output from But yes, it's kind of hack and it will produce TS issues anyway, so better not use it 👀 |
## 📜 Description Fixed firing of `onScroll` in `KeyboardAwareScrollView` ## 💡 Motivation and Context Initially it was fixed in #339 and I'm sure it was working 😅 However it looks like in current setup (RN 0.73, REA 3.8.0) such way is not working and `onScroll` property still gets ignored 😔 So in this PR I followed a different path: initially I wanted to fire this handler via `runOnJS`, but we can not follow a full signature of the method, since REA has only `nativeEvent` property (and indeed in this case some properties would be simply missing). The different path was to update a shared value from JS thread and call a callback as usually - it fixes a problem in old code and in a new, so for now this approach looks decent 👍 Let's see how it works in a wild life 👀 Also in this PR I'm changing content of `tea.yaml` - it should be done in separate PR, but I don't want to open another PR just to fix quotes, so decided to merge everything in a single one 🙈 Closes #337 ## 📢 Changelog ### JS - fire `onScroll` in callback; - react on scroll position change in JS thread. ### FS (file system) - added single quotes `'` for `tea.yaml`; ## 🤔 How Has This Been Tested? Tested manually on iPhone 15 Pro. ## 📸 Screenshots (if appropriate): <img width="474" alt="image" src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/11896adc-3fdd-4ab3-acf9-9f32f27e787c"> ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
Published under |
Describe the bug
onScroll
onKeyboardAwareScrollView
is not firedCode snippet
Just add
onScroll={console.log}
in example app.Repo for reproducing
You can use example app.
To Reproduce
Steps to reproduce the behavior:
KeyboardAwareScrollView
Expected behavior
You should see events if you scroll
ScrollView
.Smartphone (please complete the following information):
Additional context
It can be fixed by adding next code into
onScroll
handler:or assign our
onScroll
handler asonScrollReanimated
(REA intercept all events for a given view, so there is no difference which prop to use).The text was updated successfully, but these errors were encountered: