11'use strict' ;
22
33Object . defineProperty ( exports , '__esModule' , {
4- value : true ,
4+ value : true
55} ) ;
66
77var _createClass = ( function ( ) {
@@ -52,7 +52,7 @@ function _classCallCheck(instance, Constructor) {
5252function _possibleConstructorReturn ( self , call ) {
5353 if ( ! self ) {
5454 throw new ReferenceError (
55- "this hasn't been initialised - super() hasn't been called" ,
55+ "this hasn't been initialised - super() hasn't been called"
5656 ) ;
5757 }
5858 return call && ( typeof call === 'object' || typeof call === 'function' )
@@ -64,16 +64,16 @@ function _inherits(subClass, superClass) {
6464 if ( typeof superClass !== 'function' && superClass !== null ) {
6565 throw new TypeError (
6666 'Super expression must either be null or a function, not ' +
67- typeof superClass ,
67+ typeof superClass
6868 ) ;
6969 }
7070 subClass . prototype = Object . create ( superClass && superClass . prototype , {
7171 constructor : {
7272 value : subClass ,
7373 enumerable : false ,
7474 writable : true ,
75- configurable : true ,
76- } ,
75+ configurable : true
76+ }
7777 } ) ;
7878 if ( superClass )
7979 Object . setPrototypeOf
@@ -91,8 +91,8 @@ var InfiniteScroll = (function(_Component) {
9191 this ,
9292 ( InfiniteScroll . __proto__ || Object . getPrototypeOf ( InfiniteScroll ) ) . call (
9393 this ,
94- props ,
95- ) ,
94+ props
95+ )
9696 ) ;
9797
9898 _this . scrollListener = _this . scrollListener . bind ( _this ) ;
@@ -108,13 +108,21 @@ var InfiniteScroll = (function(_Component) {
108108 this . pageLoaded = this . props . pageStart ;
109109 this . options = this . eventListenerOptions ( ) ;
110110 this . attachScrollListener ( ) ;
111- } ,
111+ }
112112 } ,
113113 {
114114 key : 'componentDidUpdate' ,
115115 value : function componentDidUpdate ( ) {
116+ if ( this . props . isReverse && this . loadMore ) {
117+ var parentElement = this . getParentElement ( this . scrollComponent ) ;
118+ parentElement . scrollTop =
119+ parentElement . scrollHeight -
120+ this . beforeScrollHeight +
121+ this . beforeScrollTop ;
122+ this . loadMore = false ;
123+ }
116124 this . attachScrollListener ( ) ;
117- } ,
125+ }
118126 } ,
119127 {
120128 key : 'componentWillUnmount' ,
@@ -154,15 +162,14 @@ var InfiniteScroll = (function(_Component) {
154162 } ;
155163 }
156164 return options ;
157- } ,
158-
165+ }
159166 // Set a defaut loader for all your `InfiniteScroll` components
160167 } ,
161168 {
162169 key : 'setDefaultLoader' ,
163170 value : function setDefaultLoader ( loader ) {
164171 this . defaultLoader = loader ;
165- } ,
172+ }
166173 } ,
167174 {
168175 key : 'detachMousewheelListener' ,
@@ -175,9 +182,9 @@ var InfiniteScroll = (function(_Component) {
175182 scrollEl . removeEventListener (
176183 'mousewheel' ,
177184 this . mousewheelListener ,
178- this . options ? this . options : this . props . useCapture ,
185+ this . options ? this . options : this . props . useCapture
179186 ) ;
180- } ,
187+ }
181188 } ,
182189 {
183190 key : 'detachScrollListener' ,
@@ -190,14 +197,14 @@ var InfiniteScroll = (function(_Component) {
190197 scrollEl . removeEventListener (
191198 'scroll' ,
192199 this . scrollListener ,
193- this . options ? this . options : this . props . useCapture ,
200+ this . options ? this . options : this . props . useCapture
194201 ) ;
195202 scrollEl . removeEventListener (
196203 'resize' ,
197204 this . scrollListener ,
198- this . options ? this . options : this . props . useCapture ,
205+ this . options ? this . options : this . props . useCapture
199206 ) ;
200- } ,
207+ }
201208 } ,
202209 {
203210 key : 'getParentElement' ,
@@ -208,13 +215,13 @@ var InfiniteScroll = (function(_Component) {
208215 return scrollParent ;
209216 }
210217 return el && el . parentNode ;
211- } ,
218+ }
212219 } ,
213220 {
214221 key : 'filterProps' ,
215222 value : function filterProps ( props ) {
216223 return props ;
217- } ,
224+ }
218225 } ,
219226 {
220227 key : 'attachScrollListener' ,
@@ -243,13 +250,13 @@ var InfiniteScroll = (function(_Component) {
243250 scrollEl . addEventListener (
244251 'resize' ,
245252 this . scrollListener ,
246- this . options ? this . options : this . props . useCapture ,
253+ this . options ? this . options : this . props . useCapture
247254 ) ;
248255
249256 if ( this . props . initialLoad ) {
250257 this . scrollListener ( ) ;
251258 }
252- } ,
259+ }
253260 } ,
254261 {
255262 key : 'mousewheelListener' ,
@@ -262,7 +269,7 @@ var InfiniteScroll = (function(_Component) {
262269 ) {
263270 e . preventDefault ( ) ;
264271 }
265- } ,
272+ }
266273 } ,
267274 {
268275 key : 'scrollListener' ,
@@ -300,12 +307,15 @@ var InfiniteScroll = (function(_Component) {
300307 el . offsetParent !== null
301308 ) {
302309 this . detachScrollListener ( ) ;
310+ this . beforeScrollHeight = parentNode . scrollHeight ;
311+ this . beforeScrollTop = parentNode . scrollTop ;
303312 // Call loadMore after detachScrollListener to allow for non-async loadMore functions
304313 if ( typeof this . props . loadMore === 'function' ) {
305314 this . props . loadMore ( ( this . pageLoaded += 1 ) ) ;
315+ this . loadMore = true ;
306316 }
307317 }
308- } ,
318+ }
309319 } ,
310320 {
311321 key : 'calculateOffset' ,
@@ -318,7 +328,7 @@ var InfiniteScroll = (function(_Component) {
318328 this . calculateTopPosition ( el ) +
319329 ( el . offsetHeight - scrollTop - window . innerHeight )
320330 ) ;
321- } ,
331+ }
322332 } ,
323333 {
324334 key : 'calculateTopPosition' ,
@@ -327,7 +337,7 @@ var InfiniteScroll = (function(_Component) {
327337 return 0 ;
328338 }
329339 return el . offsetTop + this . calculateTopPosition ( el . offsetParent ) ;
330- } ,
340+ }
331341 } ,
332342 {
333343 key : 'render' ,
@@ -362,7 +372,7 @@ var InfiniteScroll = (function(_Component) {
362372 'threshold' ,
363373 'useCapture' ,
364374 'useWindow' ,
365- 'getScrollParent' ,
375+ 'getScrollParent'
366376 ] ) ;
367377
368378 props . ref = function ( node ) {
@@ -385,8 +395,8 @@ var InfiniteScroll = (function(_Component) {
385395 }
386396 }
387397 return _react2 . default . createElement ( element , props , childrenArray ) ;
388- } ,
389- } ,
398+ }
399+ }
390400 ] ) ;
391401
392402 return InfiniteScroll ;
@@ -405,8 +415,7 @@ InfiniteScroll.propTypes = {
405415 getScrollParent : _propTypes2 . default . func ,
406416 threshold : _propTypes2 . default . number ,
407417 useCapture : _propTypes2 . default . bool ,
408- useWindow : _propTypes2 . default . bool ,
409- passive : _propTypes2 . default . bool ,
418+ useWindow : _propTypes2 . default . bool
410419} ;
411420InfiniteScroll . defaultProps = {
412421 element : 'div' ,
@@ -419,8 +428,7 @@ InfiniteScroll.defaultProps = {
419428 isReverse : false ,
420429 useCapture : false ,
421430 loader : null ,
422- getScrollParent : null ,
423- passive : false ,
431+ getScrollParent : null
424432} ;
425433exports . default = InfiniteScroll ;
426434module . exports = exports [ 'default' ] ;
0 commit comments