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 { ucapAnimations } from '@ucap-webmessenger/ui';
import { GroupDetailData, UserInfo } from '@ucap-webmessenger/protocol-sync'; 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 { ExpansionPanelItemDirective } from '../directives/expansion-panel-item.directive';
import { import {
UserInfoSS, UserInfoSS,
@ -26,8 +26,6 @@ import { NGXLogger } from 'ngx-logger';
import { VirtualScrollTreeFlatDataSource } from '@ucap-webmessenger/ui'; import { VirtualScrollTreeFlatDataSource } from '@ucap-webmessenger/ui';
import { FlatTreeControl } from '@angular/cdk/tree'; import { FlatTreeControl } from '@angular/cdk/tree';
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { fromEvent, Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
enum NodeType { enum NodeType {
None = 'None', None = 'None',
@ -161,8 +159,6 @@ export class ExpansionPanelComponent
@ViewChild('cvsvGroup', { static: false }) @ViewChild('cvsvGroup', { static: false })
cvsvGroup: CdkVirtualScrollViewport; cvsvGroup: CdkVirtualScrollViewport;
private readonly destroySubject = new Subject();
NodeType = NodeType; NodeType = NodeType;
profileNodes: GroupNode[] = []; profileNodes: GroupNode[] = [];
@ -208,16 +204,9 @@ export class ExpansionPanelComponent
); );
} }
ngOnInit() { ngOnInit() {}
fromEvent(window, 'resize')
.pipe(debounceTime(10), takeUntil(this.destroySubject))
.subscribe(() => this.cvsvGroup.checkViewportSize());
}
ngOnDestroy(): void { ngOnDestroy(): void {}
this.destroySubject.next();
this.destroySubject.complete();
}
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.dataSource.cdkVirtualScrollViewport = this.cvsvGroup; 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 { ClickOutsideDirective } from './directives/click-outside.directive';
import { FileUploadForDirective } from './directives/file-upload-for.directive'; import { FileUploadForDirective } from './directives/file-upload-for.directive';
import { ImageDirective } from './directives/image.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 { AlertDialogComponent } from './dialogs/alert.dialog.component';
import { ConfirmDialogComponent } from './dialogs/confirm.dialog.component'; import { ConfirmDialogComponent } from './dialogs/confirm.dialog.component';
@ -62,7 +63,8 @@ const DIALOGS = [AlertDialogComponent, ConfirmDialogComponent];
const DIRECTIVES = [ const DIRECTIVES = [
ClickOutsideDirective, ClickOutsideDirective,
FileUploadForDirective, FileUploadForDirective,
ImageDirective ImageDirective,
CdkVirtualScrollViewportPatchDirective
]; ];
const PIPES = [ const PIPES = [
BytesPipe, BytesPipe,