Skip to content

Commit e3c4983

Browse files
committed
fix When isReverse is true,The scroll bar position incorrect
1 parent bb90778 commit e3c4983

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

dist/InfiniteScroll.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ var InfiniteScroll = (function(_Component) {
110110
{
111111
key: 'componentDidUpdate',
112112
value: function componentDidUpdate() {
113-
if (this.props.isReverse) {
113+
if (this.props.isReverse && this.loadMore) {
114114
var parentElement = this.getParentElement(this.scrollComponent);
115115
parentElement.scrollTop =
116116
parentElement.scrollHeight -
117117
this.beforeScrollHeight +
118118
this.beforeScrollTop;
119+
this.loadMore = false;
119120
}
120121
this.attachScrollListener();
121122
},
@@ -273,6 +274,7 @@ var InfiniteScroll = (function(_Component) {
273274
// Call loadMore after detachScrollListener to allow for non-async loadMore functions
274275
if (typeof this.props.loadMore === 'function') {
275276
this.props.loadMore((this.pageLoaded += 1));
277+
this.loadMore = true;
276278
}
277279
}
278280
},

src/InfiniteScroll.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ export default class InfiniteScroll extends Component {
4444
}
4545

4646
componentDidUpdate() {
47-
if (this.props.isReverse) {
47+
if (this.props.isReverse && this.loadMore) {
4848
const parentElement = this.getParentElement(this.scrollComponent);
4949
parentElement.scrollTop =
5050
parentElement.scrollHeight -
5151
this.beforeScrollHeight +
5252
this.beforeScrollTop;
53+
this.loadMore = false;
5354
}
5455
this.attachScrollListener();
5556
}
@@ -184,6 +185,7 @@ export default class InfiniteScroll extends Component {
184185
// Call loadMore after detachScrollListener to allow for non-async loadMore functions
185186
if (typeof this.props.loadMore === 'function') {
186187
this.props.loadMore((this.pageLoaded += 1));
188+
this.loadMore = true;
187189
}
188190
}
189191
}

0 commit comments

Comments
 (0)