Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f383bf2

Browse files
committed
[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 <[email protected]> Test Plan: Imported from GitHub, without a `Test Plan:` line.
1 parent 99bc08c commit f383bf2

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

Libraries/Animation/LayoutAnimation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var TypesEnum = {
2323
easeInEaseOut: true,
2424
easeIn: true,
2525
easeOut: true,
26+
keyboard: true,
2627
};
2728
var Types = keyMirror(TypesEnum);
2829

React/Base/RCTConvert.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ + (NSPropertyList)NSPropertyList:(id)json
997997
@"easeIn": @(RCTAnimationTypeEaseIn),
998998
@"easeOut": @(RCTAnimationTypeEaseOut),
999999
@"easeInEaseOut": @(RCTAnimationTypeEaseInEaseOut),
1000+
@"keyboard": @(RCTAnimationTypeKeyboard),
10001001
}), RCTAnimationTypeEaseInEaseOut, integerValue)
10011002

10021003
@end

React/Modules/RCTUIManager.m

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,23 @@ @interface RCTAnimation : NSObject
5151

5252
@implementation RCTAnimation
5353

54-
static UIViewAnimationCurve UIViewAnimationCurveFromRCTAnimationType(RCTAnimationType type)
54+
static UIViewAnimationOptions UIViewAnimationOptionsFromRCTAnimationType(RCTAnimationType type)
5555
{
5656
switch (type) {
5757
case RCTAnimationTypeLinear:
58-
return UIViewAnimationCurveLinear;
58+
return UIViewAnimationOptionCurveLinear;
5959
case RCTAnimationTypeEaseIn:
60-
return UIViewAnimationCurveEaseIn;
60+
return UIViewAnimationOptionCurveEaseIn;
6161
case RCTAnimationTypeEaseOut:
62-
return UIViewAnimationCurveEaseOut;
62+
return UIViewAnimationOptionCurveEaseOut;
6363
case RCTAnimationTypeEaseInEaseOut:
64-
return UIViewAnimationCurveEaseInOut;
64+
return UIViewAnimationOptionCurveEaseInOut;
65+
case RCTAnimationTypeKeyboard:
66+
// http://stackoverflow.com/questions/18870447/how-to-use-the-default-ios7-uianimation-curve
67+
return (UIViewAnimationOptions)(7 << 16);
6568
default:
6669
RCTLogError(@"Unsupported animation type %zd", type);
67-
return UIViewAnimationCurveEaseInOut;
70+
return UIViewAnimationOptionCurveEaseInOut;
6871
}
6972
}
7073

@@ -116,7 +119,7 @@ - (void)performAnimations:(void (^)(void))animations
116119
} else {
117120

118121
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState |
119-
UIViewAnimationCurveFromRCTAnimationType(_animationType);
122+
UIViewAnimationOptionsFromRCTAnimationType(_animationType);
120123

121124
[UIView animateWithDuration:_duration
122125
delay:_delay

React/Views/RCTAnimationType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ typedef NS_ENUM(NSInteger, RCTAnimationType) {
1515
RCTAnimationTypeEaseIn,
1616
RCTAnimationTypeEaseOut,
1717
RCTAnimationTypeEaseInEaseOut,
18+
RCTAnimationTypeKeyboard,
1819
};

0 commit comments

Comments
 (0)