angular / angular/components

feat(cdk/scrolling): Viewport needs asynchronous functions to set data

Offen
#23,715 4 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: cdk/scrolling feature P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### 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).

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.