@@ -121,30 +121,30 @@ class QueueAnim extends React.Component {
121
121
122
122
// 第一次进入,默认进场
123
123
const children = toArrayChildren ( getChildrenFromProps ( this . props ) ) ;
124
+ const childrenShow = { } ;
124
125
children . forEach ( child => {
125
126
if ( ! child || ! child . key ) {
126
127
return ;
127
128
}
128
- this . keysToEnter . push ( child . key ) ;
129
+ if ( this . props . appear ) {
130
+ this . keysToEnter . push ( child . key ) ;
131
+ } else {
132
+ childrenShow [ child . key ] = true ;
133
+ }
129
134
} ) ;
130
135
131
136
this . originalChildren = toArrayChildren ( getChildrenFromProps ( this . props ) ) ;
132
137
133
138
this . state = {
134
139
children,
135
- childrenShow : { } ,
140
+ childrenShow,
136
141
} ;
137
-
138
- [
139
- 'performEnter' ,
140
- 'performLeave' ,
141
- 'enterBegin' ,
142
- 'leaveComplete' ,
143
- ] . forEach ( ( method ) => this [ method ] = this [ method ] . bind ( this ) ) ;
144
142
}
145
143
146
144
componentDidMount ( ) {
147
- this . componentDidUpdate ( ) ;
145
+ if ( this . props . appear ) {
146
+ this . componentDidUpdate ( ) ;
147
+ }
148
148
}
149
149
150
150
componentWillReceiveProps ( nextProps ) {
@@ -224,18 +224,18 @@ class QueueAnim extends React.Component {
224
224
this . keysAnimating = [ ] ;
225
225
}
226
226
227
- getVelocityConfig ( index , ...args ) {
227
+ getVelocityConfig = ( index , ...args ) => {
228
228
if ( this . props . animConfig ) {
229
229
return transformArguments ( this . props . animConfig , ...args ) [ index ] ;
230
230
}
231
231
return AnimTypes [ transformArguments ( this . props . type , ...args ) [ index ] ] ;
232
232
}
233
233
234
- getVelocityEnterConfig ( ...args ) {
234
+ getVelocityEnterConfig = ( ...args ) => {
235
235
return this . getVelocityConfig ( 0 , ...args ) ;
236
236
}
237
237
238
- getVelocityLeaveConfig ( ...args ) {
238
+ getVelocityLeaveConfig = ( ...args ) => {
239
239
const config = this . getVelocityConfig ( 1 , ...args ) ;
240
240
const ret = { } ;
241
241
Object . keys ( config ) . forEach ( ( key ) => {
@@ -248,7 +248,7 @@ class QueueAnim extends React.Component {
248
248
return ret ;
249
249
}
250
250
251
- getVelocityEasing ( ...args ) {
251
+ getVelocityEasing = ( ...args ) => {
252
252
return transformArguments ( this . props . ease , ...args ) . map ( ( easeName ) => {
253
253
if ( typeof easeName === 'string' ) {
254
254
return BackEase [ easeName ] || easeName ;
@@ -293,7 +293,7 @@ class QueueAnim extends React.Component {
293
293
return data ;
294
294
} ;
295
295
296
- performEnter ( key , i ) {
296
+ performEnter = ( key , i ) => {
297
297
const interval = transformArguments ( this . props . interval , key , i ) [ 0 ] ;
298
298
const delay = transformArguments ( this . props . delay , key , i ) [ 0 ] ;
299
299
this . placeholderTimeoutIds [ key ] = setTimeout (
@@ -305,13 +305,13 @@ class QueueAnim extends React.Component {
305
305
}
306
306
}
307
307
308
- performEnterBegin ( key , i ) {
308
+ performEnterBegin = ( key , i ) => {
309
309
const childrenShow = this . state . childrenShow ;
310
310
childrenShow [ key ] = true ;
311
311
this . setState ( { childrenShow } , this . realPerformEnter . bind ( this , key , i ) ) ;
312
312
}
313
313
314
- realPerformEnter ( key , i ) {
314
+ realPerformEnter = ( key , i ) => {
315
315
const node = findDOMNode ( this . refs [ key ] ) ;
316
316
if ( ! node ) {
317
317
return ;
@@ -332,7 +332,7 @@ class QueueAnim extends React.Component {
332
332
} ) ;
333
333
}
334
334
335
- performLeave ( key , i ) {
335
+ performLeave = ( key , i ) => {
336
336
clearTimeout ( this . placeholderTimeoutIds [ key ] ) ;
337
337
delete this . placeholderTimeoutIds [ key ] ;
338
338
const node = findDOMNode ( this . refs [ key ] ) ;
@@ -355,7 +355,7 @@ class QueueAnim extends React.Component {
355
355
} ) ;
356
356
}
357
357
358
- enterBegin ( key , elements ) {
358
+ enterBegin = ( key , elements ) => {
359
359
elements . forEach ( ( elem ) => {
360
360
const animatingClassName = this . props . animatingClassName ;
361
361
elem . className = elem . className . replace ( animatingClassName [ 1 ] , '' ) ;
@@ -365,7 +365,7 @@ class QueueAnim extends React.Component {
365
365
} ) ;
366
366
}
367
367
368
- enterComplete ( key , elements ) {
368
+ enterComplete = ( key , elements ) => {
369
369
if ( this . keysAnimating . indexOf ( key ) >= 0 ) {
370
370
this . keysAnimating . splice ( this . keysAnimating . indexOf ( key ) , 1 ) ;
371
371
}
@@ -375,7 +375,7 @@ class QueueAnim extends React.Component {
375
375
this . props . onEnd ( { key, type : 'enter' } ) ;
376
376
}
377
377
378
- leaveBegin ( key , elements ) {
378
+ leaveBegin = ( key , elements ) => {
379
379
elements . forEach ( ( elem ) => {
380
380
const animatingClassName = this . props . animatingClassName ;
381
381
elem . className = elem . className . replace ( animatingClassName [ 0 ] , '' ) ;
@@ -385,7 +385,7 @@ class QueueAnim extends React.Component {
385
385
} ) ;
386
386
}
387
387
388
- leaveComplete ( key , elements ) {
388
+ leaveComplete = ( key , elements ) => {
389
389
if ( this . keysAnimating . indexOf ( key ) < 0 ) {
390
390
return ;
391
391
}
@@ -435,31 +435,25 @@ class QueueAnim extends React.Component {
435
435
'animatingClassName' ,
436
436
'enterForcedRePlay' ,
437
437
'onEnd' ,
438
+ 'appear' ,
438
439
] . forEach ( key => delete tagProps [ key ] ) ;
439
440
return createElement ( this . props . component , { ...tagProps } , childrenToRender ) ;
440
441
}
441
442
}
442
443
443
- const numberOrArray = React . PropTypes . oneOfType ( [ React . PropTypes . number , React . PropTypes . array ] ) ;
444
- const stringOrArray = React . PropTypes . oneOfType ( [ React . PropTypes . string , React . PropTypes . array ] ) ;
445
- const objectOrArray = React . PropTypes . oneOfType ( [ React . PropTypes . object , React . PropTypes . array ] ) ;
446
- const funcOrString = React . PropTypes . oneOfType ( [ React . PropTypes . func , React . PropTypes . string ] ) ;
447
- const funcOrStringOrArray = React . PropTypes . oneOfType ( [ React . PropTypes . func , stringOrArray ] ) ;
448
- const funcOrObjectOrArray = React . PropTypes . oneOfType ( [ React . PropTypes . func , objectOrArray ] ) ;
449
- const funcOrNumberOrArray = React . PropTypes . oneOfType ( [ React . PropTypes . func , numberOrArray ] ) ;
450
-
451
444
QueueAnim . propTypes = {
452
- component : funcOrString ,
453
- interval : numberOrArray ,
454
- duration : funcOrNumberOrArray ,
455
- delay : funcOrNumberOrArray ,
456
- type : funcOrStringOrArray ,
457
- animConfig : funcOrObjectOrArray ,
458
- ease : funcOrStringOrArray ,
445
+ component : React . PropTypes . any ,
446
+ interval : React . PropTypes . any ,
447
+ duration : React . PropTypes . any ,
448
+ delay : React . PropTypes . any ,
449
+ type : React . PropTypes . any ,
450
+ animConfig : React . PropTypes . any ,
451
+ ease : React . PropTypes . any ,
459
452
leaveReverse : React . PropTypes . bool ,
460
453
enterForcedRePlay : React . PropTypes . bool ,
461
454
animatingClassName : React . PropTypes . array ,
462
455
onEnd : React . PropTypes . func ,
456
+ appear : React . PropTypes . bool ,
463
457
} ;
464
458
465
459
QueueAnim . defaultProps = {
@@ -474,6 +468,7 @@ QueueAnim.defaultProps = {
474
468
enterForcedRePlay : false ,
475
469
animatingClassName : [ 'queue-anim-entering' , 'queue-anim-leaving' ] ,
476
470
onEnd : noop ,
471
+ appear : true ,
477
472
} ;
478
473
479
474
export default QueueAnim ;
0 commit comments