Ionic 2 scrolls down a page when opening a page

I am making a chat application. And when I open this chat application, I want the page to slide down. When the field is in focus, the page slides. But at the first opening the page does not slip. What can I do? Image of the chat page My codes;

ionViewDidEnter() {
  this.chat();
}
scrollToBottom() {
  if (this.content.scrollToBottom) {
     this.content.scrollToBottom();
  }
} 
onFocus() {
    this.content.resize();
    this.scrollToBottom();
    this.keyboard.show();
}
Run codeHide result
+4
source share
2 answers

I have not used this property yet, but according to docs :

Attr                Type        Details
-------------------------------------------------------------------------------
scrollDownOnLoad    boolean     If true, the content will scroll down on load.

So you can do it like this:

<ion-content scrollDownOnLoad="true">
    <!-- ... -->
</ion-content>
+3
source

I solved the problem. I call the scroll function in HTML

<ion-content no-padding>
    <div class="message-wrap" >
        <div *ngFor="let msg of gelenMesajlar; let i = index" class="message" [class.left]=" msg.GONDEREN === 'F' " [class.right]=" msg.GONDEREN === 'C' ">
            <div class="msg-detail">
                <div class="msg-content">
                    <span class="triangle"></span>
                    <span [style.font-size]="'10px'" *ngIf="msg.SIPARISID" [style.text-decoration]="'underline'">Konu #{{ msg.SIPARISID }} numaralı sipariş</span>
                    <p class="line-breaker">{{msg.MESAJ}}</p>
                    <span *ngIf="msg.SIPARISID" [style.font-size]="'12px'" (tap)="siparisGoruntule(msg.RESIMID, msg.SIPARISDURUMU, msg.SIPARISID)" [style.text-decoration]="'underline'">Siparişi Görüntüle</span>
                </div>

            </div>
        </div>
        {{ scrollToBottom() }}  <!-- Here it is-->
    </div>
</ion-content>
Run codeHide result
+1
source

Source: https://habr.com/ru/post/1686877/


All Articles