Hi, I use ion-infinite-scroll as in the first example on this page
But I have set the position to top.
<ion-content role="feed">
<ion-infinite-scroll position="top" (ionInfinite)="loadMoreData($event)">
<ion-infinite-scroll-content loadingText="Loading more Data..." loadingSpinner="bubbles"></ion-infinite-scroll-content>
</ion-infinite-scroll>
<ion-list>
<app-data *ngFor="let data of datas" [data]="data"></app-data>
</ion-list>
</ion-content>
Since I would like to have the scrollbars at the end of the list after inserting the data, I call scrollToBottem.
scrollToBottom() {
setTimeout(() => {
if(this.content !== undefined) {
this.content.scrollToBottom(300);
}
}, 500);
setTimeout(() => {
this.initload_ready = true;
}, 1500);
}
Unfortunately, this call triggers an infinite scroll event! To block this event at the beginning, I have to trick with a variable (initload_ready).
loadMoreData(event: InfiniteScrollCustomEvent) {
if (!this.initload_ready) {
this.completeScrollEvent(event);
return;
}
[...]
}
I think that with position = top no infinite scroll event should be triggered with a down scrolling. Seems that it triggers an event when there is a movement in the trigger zone without differentiating the direction.
What is also not quite optimal is that there is a position in the trigger zone (PWA on desktop) where infinite scroll events are triggered until event.target.complete() is called. That’s why I have to limit the number of items and call “event.target.disabled = true” so that not all data records are loaded automatically into the array.
Is there anything in the code that I can do better?
1 post - 1 participant
Read full topic