[LayoutAnimation] RCTAnimationTypeKeyboard
Summary: This adds the Keyboard animation type for when you want to animate UI based on the keyboard appearing/disappearing. Closes https://github.com/facebook/react-native/pull/1366 Github Author: Stanislav Vishnevskiy <vishnevskiy@gmail.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
parent
99bc08cf61
commit
f383bf2b83
|
@ -23,6 +23,7 @@ var TypesEnum = {
|
|||
easeInEaseOut: true,
|
||||
easeIn: true,
|
||||
easeOut: true,
|
||||
keyboard: true,
|
||||
};
|
||||
var Types = keyMirror(TypesEnum);
|
||||
|
||||
|
|
|
@ -997,6 +997,7 @@ RCT_ENUM_CONVERTER(RCTAnimationType, (@{
|
|||
@"easeIn": @(RCTAnimationTypeEaseIn),
|
||||
@"easeOut": @(RCTAnimationTypeEaseOut),
|
||||
@"easeInEaseOut": @(RCTAnimationTypeEaseInEaseOut),
|
||||
@"keyboard": @(RCTAnimationTypeKeyboard),
|
||||
}), RCTAnimationTypeEaseInEaseOut, integerValue)
|
||||
|
||||
@end
|
||||
|
|
|
@ -51,20 +51,23 @@ static NSDictionary *RCTPropsMerge(NSDictionary *beforeProps, NSDictionary *newP
|
|||
|
||||
@implementation RCTAnimation
|
||||
|
||||
static UIViewAnimationCurve UIViewAnimationCurveFromRCTAnimationType(RCTAnimationType type)
|
||||
static UIViewAnimationOptions UIViewAnimationOptionsFromRCTAnimationType(RCTAnimationType type)
|
||||
{
|
||||
switch (type) {
|
||||
case RCTAnimationTypeLinear:
|
||||
return UIViewAnimationCurveLinear;
|
||||
return UIViewAnimationOptionCurveLinear;
|
||||
case RCTAnimationTypeEaseIn:
|
||||
return UIViewAnimationCurveEaseIn;
|
||||
return UIViewAnimationOptionCurveEaseIn;
|
||||
case RCTAnimationTypeEaseOut:
|
||||
return UIViewAnimationCurveEaseOut;
|
||||
return UIViewAnimationOptionCurveEaseOut;
|
||||
case RCTAnimationTypeEaseInEaseOut:
|
||||
return UIViewAnimationCurveEaseInOut;
|
||||
return UIViewAnimationOptionCurveEaseInOut;
|
||||
case RCTAnimationTypeKeyboard:
|
||||
// http://stackoverflow.com/questions/18870447/how-to-use-the-default-ios7-uianimation-curve
|
||||
return (UIViewAnimationOptions)(7 << 16);
|
||||
default:
|
||||
RCTLogError(@"Unsupported animation type %zd", type);
|
||||
return UIViewAnimationCurveEaseInOut;
|
||||
return UIViewAnimationOptionCurveEaseInOut;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +119,7 @@ static UIViewAnimationCurve UIViewAnimationCurveFromRCTAnimationType(RCTAnimatio
|
|||
} else {
|
||||
|
||||
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState |
|
||||
UIViewAnimationCurveFromRCTAnimationType(_animationType);
|
||||
UIViewAnimationOptionsFromRCTAnimationType(_animationType);
|
||||
|
||||
[UIView animateWithDuration:_duration
|
||||
delay:_delay
|
||||
|
|
|
@ -15,4 +15,5 @@ typedef NS_ENUM(NSInteger, RCTAnimationType) {
|
|||
RCTAnimationTypeEaseIn,
|
||||
RCTAnimationTypeEaseOut,
|
||||
RCTAnimationTypeEaseInEaseOut,
|
||||
RCTAnimationTypeKeyboard,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue