@@ -43,37 +43,41 @@ class ScrollOverPack extends ScrollElement {
43
43
}
44
44
45
45
componentWillReceiveProps ( nextProps ) {
46
+ const { show } = this . state ;
47
+ const { always, children } = nextProps ;
46
48
this . setState ( {
47
- children : toArrayChildren ( nextProps . children ) ,
49
+ children : toArrayChildren ( children ) ,
48
50
} , ( ) => {
49
51
const inListener = EventListener . _listeners . scroll &&
50
52
EventListener . _listeners . scroll . some ( c => c . n === this . eventType . split ( '.' ) [ 1 ] ) ;
51
- if ( nextProps . always && ! inListener ) {
53
+ if ( always && ! inListener ) {
52
54
this . addScrollEvent ( ) ;
53
- } else {
55
+ } else if ( ! always && ! show ) {
54
56
this . scrollEventListener ( ) ;
55
57
}
56
58
} ) ;
57
59
}
58
60
59
61
scrollEventListener = ( e ) => {
60
62
this . getParam ( e ) ;
63
+ const { show } = this . state ;
64
+ const { always, replay } = this . props ;
61
65
const isTop = this . elementShowHeight > this . clientHeight + this . leavePlayHeight ;
62
- if ( this . enter || ! this . props . replay && isTop ) {
63
- if ( ! this . state . show ) {
66
+ if ( this . enter || ! replay && isTop ) {
67
+ if ( ! show ) {
64
68
this . setState ( {
65
69
show : true ,
66
70
} ) ;
67
71
}
68
- if ( ! this . props . always && this . eventType ) {
72
+ if ( ! always && this . eventType ) {
69
73
EventListener . removeEventListener ( this . eventType , this . scrollEventListener , this . target ) ;
70
74
}
71
- } else {
75
+ } else if ( always ) {
72
76
const bottomLeave = this . elementShowHeight < this . playHeight ;
73
77
// 设置往上时的出场点...
74
- const topLeave = this . props . replay ? isTop : null ;
78
+ const topLeave = replay ? isTop : null ;
75
79
if ( topLeave || bottomLeave ) {
76
- if ( this . state . show ) {
80
+ if ( show ) {
77
81
this . setState ( {
78
82
show : false ,
79
83
} ) ;
0 commit comments