From a2cfc5feca7c35ddef87e65d77c946bb01608846 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Mon, 30 Mar 2015 07:12:38 -0700 Subject: [PATCH] Changed LayoutAnimation to use ms instead of seconds for consistency --- Examples/UIExplorer/ListViewPagingExample.js | 8 +++---- Libraries/Animation/LayoutAnimation.js | 6 ++--- React/Modules/RCTUIManager.m | 24 ++++++++++++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Examples/UIExplorer/ListViewPagingExample.js b/Examples/UIExplorer/ListViewPagingExample.js index 2d26868e4..36cc82d86 100644 --- a/Examples/UIExplorer/ListViewPagingExample.js +++ b/Examples/UIExplorer/ListViewPagingExample.js @@ -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, }, }, diff --git a/Libraries/Animation/LayoutAnimation.js b/Libraries/Animation/LayoutAnimation.js index b68656984..12128055c 100644 --- a/Libraries/Animation/LayoutAnimation.js +++ b/Libraries/Animation/LayoutAnimation.js @@ -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, diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index a0e7285c6..6ac370a49 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -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"]];