Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 📜 Description A follow up PR for #412 - follow keyboard frame-in-frame if keyboard animation is **not** spring animation. ## 💡 Motivation and Context On iOS keyboard animation can be not only spring animation. It can be also `CABasicAnimation` (when keyboard goes up after interactive dismissal, for example). Before we were relying on `CADisplayLink` and coordinates pooling, but such approach doesn't give a good precision. Even after implementing custom `SpringAnimation` we still relied on this approach (we used this approach as a fallback if the animation is not `CASpringAnimation`). In this PR I implemented custom `TimingAnimation` class and if the animation is `CABasicAnimation` then we also can assure frame precision. All these math calculations were based on this [Desmos playground](https://www.desmos.com/calculator/eynenh1aga?lang=en) - I used concrete params of a particular animation config and concrete values produced by iOS. And then I wrote a code 🙃 > _As you can see some of points are not perfectly aligned to the curve - I think a similar behavior I also observed with `SpringAnimation` and later on I'll improve that as well_ For finding `t` for particular `x` (or `y`) I used [Newton-Raphson](https://en.wikipedia.org/wiki/Newton%27s_method) method. It has better convergence than a binary search and typically I can find a value with given precision within 6 iterations. Last but not least - the animation (`CABaicAnimation`) is not available straight in `keyboardWillShow` callback (it's `nil` there) and it's available only in `CADisplayLink` callback (so I added an attempt of animation initialization there as well). ## 📢 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 --> ### iOS - added `TimingAnimation` class; - use `TimingAnimation` in `KeyboardMovementObserver`. ## 🤔 How Has This Been Tested? Tested manually on: - iPhone 6s (iOS 15.8) - iPhone 11 (iOS 17.4); - iPhone 14 Pro (iOS 17.4); - iPhone 15 Pro (iOS 17.5, simulator); ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<video src="https://github.com/user-attachments/assets/1c1bba40-c76e-468f-87aa-7e9105715ab7">|<video src="https://github.com/user-attachments/assets/55de0c4d-9d0a-4775-a4dd-4983acc30283">| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
- Loading branch information