Hello! I have one problem with using Refresher and InfiniteScroll on the page.
How to reproduce. Scroll down many times to end of the page. Call function infiniteScroll.enable(false)
to stop get new items form array. Then Scroll to top of the page and call Refresher which update items array and show first 5 items. Scroll down again to see other items. On this step doInfinite()
never calls because it was disabled early.
How can I enable InfiniteScroll again after using refresher? Where can I call function infiniteScroll.enable(true)
? If I understand correctly I can’t pass infiniteScroll object to Refresher function.
Page code:
<ion-content>
<ion-refresher (ionRefresh)="getItems($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<ion-list><ion-item *ngFor="let item of items">{{item.name}}</ion-item></ion-list>
<ion-infinite-scroll (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>
Code:
...
getItems(refresher?) {
this.start = 0;
this.perPage = 5;
this.fullItems = [...] // full array with all items;
this.items = this.fullItems.slice(this.start, this.perPage);
this.start += this.perPage;
}
doInfinite(infiniteScroll) {
if (this.start > this.fullItems.length)
infiniteScroll.enable(false);
else {
this.items = this.items.concat(this.fullItems.slice(this.start, this.start + this.perPage));
this.start += this.perPage;
infiniteScroll.complete();
}
}
...