@@ -43,37 +43,41 @@ class ScrollOverPack extends ScrollElement {
4343 }
4444
4545 componentWillReceiveProps ( nextProps ) {
46+ const { show } = this . state ;
47+ const { always, children } = nextProps ;
4648 this . setState ( {
47- children : toArrayChildren ( nextProps . children ) ,
49+ children : toArrayChildren ( children ) ,
4850 } , ( ) => {
4951 const inListener = EventListener . _listeners . scroll &&
5052 EventListener . _listeners . scroll . some ( c => c . n === this . eventType . split ( '.' ) [ 1 ] ) ;
51- if ( nextProps . always && ! inListener ) {
53+ if ( always && ! inListener ) {
5254 this . addScrollEvent ( ) ;
53- } else {
55+ } else if ( ! always && ! show ) {
5456 this . scrollEventListener ( ) ;
5557 }
5658 } ) ;
5759 }
5860
5961 scrollEventListener = ( e ) => {
6062 this . getParam ( e ) ;
63+ const { show } = this . state ;
64+ const { always, replay } = this . props ;
6165 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 ) {
6468 this . setState ( {
6569 show : true ,
6670 } ) ;
6771 }
68- if ( ! this . props . always && this . eventType ) {
72+ if ( ! always && this . eventType ) {
6973 EventListener . removeEventListener ( this . eventType , this . scrollEventListener , this . target ) ;
7074 }
71- } else {
75+ } else if ( always ) {
7276 const bottomLeave = this . elementShowHeight < this . playHeight ;
7377 // 设置往上时的出场点...
74- const topLeave = this . props . replay ? isTop : null ;
78+ const topLeave = replay ? isTop : null ;
7579 if ( topLeave || bottomLeave ) {
76- if ( this . state . show ) {
80+ if ( show ) {
7781 this . setState ( {
7882 show : false ,
7983 } ) ;
0 commit comments