@@ -88,21 +88,16 @@ var ReduxInfiniteScroll = function (_Component) {
88
88
} , {
89
89
key : 'scrollListener' ,
90
90
value : function scrollListener ( ) {
91
- var _this2 = this ;
92
-
93
91
// This is to prevent the upcoming logic from toggling a load more before
94
92
// any data has been passed to the component
95
- if ( this . props . items <= 0 ) return ;
93
+ if ( this . _totalItemsSize ( ) <= 0 ) return ;
96
94
97
- // Need to find better way around this setTimeout
98
- setTimeout ( function ( ) {
99
- var bottomPosition = _this2 . props . elementIsScrollable ? _this2 . _elScrollListener ( ) : _this2 . _windowScrollListener ( ) ;
95
+ var bottomPosition = this . props . elementIsScrollable ? this . _elScrollListener ( ) : this . _windowScrollListener ( ) ;
100
96
101
- if ( bottomPosition < Number ( _this2 . props . threshold ) ) {
102
- _this2 . detachScrollListener ( ) ;
103
- _this2 . props . loadMore ( ) ;
104
- }
105
- } ) ;
97
+ if ( bottomPosition < Number ( this . props . threshold ) ) {
98
+ this . detachScrollListener ( ) ;
99
+ this . props . loadMore ( ) ;
100
+ }
106
101
}
107
102
} , {
108
103
key : 'detachScrollListener' ,
@@ -118,6 +113,14 @@ var ReduxInfiniteScroll = function (_Component) {
118
113
119
114
return [ allItems , this . renderLoader ( ) ] ;
120
115
}
116
+ } , {
117
+ key : '_totalItemsSize' ,
118
+ value : function _totalItemsSize ( ) {
119
+ var totalSize = void 0 ;
120
+ totalSize += this . props . children . size ? this . props . children . size : this . props . children . length ;
121
+ totalSize += this . props . items . size ? this . props . items . size : this . props . items . length ;
122
+ return totalSize ;
123
+ }
121
124
} , {
122
125
key : 'componentWillUnmount' ,
123
126
value : function componentWillUnmount ( ) {
0 commit comments