File tree Expand file tree Collapse file tree 2 files changed +36
-9
lines changed Expand file tree Collapse file tree 2 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ class QueueAnim extends React.Component {
160
160
// 在出场没结束时,childrenShow 里的值将不会清除。再触发进场时, childrenShow 里的值是保留着的, 设置了 enterForcedRePlay 将重新播放进场。
161
161
newChildren . forEach ( item => {
162
162
if ( this . keysToLeave . indexOf ( item . key ) >= 0 ) {
163
- const node = this . refs [ item . key ] ;
163
+ const node = findDOMNode ( this . refs [ item . key ] ) ;
164
164
// 因为进场是用的间隔性进入,这里不做 stop 处理将会在这间隔里继续出场的动画。。
165
165
velocity ( node , 'stop' ) ;
166
166
delete childrenShow [ item . key ] ;
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ describe('rc-queue-anim', () => {
44
44
getInitialState ( ) {
45
45
return {
46
46
show : true ,
47
+ unMount : false ,
47
48
items : [ {
48
49
key : 1 ,
49
50
content : 'div' ,
@@ -61,6 +62,11 @@ describe('rc-queue-anim', () => {
61
62
show : ! this . state . show ,
62
63
} ) ;
63
64
} ,
65
+ unMountQueue ( ) {
66
+ this . setState ( {
67
+ unMount : true ,
68
+ } ) ;
69
+ } ,
64
70
removeOne ( ) {
65
71
const items = this . state . items ;
66
72
const removeIndex = 0 ;
@@ -70,14 +76,16 @@ describe('rc-queue-anim', () => {
70
76
} ,
71
77
render ( ) {
72
78
return (
73
- < QueueAnim { ...props } >
74
- {
75
- this . state . show ?
76
- this . state . items . map ( ( item ) => < div key = { item . key } > { item . content } </ div > ) :
77
- null
78
- }
79
- { null }
80
- </ QueueAnim >
79
+ < section >
80
+ { ! this . state . unMount ? < QueueAnim { ...props } >
81
+ {
82
+ this . state . show ?
83
+ this . state . items . map ( ( item ) => < div key = { item . key } > { item . content } </ div > ) :
84
+ null
85
+ }
86
+ { null }
87
+ </ QueueAnim > : null }
88
+ </ section >
81
89
) ;
82
90
} ,
83
91
} ) ;
@@ -343,4 +351,23 @@ describe('rc-queue-anim', () => {
343
351
} , 17 ) ;
344
352
} , 1000 ) ;
345
353
} ) ;
354
+
355
+ it . only ( 'will un mount' , ( done ) => {
356
+ const instance = createQueueAnimInstance ( {
357
+ animConfig ( e ) {
358
+ if ( e . index === 1 ) {
359
+ return { top : [ 100 , 0 ] } ;
360
+ }
361
+ return { left : [ 100 , 0 ] } ;
362
+ } ,
363
+ } ) ;
364
+ setTimeout ( ( ) => {
365
+ let children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
366
+ expect ( children . length ) . to . be ( 4 ) ;
367
+ instance . unMountQueue ( ) ;
368
+ children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
369
+ expect ( children . length ) . to . be ( 0 ) ;
370
+ done ( ) ;
371
+ } , 100 ) ;
372
+ } ) ;
346
373
} ) ;
You can’t perform that action at this time.
0 commit comments