feat(cdk/scrolling): Viewport needs asynchronous functions to set data
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
#### 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).
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100