diff --git a/ios/Sources/KeyboardPlugin/Keyboard.m b/ios/Sources/KeyboardPlugin/Keyboard.m index 29c0708..5694572 100644 --- a/ios/Sources/KeyboardPlugin/Keyboard.m +++ b/ios/Sources/KeyboardPlugin/Keyboard.m @@ -142,8 +142,34 @@ - (void)onKeyboardWillShow:(NSNotification *)notification } } - double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]+0.2; - [self setKeyboardHeight:height delay:duration]; + // Extract animation curve and convert to CSS timing function string + NSInteger animationCurve = [[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]; + NSString *curveString; + switch (animationCurve) { + case UIViewAnimationCurveEaseInOut: + curveString = @"ease-in-out"; + break; + case UIViewAnimationCurveEaseIn: + curveString = @"ease-in"; + break; + case UIViewAnimationCurveEaseOut: + curveString = @"ease-out"; + break; + case UIViewAnimationCurveLinear: + curveString = @"linear"; + break; + default: + curveString = @"ease-in-out"; + break; + } + + // Set CSS variables on body element + double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; + if (duration > 0) { + [self.bridge evalWithJs: [NSString stringWithFormat:@"(function() { document.body.style.setProperty('--keyboard-animation-duration', '%fs'); document.body.style.setProperty('--keyboard-animation-curve', '%@'); })()", duration, curveString]]; + } + + [self setKeyboardHeight:height delay:0]; [self resetScrollView]; NSString * data = [NSString stringWithFormat:@"{ 'keyboardHeight': %d }", (int)height]; @@ -180,6 +206,7 @@ - (void)setKeyboardHeight:(int)height delay:(NSTimeInterval)delay return; } + [self.bridge evalWithJs: [NSString stringWithFormat:@"(function() { document.body.style.setProperty('--keyboard-height', '%dpx'); })()", height]]; self.paddingBottom = height; __weak KeyboardPlugin* weakSelf = self; @@ -403,4 +430,3 @@ - (void)dealloc @end #pragma clang diagnostic pop -