Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 📜 Description Fixed choppy animation for `KeyboardAvoidingView` if child `TextInputs` are using `secureTextEntry` property. ## 💡 Motivation and Context The problem which causes jumpy behavior is hidden in fact, that 2 `keyboardWillShow` + `keyboardWillHide` events are emitted instead of a single one. If we add logger we'll see: ```bash onStart height 291 onEnd height 291 onStart height 336 ... // onMove onEnd height 336 ``` And such events are very similar to what happens on Android when keyboard gets resized. So basically fix consist from two parts. ### Part 1️⃣ In `useKeyboardInterpolation` we are not using Android specific interpolation and are using "progress"-based animation (interpolation between current keyboard frame and final keyboard frame). It allows us to have positive value and make animation smooth. However is some cases we may see a jump occurring for one frame, and for that we apply second fix. ### Part 2️⃣ In second part we are handling "unnecessary" `onEnd` event. Before we were simply updating `height`/`progress` values in `onEnd` handler - it was needed to handle cases when `onMove` handler is not called but we still need to synchronize the state. In this PR I slightly re-worked approach and now I'm updating it only if `duration === 0` (i. e. transition was instant). Closes #327 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - use "progress"-based interpolation for iOS in `useKeyboardInterpolation`; - update values in `onEnd` only if `duration` is `0`. ## 🤔 How Has This Been Tested? Tested on iPhone 15 Pro. ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<video src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/b75f7ca4-fa84-448d-92f8-517b5886b84e">|<video src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/fe3b5cf0-8a61-4af6-ac75-ae3ce64cca72">| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
- Loading branch information