-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Suggestion for Improvement:
Hi, I noticed that when the keyboard appears, the view shift has a noticeable delay. The current implementation uses delay(for: .milliseconds(200), scheduler: DispatchQueue.main), but a fixed 200ms delay is unreliable for the following reasons:
Keyboard animation duration is not fixed – The actual animation time varies across iOS versions, devices, and user settings (e.g., "Reduce Motion"). Using a hardcoded 200ms delay may cause desynchronization, leading to lag or visual inconsistencies.
Asynchronous execution may fluctuate – Since DispatchQueue.main might have other tasks running, the actual delay could be longer than expected due to main thread load, further impacting responsiveness.
Not in sync with keyboard events – iOS provides keyboardWillShowNotification and keyboardDidShowNotification, which include the actual animation duration and curve in userInfo[UIKeyboardAnimationDurationUserInfoKey]. Using these ensures smooth and synchronized UI updates rather than relying on an arbitrary delay.
I suggest listening to keyboardWillShowNotification and using the provided animation duration instead. This will help achieve a more consistent and fluid user experience.
Looking forward to your thoughts! Thanks for your great work on this library.