Skip to content

Configure keyboard view delay #130

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ cordova plugin add cordova-plugin-ionic-keyboard --save

## Preferences

### KeyboardDelayDuration (for IOS Only)

When styling your app like the Login page with (vh). The keyboard open delay might not be desirable. So this option can be used to configure the delay in which the keyboard is open.

> Double (0.2 by default)

```xml
<preference name="KeyboardDelayDuration" value="0.2" />
```

### KeyboardResize (for iOS only)

> Boolean (true by default)
Expand Down
11 changes: 10 additions & 1 deletion src/ios/CDVIonicKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,19 @@ - (void)onKeyboardWillShow:(NSNotification *)note
}
CGRect rect = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
double height = rect.size.height;
double delayedDuration = 0.2;

NSDictionary *settings = self.commandDelegate.settings;
NSString *delayDurationString = [settings cordovaSettingForKey:@"KeyboardDelayDuration"];

if (delayDurationString) {
// convert string into double
delayedDuration = [delayDurationString doubleValue];
}

if (self.isWK) {
double duration = [[note.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[self setKeyboardHeight:height delay:duration+0.2];
[self setKeyboardHeight:height delay:duration+delayedDuration];
[self resetScrollView];
}

Expand Down