Skip to content

Commit

Permalink
Changed LayoutAnimation to use ms instead of seconds for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Mar 30, 2015
1 parent 6885c74 commit c129e2b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Examples/UIExplorer/ListViewPagingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
},
},
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Animation/LayoutAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 17 additions & 7 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,18 @@ - (instancetype)initWithDuration:(NSTimeInterval)duration dictionary:(NSDictiona
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"]];
Expand Down Expand Up @@ -142,9 +150,11 @@ - (instancetype)initWithDictionary:(NSDictionary *)config callback:(RCTResponseS

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"]];
Expand Down

0 comments on commit c129e2b

Please sign in to comment.