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
useReanimatedKeyboardAnimation doesn't look smooth like the Reanimated UseAnimatedKeyboard hook in IOS when closing the keyboard #307
Comments
Hello @devoren If you want to have the same behavior as reanimated hook, then you can use something like this: const useAnimatedKeyboard = () => {
const height = useSharedValue(0);
useKeyboardHandler({
onMove: (e) => {
'worklet';
height.value = e.height;
},
}, []);
return { height };
} However it's strange that there is no back animation. In my example app it's present: RNKC-back-transition.mp4The only difference I see in RN version (0.72.4 vs 0.72.7), iOS version (17.2 vs 16.6), device (iPhone 15 Pro simulator vs iPhone 14). The described problem I observed in RN 0.73 🤔 But I haven't figured out what is causing this problem yet |
@kirillzyusko Hey! im sorry, RN version is 0.72.6. Yeah no back animation and height value is jumping from -326 to -0 when closing the keyboard. Android works fine in my case |
@devoren that how it was designed to work. When keyboard appears it will also instantly change the height from When you are using Can you try to clone the repo and run example app? Are you observing the same problem there? What is the |
"react-native-reanimated": "^3.6.1". Okay i will try it today, thank you! |
@kirillzyusko Hello! Sorry for the late feedback. I tried the example but the back animation is still not working. Can you check flatlist example? Chat works but chat flatlist example not. RN 0.72.4v, ios 16.4, iphone 13 Simulator.Screen.Recording.-.iPhone.13.-.2023-12-27.at.22.03.53.online-video-cutter.com.mp4 |
Hm, very interesting @devoren I'll investigate it, but for now I'd suggest you to go with: const useAnimatedKeyboard = () => {
const height = useSharedValue(0);
useKeyboardHandler({
onMove: (e) => {
'worklet';
height.value = e.height;
},
}, []);
return { height };
} Since you are animating |
In production, the "back animation" is better than DEV mode, and also the back animation only doesn't show up if I dismiss the keyboard by pressing the list rather than the keyboard back button. @kirillzyusko thank you ❤️ |
## 📜 Description Schedule layout animations on before keyboard appear/disappear. ## 💡 Motivation and Context Looks like after RN 0.71 the disappear animation happens instantly if user pressed on the `ScrollView`. I don't know what was exactly broken, but I discovered, that if we schedule `LayoutAnimation` with `keyboard` type, then animation happens as it should. So in this PR I decided to schedule layout animations manually and remove them when keyboard finished its movement. Theoretically it's a little bit dangerous to schedule global animations, but: - on iOS they are already kind of getting scheduled; - we remove our animation after keyboard movement completed. So it's kind of relatively safe 🙃 Closes #307 ## 📢 Changelog ### JS - added `reanimated chat flat list` example to Fabric project; ### iOS - added `scheduleKeyboardAnimation`/`unscheduleKeyboardAnimation` methods to `RCTUIManager` (as extension); - added `onRequestAnimation`/`onCancelAnimation` methods to `KeyboardMovementObserver`; - call `onRequestAnimation` on `keyboardWill` events and `onCancelAnimation` on `keyboardDid` events; ## 🤔 How Has This Been Tested? Tested on iPhone 15 Pro (both paper and fabric). ## 📸 Screenshots (if appropriate): |Before|After| |------|------| |<video src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/f1a550e4-bb45-48e6-a4ee-7ef8a0bf1e0f">|<video src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/daafb826-df26-4dce-98af-d2d344f77699">| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
@focux @nandorojo @devoren @jongbelegen looks like you are all experienced this problem. I fixed it in If it doesn't work in your case (for some reasons), please open a new issue 🙏 |
Sounds good. Thank you so much! |
Confirm it got fixed in v1.11.5, thanks! 🙏 |
Describe the bug
Hello! I'm creating a chat app and using fakeView. I'm using useReanimatedKeyboardAnimation but the height value is faster than useAnimatedKeyboard height value in iOS. Also how to add instets bottom? when i use useReanimatedKeyboardAnimation i use it like this:
height: height.value ? Math.abs(height.value) : insets.bottom
but it is not working with useAnimatedKeyboard (jumping)Code snippet
Add your code snippet where error has been occurred.
Repo for reproducing
I would be highly appreciate if you can provide repository for reproducing your issue. It can significantly reduce the time for discovering and fixing the problem.
https://github.com/kirillzyusko/react-native-keyboard-controller/blob/main/example/src/screens/Examples/ReanimatedChatFlatlist/index.tsx
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
The keyboard closes smoothly, as when using the useAnimatedKeyboard hook.
Screenshots
If applicable, add screenshots to help explain your problem.
useReanimatedKeyboardAnimation:
useReanimatedKeyboardAnimation.mp4
useAnimatedKeyboard:
useAnimatedKeyboard.mp4
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: