feat(cdk/scrolling): Viewport needs asynchronous functions to set data
- Ngôn ngữ chính
- TypeScript
- Star
- 25k
- Fork
- 6.8k
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 91
Mô tả
#### 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).
Hướng dẫn đóng góp
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, typescript
- Lĩnh vực
- frontend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100