Permalink
Browse files

[LayoutAnimation] RCTAnimationTypeKeyboard

Summary:
This adds the Keyboard animation type for when you want to animate UI based on the keyboard appearing/disappearing.
Closes facebook#1366
Github Author: Stanislav Vishnevskiy <vishnevskiy@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
  • Loading branch information...
vishnevskiy committed Jun 25, 2015
1 parent 99bc08c commit f383bf2b83c42cca96df5704c3b6c5ceba7fbb54
@@ -23,6 +23,7 @@ var TypesEnum = {
easeInEaseOut: true,
easeIn: true,
easeOut: true,
keyboard: true,
};
var Types = keyMirror(TypesEnum);
View
@@ -997,6 +997,7 @@ + (NSPropertyList)NSPropertyList:(id)json
@"easeIn": @(RCTAnimationTypeEaseIn),
@"easeOut": @(RCTAnimationTypeEaseOut),
@"easeInEaseOut": @(RCTAnimationTypeEaseInEaseOut),
@"keyboard": @(RCTAnimationTypeKeyboard),
}), RCTAnimationTypeEaseInEaseOut, integerValue)
@end
@@ -51,20 +51,23 @@ @interface RCTAnimation : NSObject
@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 @@ - (void)performAnimations:(void (^)(void))animations
} 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,
};

0 comments on commit f383bf2

Please sign in to comment.