iwe7-scrolling
@copy from @angular/cdk-experimentalui
CdkVirtualScrollViewport
Componentselector
cdk-virtual-scroll-viewport
this
// inputs
@Input() orientation: "horizontal" | "vertical" = "vertical";
複製代碼
CdkVirtualForOf
Directiveselector
[cdkVirtualFor][cdkVirtualForOf]
spa
// inputs
@Input() cdkVirtualForOf: DataSource<T> | Observable<T[]> | NgIterable<T>;
@Input() cdkVirtualForTrackBy: TrackByFunction<T> | undefined;
@Input() cdkVirtualForTemplate: TemplateRef<CdkVirtualForOfContext<T>>;
@Input() cdkVirtualForTemplateCacheSize: number = 20;
// 屬性
viewChange = new Subject<ListRange>();
// 方法
measureRangeSize(range: ListRange,orientation: "horizontal" | "vertical"): number;
複製代碼
CdkAutoSizeVirtualScroll
Directiveselector
cdk-virtual-scroll-viewport[autosize]
code
// inputs
@Input() minBufferPx: number = 100;
@Input() addBufferPx: number = 200;
複製代碼
selector
cdk-virtual-scroll-viewport[itemSize]
input
@Input() itemSize: number = 20;
@Input() bufferSize: number = 5;
複製代碼
VirtualScrollStrategy
Interfaceexport interface VirtualScrollStrategy {
/** * Attaches this scroll strategy to a viewport. * @param viewport The viewport to attach this strategy to. */
attach(viewport: CdkVirtualScrollViewport): void;
/** Detaches this scroll strategy from the currently attached viewport. */
detach(): void;
/** Called when the viewport is scrolled (debounced using requestAnimationFrame). */
onContentScrolled();
/** Called when the length of the data changes. */
onDataLengthChanged();
/** Called when the range of items rendered in the DOM has changed. */
onContentRendered();
/** Called when the offset of the rendered items changed. */
onRenderedOffsetChanged();
}
複製代碼
ItemSizeAverager
ClassAutoSizeVirtualScrollStrategy
implements VirtualScrollStrategy ClassFixedSizeVirtualScrollStrategy
implements VirtualScrollStrategy Class