bug fixed

This commit is contained in:
richard-loafle 2020-04-23 13:31:28 +09:00
parent 6a0f008457
commit 0fc503db87
2 changed files with 42 additions and 2 deletions

View File

@ -1,12 +1,21 @@
import { Observable } from 'rxjs';
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { LogService } from '@ucap/ng-logger'; import { LogService } from '@ucap/ng-logger';
import { import {
VirtualScrollStrategy, VirtualScrollStrategy,
FixedSizeVirtualScrollStrategy, FixedSizeVirtualScrollStrategy,
VIRTUAL_SCROLL_STRATEGY VIRTUAL_SCROLL_STRATEGY,
CdkVirtualScrollViewport
} from '@angular/cdk/scrolling'; } from '@angular/cdk/scrolling';
export class GroupVirtualScrollStrategy extends FixedSizeVirtualScrollStrategy {
constructor() {
super(60, 150, 200); // (itemSize, minBufferPx, maxBufferPx)
}
}
@Component({ @Component({
selector: 'app-sections-group-list', selector: 'app-sections-group-list',
templateUrl: './list.section.component.html', templateUrl: './list.section.component.html',
@ -14,7 +23,7 @@ import {
providers: [ providers: [
{ {
provide: VIRTUAL_SCROLL_STRATEGY, provide: VIRTUAL_SCROLL_STRATEGY,
useValue: new FixedSizeVirtualScrollStrategy(60, 3, 3) useClass: GroupVirtualScrollStrategy
} }
] ]
}) })

View File

@ -0,0 +1,31 @@
import { Observable, Subject } from 'rxjs';
import {
VirtualScrollStrategy,
CdkVirtualScrollViewport
} from '@angular/cdk/scrolling';
import { distinctUntilChanged } from 'rxjs/operators';
export class GroupVirtualScrollStrategy implements VirtualScrollStrategy {
scrolledIndexChange: Observable<number>;
private indexSubject = new Subject<number>();
private viewport: CdkVirtualScrollViewport | null = null;
constructor() {
this.scrolledIndexChange = this.indexSubject.pipe(distinctUntilChanged());
}
attach(viewport: CdkVirtualScrollViewport): void {
this.viewport = viewport;
}
detach(): void {
this.indexSubject.complete();
this.viewport = null;
}
onContentScrolled(): void {}
onDataLengthChanged(): void {}
onContentRendered(): void {}
onRenderedOffsetChanged(): void {}
scrollToIndex(index: number, behavior: ScrollBehavior): void {}
}