Skip to content

Commit

Permalink
chore: always animate keyboard height change if possible on iOS
Browse files Browse the repository at this point in the history
If the keyboard event has non-zero duration, animate the change to the
target height. Prevents jumping to the target height when opening the
floating keyboard.
  • Loading branch information
mhoran committed Jan 9, 2025
1 parent 09562c6 commit 9bf43f3
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ - (void)keyboardWillChangeFrame:(NSNotification *)notification
_targetKeyboardHeight =
CGRectIsEmpty(endFrameIntersection) ? 0 : CGRectGetMaxY(window.bounds) - CGRectGetMinY(endFrameIntersection);

bool forceAnimation = false;
auto keyboardView = [self getKeyboardView];
if (_state == CLOSING) {
_targetKeyboardHeight = 0;
Expand All @@ -219,12 +218,10 @@ - (void)keyboardWillChangeFrame:(NSNotification *)notification
_initialKeyboardHeight = CGRectIsEmpty(beginFrameIntersection)
? 0
: CGRectGetMaxY(window.bounds) - CGRectGetMinY(beginFrameIntersection);
forceAnimation = true;
}
_isInteractiveDismissalCanceled = false;

bool hasKeyboardAnimation = [self hasAnyAnimation:keyboardView];
if (hasKeyboardAnimation || forceAnimation) {
if (animationDuration > 0) {
_measuringView.frame = CGRectMake(0, -1, 0, _initialKeyboardHeight);
[UIView animateWithDuration:animationDuration
animations:^{
Expand Down

0 comments on commit 9bf43f3

Please sign in to comment.