bug of scroll is fixed

This commit is contained in:
병준 박 2019-11-01 15:06:37 +09:00
parent bb1c74823d
commit 654a8475fe
4 changed files with 87 additions and 23 deletions

View File

@ -17,7 +17,8 @@
mat-icon-button mat-icon-button
aria-label="chats button" aria-label="chats button"
class="responsive-chats-button" class="responsive-chats-button"
*ngIf="!!roomInfo && roomInfo.isTimeRoom"> *ngIf="!!roomInfo && roomInfo.isTimeRoom"
>
<mat-icon>timer</mat-icon> <mat-icon>timer</mat-icon>
</button> </button>
</div> </div>
@ -26,8 +27,13 @@
{{ getRoomName() }} {{ getRoomName() }}
</h3> </h3>
<!-- Timer Room Info --> <!-- Timer Room Info -->
<div *ngIf="roomInfo && roomInfo.isTimeRoom" class="room-type text-accent-color "> <div
<span class="bg-accent-light">{{ getConvertTimer(roomInfo.timeRoomInterval) }} </span>비밀 대화방입니다. *ngIf="roomInfo && roomInfo.isTimeRoom"
class="room-type text-accent-color "
>
<span class="bg-accent-light"
>{{ getConvertTimer(roomInfo.timeRoomInterval) }} </span
>비밀 대화방입니다.
</div> </div>
<!-- Timer Room Info --> <!-- Timer Room Info -->
</div> </div>
@ -82,8 +88,6 @@
(fileDragOver)="onFileDragOver()" (fileDragOver)="onFileDragOver()"
(fileDragLeave)="onFileDragLeave()" (fileDragLeave)="onFileDragLeave()"
> >
<!-- CHAT MESSAGES --> <!-- CHAT MESSAGES -->
<perfect-scrollbar <perfect-scrollbar
fxFlex="1 1 auto" fxFlex="1 1 auto"
@ -124,6 +128,7 @@
<div fxFlex="0 0 auto" fxLayout="column"> <div fxFlex="0 0 auto" fxLayout="column">
<!-- REPLY FORM --> <!-- REPLY FORM -->
<ucap-chat-form <ucap-chat-form
#chatForm
(send)="onSendMessage($event)" (send)="onSendMessage($event)"
(sendFiles)="onFileSelected($event)" (sendFiles)="onFileSelected($event)"
></ucap-chat-form> ></ucap-chat-form>

View File

@ -18,12 +18,12 @@
word-wrap: break-word; word-wrap: break-word;
} }
} }
.container{ .container {
position: relative; position: relative;
width:100%; width: 100%;
} }
.chat-toolbar { .chat-toolbar {
width:100%; width: 100%;
height: 70px; height: 70px;
min-height: 70px; min-height: 70px;
align-items: center; align-items: center;
@ -53,7 +53,7 @@
} }
} }
.room-info { .room-info {
display:flex; display: flex;
flex-flow: column; flex-flow: column;
overflow: hidden; overflow: hidden;
.room-name { .room-name {
@ -65,21 +65,42 @@
font-size: 14px; font-size: 14px;
line-height: normal; line-height: normal;
margin-top: 6px; margin-top: 6px;
height:20px; height: 20px;
span{ span {
border-radius:10px; border-radius: 10px;
padding:1px 10px; padding: 1px 10px;
margin-right:6px; margin-right: 6px;
font-size:13px; font-size: 13px;
} }
} }
} }
.room-option { .room-option {
wdith: 100%; width: 100%;
margin-left: auto; margin-left: auto;
} }
} }
} }
.chat-content { .chat-content {
position: relative;
background: transparent;
overflow: auto; overflow: auto;
-webkit-overflow-scrolling: touch;
.file-drop-zone-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.95);
.file-drop-zone {
position: absolute;
top: 10%;
left: 10%;
width: 80%;
height: 80%;
}
}
} }

View File

@ -4,7 +4,9 @@ import {
OnDestroy, OnDestroy,
AfterViewChecked, AfterViewChecked,
ViewChild, ViewChild,
ElementRef ElementRef,
AfterContentInit,
AfterViewInit
} from '@angular/core'; } from '@angular/core';
import { import {
ucapAnimations, ucapAnimations,
@ -43,7 +45,10 @@ import {
} from '@app/types'; } from '@app/types';
import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room'; import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
import { tap, take } from 'rxjs/operators'; import { tap, take } from 'rxjs/operators';
import { FileInfo } from '@ucap-webmessenger/ui-chat'; import {
FileInfo,
FormComponent as UCapUiChatFormComponent
} from '@ucap-webmessenger/ui-chat';
import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { KEY_VER_INFO } from '@app/types/ver-info.type';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { MatMenuTrigger } from '@angular/material'; import { MatMenuTrigger } from '@angular/material';
@ -67,10 +72,13 @@ import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar';
styleUrls: ['./messages.component.scss'], styleUrls: ['./messages.component.scss'],
animations: ucapAnimations animations: ucapAnimations
}) })
export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild('messageBoxContainer', { static: true }) @ViewChild('messageBoxContainer', { static: true })
private messageBoxContainer: ElementRef; private messageBoxContainer: ElementRef;
@ViewChild('chatForm', { static: true })
private chatForm: UCapUiChatFormComponent;
@ViewChild('messageContextMenuTrigger', { static: true }) @ViewChild('messageContextMenuTrigger', { static: true })
messageContextMenuTrigger: MatMenuTrigger; messageContextMenuTrigger: MatMenuTrigger;
messageContextMenuPosition = { x: '0px', y: '0px' }; messageContextMenuPosition = { x: '0px', y: '0px' };
@ -167,6 +175,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
tap(infoList => { tap(infoList => {
if (!!infoList && infoList.length > 0) { if (!!infoList && infoList.length > 0) {
this.baseEventSeq = infoList[0].seq; this.baseEventSeq = infoList[0].seq;
this.readyToReply();
} }
}) })
); );
@ -175,8 +184,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
select(AppStore.MessengerSelector.EventSelector.infoStatus) select(AppStore.MessengerSelector.EventSelector.infoStatus)
); );
this.psChatContent.directiveRef.scrollToBottom(0, 0);
this.interval = setInterval(() => { this.interval = setInterval(() => {
if (!!this.roomInfo.isTimeRoom) { if (!!this.roomInfo.isTimeRoom) {
this.store.dispatch(EventStore.infoIntervalClear({})); this.store.dispatch(EventStore.infoIntervalClear({}));
@ -198,8 +205,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
clearInterval(this.interval); clearInterval(this.interval);
} }
ngAfterViewChecked(): void { ngAfterViewInit(): void {
this.psChatContent.directiveRef.scrollToBottom(0, 0); this.readyToReply();
} }
getRoomName() { getRoomName() {
@ -240,6 +247,30 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
selectContact() {} selectContact() {}
readyToReply(): void {
setTimeout(() => {
this.focusReplyInput();
this.scrollToBottom();
});
}
focusReplyInput(): void {
setTimeout(() => {
this.chatForm.focus();
});
}
scrollToBottom(speed?: number): void {
speed = speed || 0;
if (this.psChatContent.directiveRef) {
this.psChatContent.directiveRef.update();
setTimeout(() => {
this.psChatContent.directiveRef.scrollToBottom(0, speed);
});
}
}
async onSendMessage(message: string) { async onSendMessage(message: string) {
if (!message || message.trim().length === 0) { if (!message || message.trim().length === 0) {
const result = await this.dialogService.open< const result = await this.dialogService.open<

View File

@ -23,6 +23,9 @@ export class FormComponent implements OnInit {
@ViewChild('replyForm', { static: false }) @ViewChild('replyForm', { static: false })
replyForm: NgForm; replyForm: NgForm;
@ViewChild('replyInput', { static: false })
replyInput: ElementRef<HTMLTextAreaElement>;
@ViewChild('fileInput', { static: false }) @ViewChild('fileInput', { static: false })
fileInput: ElementRef<HTMLInputElement>; fileInput: ElementRef<HTMLInputElement>;
@ -30,6 +33,10 @@ export class FormComponent implements OnInit {
ngOnInit() {} ngOnInit() {}
focus(): void {
this.replyInput.nativeElement.focus();
}
onSend(event: Event) { onSend(event: Event) {
event.preventDefault(); event.preventDefault();