Changed LayoutAnimation to use ms instead of seconds for consistency

This commit is contained in:
Nick Lockwood 2015-03-30 07:12:38 -07:00
parent 57d0a5a628
commit a2cfc5feca
3 changed files with 24 additions and 14 deletions

View File

@ -226,9 +226,9 @@ var styles = StyleSheet.create({
var animations = {
layout: {
spring: {
duration: 0.75,
duration: 750,
create: {
duration: 0.3,
duration: 300,
type: LayoutAnimation.Types.easeInEaseOut,
property: LayoutAnimation.Properties.opacity,
},
@ -238,13 +238,13 @@ var animations = {
},
},
easeInEaseOut: {
duration: 0.3,
duration: 300,
create: {
type: LayoutAnimation.Types.easeInEaseOut,
property: LayoutAnimation.Properties.scaleXY,
},
update: {
delay: 0.1,
delay: 100,
type: LayoutAnimation.Types.easeInEaseOut,
},
},

View File

@ -92,13 +92,13 @@ var LayoutAnimation = {
configChecker: configChecker,
Presets: {
easeInEaseOut: create(
0.3, Types.easeInEaseOut, Properties.opacity
300, Types.easeInEaseOut, Properties.opacity
),
linear: create(
0.5, Types.linear, Properties.opacity
500, Types.linear, Properties.opacity
),
spring: {
duration: 0.7,
duration: 700,
create: {
type: Types.linear,
property: Properties.opacity,

View File

@ -80,10 +80,18 @@ static UIViewAnimationCurve UIViewAnimationCurveFromRCTAnimationType(RCTAnimatio
if ((self = [super init])) {
_property = [RCTConvert NSString:config[@"property"]];
// TODO: this should be provided in ms, not seconds
// (this will require changing all call sites to ms as well)
_duration = [RCTConvert NSTimeInterval:config[@"duration"]] * 1000.0 ?: duration;
_delay = [RCTConvert NSTimeInterval:config[@"delay"]] * 1000.0;
_duration = [RCTConvert NSTimeInterval:config[@"duration"]] ?: duration;
if (_duration > 0.0 && _duration < 0.01) {
RCTLogError(@"RCTLayoutAnimation expects timings to be in ms, not seconds.");
_duration = _duration * 1000.0;
}
_delay = [RCTConvert NSTimeInterval:config[@"delay"]];
if (_delay > 0.0 && _delay < 0.01) {
RCTLogError(@"RCTLayoutAnimation expects timings to be in ms, not seconds.");
_delay = _delay * 1000.0;
}
_animationType = [RCTConvert RCTAnimationType:config[@"type"]];
if (_animationType == RCTAnimationTypeSpring) {
_springDamping = [RCTConvert CGFloat:config[@"springDamping"]];
@ -142,9 +150,11 @@ static UIViewAnimationCurve UIViewAnimationCurveFromRCTAnimationType(RCTAnimatio
if ((self = [super init])) {
// TODO: this should be provided in ms, not seconds
// (this will require changing all call sites to ms as well)
NSTimeInterval duration = [RCTConvert NSTimeInterval:config[@"duration"]] * 1000.0;
NSTimeInterval duration = [RCTConvert NSTimeInterval:config[@"duration"]];
if (duration > 0.0 && duration < 0.01) {
RCTLogError(@"RCTLayoutAnimation expects timings to be in ms, not seconds.");
duration = duration * 1000.0;
}
_createAnimation = [[RCTAnimation alloc] initWithDuration:duration dictionary:config[@"create"]];
_updateAnimation = [[RCTAnimation alloc] initWithDuration:duration dictionary:config[@"update"]];