feat(cdk/scrolling): ScrollToIndexIfNeeded function
- Lenguaje dominante
- TypeScript
- Estrellas
- 25k
- Forks
- 6.8k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 91
Descripción
#### Feature Description
We have `scrollToIndex` function on `CdkVirtualScrollViewport`. But we cannot determine whenever an index is or is not withing **visible** viewport.
```ts
const viewPort: CdkVirtualScrollViewport;
scrollToIndex(index: number): void {
const range = viewPort.getRenderedRange();
if (range.start > index || range.end < index) {
// Scroll is 100% needed.
viewPort.scrollToIndex(index, 'auto');
} else {
// The index is within range, but not necessarily within visible viewport!
// From my testing I have +-8 items above and bellow at the time
}
}
```
#### Use Case
It would enable scrolling to an item if only needed.
#### Note
If there was `CdkVirtualScrollViewport.getVisibleRange`, we could even scroll our desired element to the middle of the viewport!
Guía de contribución
Línea de trabajo
Comienza con CdkVirtualScrollViewport, especialmente con los puntos de entrada existentes scrollToIndex y getRenderedRange. Determina cómo se podría exponer o utilizar un rango visible para evitar desplazamientos innecesarios, incluido el caso de uso solicitado de la parte central del viewport. Se considera terminado cuando el viewport puede desplazarse hasta un índice únicamente cuando este está fuera del viewport visible.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- frontend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100