feat(cdk/scrolling): Viewport needs asynchronous functions to set data
- 主要语言
- TypeScript
- 星标
- 25k
- 派生
- 6.8k
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 91
描述
#### Feature Description
The virtual scrolling viewport is [asynchronously initialized](https://github.com/angular/components/blob/master/src/cdk/scrolling/virtual-scroll-viewport.ts#L195). Normally developers can expect that when `ngAfterViewInit()` is called in a component's parent, the component will be ready for interaction, but the viewport is not yet ready at that point. The application needs to wait a tick so that the viewport can finish initializing before using functions like `scrollToIndex`. Developers should not need to know this before using the viewport.
I request that all functions requiring a fully initialized viewport be replaced with asynchronous versions that defer the execution of those functions until the viewport is finished with initialization. A viable alternative would be to provide an Observable that declares that the viewport is ready to receive commands.
#### Use Case
I want to be able to use the viewport in `ngAfterViewInit` as can normally be done with child components. See [this Stackblitz](https://stackblitz.com/edit/autoscroll?file=src%2Fapp%2Fapp.component.ts).
贡献指南
调研方向
Start with src/cdk/scrolling/virtual-scroll-viewport.ts around the asynchronous initialization at line 195, then review the scrollToIndex use case and linked StackBlitz. Identify which viewport commands depend on readiness and determine whether deferred methods or a readiness Observable best supports use from ngAfterViewInit; done means commands work without an extra caller-supplied tick.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100