Skip to content

Commit a2cfc5f

Browse files
committed
Changed LayoutAnimation to use ms instead of seconds for consistency
1 parent 57d0a5a commit a2cfc5f

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

Examples/UIExplorer/ListViewPagingExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ var styles = StyleSheet.create({
226226
var animations = {
227227
layout: {
228228
spring: {
229-
duration: 0.75,
229+
duration: 750,
230230
create: {
231-
duration: 0.3,
231+
duration: 300,
232232
type: LayoutAnimation.Types.easeInEaseOut,
233233
property: LayoutAnimation.Properties.opacity,
234234
},
@@ -238,13 +238,13 @@ var animations = {
238238
},
239239
},
240240
easeInEaseOut: {
241-
duration: 0.3,
241+
duration: 300,
242242
create: {
243243
type: LayoutAnimation.Types.easeInEaseOut,
244244
property: LayoutAnimation.Properties.scaleXY,
245245
},
246246
update: {
247-
delay: 0.1,
247+
delay: 100,
248248
type: LayoutAnimation.Types.easeInEaseOut,
249249
},
250250
},

Libraries/Animation/LayoutAnimation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ var LayoutAnimation = {
9292
configChecker: configChecker,
9393
Presets: {
9494
easeInEaseOut: create(
95-
0.3, Types.easeInEaseOut, Properties.opacity
95+
300, Types.easeInEaseOut, Properties.opacity
9696
),
9797
linear: create(
98-
0.5, Types.linear, Properties.opacity
98+
500, Types.linear, Properties.opacity
9999
),
100100
spring: {
101-
duration: 0.7,
101+
duration: 700,
102102
create: {
103103
type: Types.linear,
104104
property: Properties.opacity,

React/Modules/RCTUIManager.m

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,18 @@ - (instancetype)initWithDuration:(NSTimeInterval)duration dictionary:(NSDictiona
8080
if ((self = [super init])) {
8181
_property = [RCTConvert NSString:config[@"property"]];
8282

83-
// TODO: this should be provided in ms, not seconds
84-
// (this will require changing all call sites to ms as well)
85-
_duration = [RCTConvert NSTimeInterval:config[@"duration"]] * 1000.0 ?: duration;
86-
_delay = [RCTConvert NSTimeInterval:config[@"delay"]] * 1000.0;
83+
_duration = [RCTConvert NSTimeInterval:config[@"duration"]] ?: duration;
84+
if (_duration > 0.0 && _duration < 0.01) {
85+
RCTLogError(@"RCTLayoutAnimation expects timings to be in ms, not seconds.");
86+
_duration = _duration * 1000.0;
87+
}
88+
89+
_delay = [RCTConvert NSTimeInterval:config[@"delay"]];
90+
if (_delay > 0.0 && _delay < 0.01) {
91+
RCTLogError(@"RCTLayoutAnimation expects timings to be in ms, not seconds.");
92+
_delay = _delay * 1000.0;
93+
}
94+
8795
_animationType = [RCTConvert RCTAnimationType:config[@"type"]];
8896
if (_animationType == RCTAnimationTypeSpring) {
8997
_springDamping = [RCTConvert CGFloat:config[@"springDamping"]];
@@ -142,9 +150,11 @@ - (instancetype)initWithDictionary:(NSDictionary *)config callback:(RCTResponseS
142150

143151
if ((self = [super init])) {
144152

145-
// TODO: this should be provided in ms, not seconds
146-
// (this will require changing all call sites to ms as well)
147-
NSTimeInterval duration = [RCTConvert NSTimeInterval:config[@"duration"]] * 1000.0;
153+
NSTimeInterval duration = [RCTConvert NSTimeInterval:config[@"duration"]];
154+
if (duration > 0.0 && duration < 0.01) {
155+
RCTLogError(@"RCTLayoutAnimation expects timings to be in ms, not seconds.");
156+
duration = duration * 1000.0;
157+
}
148158

149159
_createAnimation = [[RCTAnimation alloc] initWithDuration:duration dictionary:config[@"create"]];
150160
_updateAnimation = [[RCTAnimation alloc] initWithDuration:duration dictionary:config[@"update"]];

0 commit comments

Comments
 (0)