From 7d8261f0327d8c27bc83256e64e357948236b16d Mon Sep 17 00:00:00 2001 From: E204651X <mael.caubere@etu.univ-nantes.fr> Date: Fri, 13 Jan 2023 19:21:18 +0100 Subject: [PATCH] =?UTF-8?q?fix=20scroll=20to=20bottom=20=C3=A0=20l'initial?= =?UTF-8?q?isation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/doggo-chat/doggo-chat.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/smash/components/doggo-chat/doggo-chat.component.ts b/src/app/smash/components/doggo-chat/doggo-chat.component.ts index 87d8770..2258fb8 100644 --- a/src/app/smash/components/doggo-chat/doggo-chat.component.ts +++ b/src/app/smash/components/doggo-chat/doggo-chat.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { SmashModel } from '../../models/smash.model'; @@ -12,7 +12,7 @@ import {ChatStore} from "../../store/chat.store"; templateUrl: './doggo-chat.component.html', styleUrls: ['./doggo-chat.component.scss'], }) -export class DoggoChatComponent implements OnInit { +export class DoggoChatComponent implements OnInit, AfterViewInit { @ViewChild('scrollMe') private myScrollContainer!: ElementRef; chats: ChatModel[] = [] @@ -44,11 +44,16 @@ export class DoggoChatComponent implements OnInit { this.getDoggoProfileByIndex(); this.retrieveChats(); - //initialisation du formulaire et de la vue + //initialisation du formulaire this.formMessage = new FormGroup({ 'content': new FormControl('') }); + } + /** + * Scroll tout en bas de la conversation après que la vue à été initialisée + */ + ngAfterViewInit(): void { this.scrollToBottom(); } -- GitLab