refactoring of left side drawer indicator

This commit is contained in:
Richard Park 2020-01-22 10:36:14 +09:00
parent 73ea6f3ffa
commit c8b5aae629
5 changed files with 44 additions and 62 deletions

View File

@ -1,4 +1,4 @@
<div #leftSideContainer class="container"> <div class="container">
<div fxFlexFill class="left-side-tabs-body"> <div fxFlexFill class="left-side-tabs-body">
<div <div
#tabs #tabs

View File

@ -124,8 +124,3 @@
height: 100%; height: 100%;
} }
} }
.left-drawer-toggle {
position: absolute;
top: 0px;
}

View File

@ -8,8 +8,7 @@ import {
QueryList, QueryList,
ElementRef, ElementRef,
OnDestroy, OnDestroy,
ViewChild, ViewChild
HostListener
} from '@angular/core'; } from '@angular/core';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui'; import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
@ -31,13 +30,12 @@ import {
UserInfoF, UserInfoF,
UserInfoDN UserInfoDN
} from '@ucap-webmessenger/protocol-query'; } from '@ucap-webmessenger/protocol-query';
import { MatTabChangeEvent } from '@angular/material';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { OpenProfileOptions } from '@ucap-webmessenger/protocol-buddy'; import { OpenProfileOptions } from '@ucap-webmessenger/protocol-buddy';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { MessageType } from '@ucap-webmessenger/api-message'; import { MessageType } from '@ucap-webmessenger/api-message';
import { tap, take } from 'rxjs/operators'; import { tap } from 'rxjs/operators';
import { import {
MessageWriteDialogComponent, MessageWriteDialogComponent,
MessageWriteDialogResult, MessageWriteDialogResult,
@ -51,7 +49,7 @@ import {
} from '@app/types'; } from '@app/types';
import { MessageBoxComponent } from './left-sidenav/message.component'; import { MessageBoxComponent } from './left-sidenav/message.component';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { TranslateService, LangChangeEvent } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@Component({ @Component({
selector: 'app-layout-messenger-left-side', selector: 'app-layout-messenger-left-side',
@ -76,9 +74,6 @@ export class LeftSideComponent implements OnInit, OnDestroy {
@ViewChild('messageBoxComponent', { static: false }) @ViewChild('messageBoxComponent', { static: false })
messageBoxComponent: MessageBoxComponent; messageBoxComponent: MessageBoxComponent;
@ViewChild('leftSideContainer', { static: false })
leftSideContainer: ElementRef<HTMLElement>;
onLangChangeSubscription: Subscription; onLangChangeSubscription: Subscription;
badgeChatUnReadCount: number; badgeChatUnReadCount: number;
@ -102,6 +97,7 @@ export class LeftSideComponent implements OnInit, OnDestroy {
constructor( constructor(
private store: Store<any>, private store: Store<any>,
public elementRef: ElementRef<HTMLElement>,
private dialogService: DialogService, private dialogService: DialogService,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private translateService: TranslateService, private translateService: TranslateService,
@ -183,51 +179,6 @@ export class LeftSideComponent implements OnInit, OnDestroy {
} }
} }
@HostListener('mouseenter', ['$event'])
mouseOver(event: MouseEvent) {
const rect = this.leftSideContainer.nativeElement.getBoundingClientRect();
const minX = rect.left + rect.width - 5;
const maxX = rect.left + rect.width;
const minY = rect.top;
const maxY = rect.top + rect.height;
if (
event.pageX >= minX &&
event.pageX <= maxX &&
event.pageY >= minY &&
event.pageY <= maxY
) {
this.logger.debug('mouseOver edge of container');
this.store.dispatch(
ChatStore.toggleLeftSideDrawerIndicator({ show: true })
);
}
}
@HostListener('mouseleave', ['$event'])
mouseLeave(event: MouseEvent) {
// const rect = this.leftSideContainer.nativeElement.getBoundingClientRect();
// const minX = rect.left;
// const maxX = rect.left + rect.width + 5;
// const minY = rect.top;
// const maxY = rect.top + rect.height;
// if (
// event.pageX >= minX &&
// event.pageX <= maxX &&
// event.pageY >= minY &&
// event.pageY <= maxY
// ) {
// } else {
// this.store.dispatch(
// ChatStore.toggleLeftSideDrawerIndicator({ show: false })
// );
// }
this.store.dispatch(
ChatStore.toggleLeftSideDrawerIndicator({ show: false })
);
}
async onClickNewChat(type: string = 'NORMAL') { async onClickNewChat(type: string = 'NORMAL') {
const result = await this.dialogService.open< const result = await this.dialogService.open<
CreateChatDialogComponent, CreateChatDialogComponent,

View File

@ -6,9 +6,12 @@
<mat-drawer-container class="contents" autosize> <mat-drawer-container class="contents" autosize>
<mat-drawer #leftSideDrawer mode="side" opened> <mat-drawer #leftSideDrawer mode="side" opened>
<app-layout-messenger-left-side <app-layout-messenger-left-side
#leftSideContainer
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(sendCall)="sendClickToCall($event)" (sendCall)="sendClickToCall($event)"
(sendSms)="openSms($event)" (sendSms)="openSms($event)"
(mouseenter)="onMouseEnterLeftSideContainer($event)"
(mouseleave)="onMouseLeaveLeftSideContainer($event)"
></app-layout-messenger-left-side> ></app-layout-messenger-left-side>
</mat-drawer> </mat-drawer>
<div class="chat-messages"> <div class="chat-messages">

View File

@ -5,7 +5,8 @@ import {
Inject, Inject,
OnDestroy, OnDestroy,
ViewChild, ViewChild,
NgZone NgZone,
ElementRef
} from '@angular/core'; } from '@angular/core';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
@ -48,6 +49,7 @@ import { MessageType } from '@ucap-webmessenger/api-message';
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type'; import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { LeftSideComponent } from '@app/layouts/messenger/components/left-side.component';
@Component({ @Component({
selector: 'app-page-messenger-main', selector: 'app-page-messenger-main',
@ -55,8 +57,12 @@ import { TranslateService } from '@ngx-translate/core';
styleUrls: ['./main.page.component.scss'] styleUrls: ['./main.page.component.scss']
}) })
export class MainPageComponent implements OnInit, OnDestroy { export class MainPageComponent implements OnInit, OnDestroy {
@ViewChild('rightDrawer', { static: true }) rightDrawer: MatDrawer; @ViewChild('rightDrawer', { static: true })
@ViewChild('leftSideDrawer', { static: true }) leftSideDrawer: MatDrawer; rightDrawer: MatDrawer;
@ViewChild('leftSideDrawer', { static: true })
leftSideDrawer: MatDrawer;
@ViewChild('leftSideContainer', { static: false })
leftSideContainer: LeftSideComponent;
selectedChat$: Observable<string | null>; selectedChat$: Observable<string | null>;
selectedRightDrawer$: Observable<string | null>; selectedRightDrawer$: Observable<string | null>;
@ -455,4 +461,31 @@ export class MainPageComponent implements OnInit, OnDestroy {
this.onLeftDrawerIndicator = false; this.onLeftDrawerIndicator = false;
} }
} }
onMouseEnterLeftSideContainer(event: MouseEvent) {
const rect = this.leftSideContainer.elementRef.nativeElement.getBoundingClientRect();
const minX = rect.left + rect.width - 10;
const maxX = rect.left + rect.width;
const minY = rect.top;
const maxY = rect.top + rect.height;
if (
event.pageX >= minX &&
event.pageX <= maxX &&
event.pageY >= minY &&
event.pageY <= maxY
) {
this.logger.debug('mouseOver edge of container');
this.store.dispatch(
ChatStore.toggleLeftSideDrawerIndicator({ show: true })
);
}
}
onMouseLeaveLeftSideContainer(event: MouseEvent) {
this.store.dispatch(
ChatStore.toggleLeftSideDrawerIndicator({ show: false })
);
}
} }