@angular/cdk-experimental/scrolling源码总结

iwe7-scrolling

@copy from @angular/cdk-experimental

CdkVirtualScrollViewport Component

selector cdk-virtual-scroll-viewport

// inputs
@Input() orientation: "horizontal" | "vertical" = "vertical";
复制代码
CdkVirtualForOf Directive

selector [cdkVirtualFor][cdkVirtualForOf]

// 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 Directive

selector cdk-virtual-scroll-viewport[autosize]

// inputs
@Input() minBufferPx: number = 100;
@Input() addBufferPx: number = 200;
复制代码

``

selector cdk-virtual-scroll-viewport[itemSize]

@Input() itemSize: number = 20;
@Input() bufferSize: number = 5;
复制代码

VirtualScrollStrategy Interface

export 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 Class

AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy Class

FixedSizeVirtualScrollStrategy implements VirtualScrollStrategy Class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值