@@ -25,8 +25,7 @@ class QueueAnim extends React.Component {
25
25
this . keysToEnter = [ ] ;
26
26
this . keysToLeave = [ ] ;
27
27
this . keysAnimating = [ ] ;
28
-
29
- this . placeholder = { } ;
28
+ this . placeholderTimeoutIds = { } ;
30
29
31
30
// 第一次进入,默认进场
32
31
const children = toArrayChildren ( getChildrenFromProps ( this . props ) ) ;
@@ -114,6 +113,9 @@ class QueueAnim extends React.Component {
114
113
velocity ( findDOMNode ( this . refs [ child . key ] ) , 'stop' ) ;
115
114
}
116
115
} ) ;
116
+ Object . keys ( this . placeholderTimeoutIds ) . forEach ( key => {
117
+ clearTimeout ( this . placeholderTimeoutIds [ key ] ) ;
118
+ } ) ;
117
119
}
118
120
}
119
121
@@ -150,21 +152,12 @@ class QueueAnim extends React.Component {
150
152
}
151
153
152
154
performEnter ( key , i ) {
153
- /*
154
- const placeholderNode = this.placeholder[key] || document.createElement('div');//findDOMNode(this.refs[placeholderKeyPrefix + key]);
155
- this.placeholder[key] = placeholderNode*/
156
-
157
155
const interval = transformArguments ( this . props . interval , key , i ) [ 0 ] ;
158
156
const delay = transformArguments ( this . props . delay , key , i ) [ 0 ] ;
159
- /*
160
- placeholderNode.style.visibility = 'hidden';
161
- velocity(placeholderNode, 'stop');
162
- velocity(placeholderNode, {opacity: [0, 0]}, {
163
- delay: interval * i + delay,
164
- duration: 0,
165
- begin: this.performEnterBegin.bind(this, key, i),
166
- });*/
167
- this . placeholder [ key ] = setTimeout ( this . performEnterBegin . bind ( this , key , i ) , interval * i + delay ) ;
157
+ this . placeholderTimeoutIds [ key ] = setTimeout (
158
+ this . performEnterBegin . bind ( this , key , i ) ,
159
+ interval * i + delay
160
+ ) ;
168
161
if ( this . keysToEnter . indexOf ( key ) >= 0 ) {
169
162
this . keysToEnter . splice ( this . keysToEnter . indexOf ( key ) , 1 ) ;
170
163
}
@@ -173,9 +166,7 @@ class QueueAnim extends React.Component {
173
166
performEnterBegin ( key , i ) {
174
167
const childrenShow = this . state . childrenShow ;
175
168
childrenShow [ key ] = true ;
176
- if ( this . _reactInternalInstance ) {
177
- this . setState ( { childrenShow} , this . realPerformEnter . bind ( this , key , i ) ) ;
178
- }
169
+ this . setState ( { childrenShow} , this . realPerformEnter . bind ( this , key , i ) ) ;
179
170
}
180
171
181
172
realPerformEnter ( key , i ) {
@@ -186,7 +177,6 @@ class QueueAnim extends React.Component {
186
177
const duration = transformArguments ( this . props . duration , key , i ) [ 0 ] ;
187
178
node . style . visibility = 'hidden' ;
188
179
velocity ( node , 'stop' ) ;
189
- console . log ( 'enter' , key ) ;
190
180
velocity ( node , this . getVelocityEnterConfig ( key , i ) , {
191
181
duration : duration ,
192
182
easing : this . getVelocityEasing ( key , i ) [ 0 ] ,
@@ -197,12 +187,9 @@ class QueueAnim extends React.Component {
197
187
}
198
188
199
189
performLeave ( key , i ) {
190
+ clearTimeout ( this . placeholderTimeoutIds [ key ] ) ;
191
+ delete this . placeholderTimeoutIds [ key ] ;
200
192
const node = findDOMNode ( this . refs [ key ] ) ;
201
- // console.log('stop', key);
202
- /*
203
- velocity(this.placeholder[key], 'stop');
204
- */
205
- clearTimeout ( this . placeholder [ key ] ) ;
206
193
if ( ! node ) {
207
194
return ;
208
195
}
@@ -211,7 +198,6 @@ class QueueAnim extends React.Component {
211
198
const duration = transformArguments ( this . props . duration , key , i ) [ 1 ] ;
212
199
const order = this . props . leaveReverse ? ( this . keysToLeave . length - i - 1 ) : i ;
213
200
velocity ( node , 'stop' ) ;
214
- // console.log('leave', key);
215
201
velocity ( node , this . getVelocityLeaveConfig ( key , i ) , {
216
202
delay : interval * order + delay ,
217
203
duration : duration ,
@@ -252,13 +238,8 @@ class QueueAnim extends React.Component {
252
238
if ( this . keysToLeave . indexOf ( key ) >= 0 ) {
253
239
this . keysToLeave . splice ( this . keysToLeave . indexOf ( key ) , 1 ) ;
254
240
}
255
- let leaveEnd ;
256
- this . keysToLeave . forEach ( ( c ) => {
257
- if ( childrenShow [ c ] ) {
258
- leaveEnd = true ;
259
- }
260
- } ) ;
261
- if ( ! leaveEnd ) {
241
+ const needLeave = this . keysToLeave . some ( c => childrenShow [ c ] ) ;
242
+ if ( ! needLeave ) {
262
243
const currentChildren = toArrayChildren ( getChildrenFromProps ( this . props ) ) ;
263
244
this . setState ( {
264
245
children : currentChildren ,
0 commit comments