Infinite scroll make ion-content scroll stay at same content after loading more content


I’m having an issue with infinite scroll. It loads the elements as it’s suppose to do. However, when the infinite scroll is finished loading more items the content scrolls away, leaving the user confused what happened. When the infinite scroll is done loading and items were inserted into the DOM, the ion-content’s scroll distance to the bottom should be the same as before. What is the best way to achieve this?

This is what the template looks like:

<ion-content class="conversation" (ionScroll)="contentScroll$.next($event)" (DOMNodeInserted)="messageInserted$.next()">
  <ion-infinite-scroll (ionInfinite)="$event.waitFor(loadMoreMessages())" position="top" threshold="10%">

  <div class="conversation__message"
       *ngFor="let message of (conversation.messages$ | async)"
       [class.conversation__message--own]=" === userId"
       [class.conversation__message--other]=" !== userId">
    <div class="conversation__message__avatar" *ngIf=" !== userId"
    <div class="conversation__message__bubble">{{message.text}}</div>

Do you have any idea how to solve this (preferably elegant and without glitches :sweat_smile:)?