File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,14 @@ var InfiniteScroll = (function(_Component) {
110110 {
111111 key : 'componentDidUpdate' ,
112112 value : function componentDidUpdate ( ) {
113+ if ( this . props . isReverse && this . loadMore ) {
114+ var parentElement = this . getParentElement ( this . scrollComponent ) ;
115+ parentElement . scrollTop =
116+ parentElement . scrollHeight -
117+ this . beforeScrollHeight +
118+ this . beforeScrollTop ;
119+ this . loadMore = false ;
120+ }
113121 this . attachScrollListener ( ) ;
114122 } ,
115123 } ,
@@ -261,9 +269,12 @@ var InfiniteScroll = (function(_Component) {
261269 el . offsetParent !== null
262270 ) {
263271 this . detachScrollListener ( ) ;
272+ this . beforeScrollHeight = parentNode . scrollHeight ;
273+ this . beforeScrollTop = parentNode . scrollTop ;
264274 // Call loadMore after detachScrollListener to allow for non-async loadMore functions
265275 if ( typeof this . props . loadMore === 'function' ) {
266276 this . props . loadMore ( ( this . pageLoaded += 1 ) ) ;
277+ this . loadMore = true ;
267278 }
268279 }
269280 } ,
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ export default class InfiniteScroll extends Component {
4444 }
4545
4646 componentDidUpdate ( ) {
47+ if ( this . props . isReverse && this . loadMore ) {
48+ const parentElement = this . getParentElement ( this . scrollComponent ) ;
49+ parentElement . scrollTop =
50+ parentElement . scrollHeight -
51+ this . beforeScrollHeight +
52+ this . beforeScrollTop ;
53+ this . loadMore = false ;
54+ }
4755 this . attachScrollListener ( ) ;
4856 }
4957
@@ -172,9 +180,12 @@ export default class InfiniteScroll extends Component {
172180 ( el && el . offsetParent !== null )
173181 ) {
174182 this . detachScrollListener ( ) ;
183+ this . beforeScrollHeight = parentNode . scrollHeight ;
184+ this . beforeScrollTop = parentNode . scrollTop ;
175185 // Call loadMore after detachScrollListener to allow for non-async loadMore functions
176186 if ( typeof this . props . loadMore === 'function' ) {
177187 this . props . loadMore ( ( this . pageLoaded += 1 ) ) ;
188+ this . loadMore = true ;
178189 }
179190 }
180191 }
You can’t perform that action at this time.
0 commit comments