Skip to content

Commit

Permalink
Make sure that infinite scroll actually ends (ampproject#20647)
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyxz authored and nbeloglazov committed Feb 12, 2019
1 parent f1e30f2 commit 717e583
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions extensions/amp-list/0.1/amp-list.js
Expand Up @@ -855,21 +855,25 @@ export class AmpList extends AMP.BaseElement {
* Called when 3 viewports above bottom of automatic load-more list, or
* manually on clicking the load-more-button element. Sets the amp-list
* src to the bookmarked src and fetches data from it.
* @param {boolean=} opt_reload
* @return {!Promise}
* @private
*/
loadMoreCallback_() {
if (this.loadMoreSrc_) {
loadMoreCallback_(opt_reload = false) {
if (!!this.loadMoreSrc_) {
this.element.setAttribute('src', this.loadMoreSrc_);
this.loadMoreSrc_ = null;
} else if (!opt_reload) {
// Nothing more to load
return Promise.resolve();
}
this.mutateElement(() => {
this.loadMoreService_.toggleLoadMoreLoading(true);
});
return this.fetchList_(/* opt_append */ true)
.then(() => {
if (this.loadMoreSrc_) {
this.loadMoreService_.toggleLoadMoreLoading(false);
this.mutateElement(() =>
this.loadMoreService_.toggleLoadMoreLoading(false));
} else {
this.mutateElement(() =>
this.loadMoreService_.setLoadMoreEnded());
Expand All @@ -886,7 +890,7 @@ export class AmpList extends AMP.BaseElement {
.getLoadMoreFailedClickable();
this.unlistenLoadMore_ = listen(
loadMoreFailedClickable,
'click', () => this.loadMoreCallback_());
'click', () => this.loadMoreCallback_(/*opt_reload*/ true));
});
}

Expand Down

0 comments on commit 717e583

Please sign in to comment.