bug of virtual scroll is fixed

This commit is contained in:
병준 박 2019-11-18 16:58:27 +09:00
parent 59e4a500d0
commit 7aa5f4f227
3 changed files with 36 additions and 15 deletions

View File

@ -15,7 +15,7 @@ import {
import { ucapAnimations } from '@ucap-webmessenger/ui';
import { GroupDetailData, UserInfo } from '@ucap-webmessenger/protocol-sync';
import { MatAccordion, MatTreeFlattener, MatTree } from '@angular/material';
import { MatTreeFlattener, MatTree } from '@angular/material';
import { ExpansionPanelItemDirective } from '../directives/expansion-panel-item.directive';
import {
UserInfoSS,
@ -26,8 +26,6 @@ import { NGXLogger } from 'ngx-logger';
import { VirtualScrollTreeFlatDataSource } from '@ucap-webmessenger/ui';
import { FlatTreeControl } from '@angular/cdk/tree';
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { fromEvent, Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
enum NodeType {
None = 'None',
@ -161,8 +159,6 @@ export class ExpansionPanelComponent
@ViewChild('cvsvGroup', { static: false })
cvsvGroup: CdkVirtualScrollViewport;
private readonly destroySubject = new Subject();
NodeType = NodeType;
profileNodes: GroupNode[] = [];
@ -208,16 +204,9 @@ export class ExpansionPanelComponent
);
}
ngOnInit() {
fromEvent(window, 'resize')
.pipe(debounceTime(10), takeUntil(this.destroySubject))
.subscribe(() => this.cvsvGroup.checkViewportSize());
}
ngOnInit() {}
ngOnDestroy(): void {
this.destroySubject.next();
this.destroySubject.complete();
}
ngOnDestroy(): void {}
ngAfterViewInit(): void {
this.dataSource.cdkVirtualScrollViewport = this.cvsvGroup;

View File

@ -0,0 +1,30 @@
import { Directive, OnInit, OnDestroy, Self, Inject } from '@angular/core';
import { Subject, fromEvent } from 'rxjs';
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { debounceTime, takeUntil } from 'rxjs/operators';
@Directive({
// tslint:disable-next-line: directive-selector
selector: 'cdk-virtual-scroll-viewport'
})
export class CdkVirtualScrollViewportPatchDirective
implements OnInit, OnDestroy {
protected readonly destroySubject = new Subject();
constructor(
@Self()
@Inject(CdkVirtualScrollViewport)
private readonly viewportComponent: CdkVirtualScrollViewport
) {}
ngOnInit() {
fromEvent(window, 'resize')
.pipe(debounceTime(10), takeUntil(this.destroySubject))
.subscribe(() => this.viewportComponent.checkViewportSize());
}
ngOnDestroy() {
this.destroySubject.next();
this.destroySubject.complete();
}
}

View File

@ -34,6 +34,7 @@ import { SnackBarService } from './services/snack-bar.service';
import { ClickOutsideDirective } from './directives/click-outside.directive';
import { FileUploadForDirective } from './directives/file-upload-for.directive';
import { ImageDirective } from './directives/image.directive';
import { CdkVirtualScrollViewportPatchDirective } from './directives/cdk-virtual-scroll-viewport-patch.directive';
import { AlertDialogComponent } from './dialogs/alert.dialog.component';
import { ConfirmDialogComponent } from './dialogs/confirm.dialog.component';
@ -62,7 +63,8 @@ const DIALOGS = [AlertDialogComponent, ConfirmDialogComponent];
const DIRECTIVES = [
ClickOutsideDirective,
FileUploadForDirective,
ImageDirective
ImageDirective,
CdkVirtualScrollViewportPatchDirective
];
const PIPES = [
BytesPipe,