Skip to content
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

fix(keyboard): Remove iOS keyboard delay (#1904) #2233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions keyboard/ios/Sources/KeyboardPlugin/Keyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (void)resetScrollView

- (void)onKeyboardWillHide:(NSNotification *)notification
{
[self setKeyboardHeight:0 delay:0.01];
[self setKeyboardHeight:0 delay:0];
[self resetScrollView];
hideTimer = [NSTimer scheduledTimerWithTimeInterval:0 repeats:NO block:^(NSTimer * _Nonnull timer) {
[self.bridge triggerWindowJSEventWithEventName:@"keyboardWillHide"];
Expand Down Expand Up @@ -142,8 +142,7 @@ - (void)onKeyboardWillShow:(NSNotification *)notification
}
}

double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]+0.2;
[self setKeyboardHeight:height delay:duration];
[self setKeyboardHeight:height delay:0];
[self resetScrollView];

NSString * data = [NSString stringWithFormat:@"{ 'keyboardHeight': %d }", (int)height];
Expand Down Expand Up @@ -199,7 +198,7 @@ - (void)resizeElement:(NSString *)element withPaddingBottom:(int)paddingBottom w
height = screenHeight - paddingBottom;
}

[self.bridge evalWithJs: [NSString stringWithFormat:@"(function() { var el = %@; var height = %d; if (el) { el.style.height = height > -1 ? height + 'px' : null; } })()", element, height]];
[self.bridge evalWithJs: [NSString stringWithFormat:@"requestAnimationFrame(() => { var el = %@; var height = %d; if (el) { el.style.height = height > -1 ? height + 'px' : null; } })", element, height]];
}

- (void)_updateFrame
Expand Down
Loading