API Reference
Inputs
| Input | Type | Default | Description |
|---|
items | unknown[] | [] | Array of data items to render |
bufferSize | number | 3 | Number of extra rows to render above and below the viewport |
loadMoreThreshold | number | 0.8 | Scroll ratio (0-1) at which the loadMore event fires |
scrollParent | HTMLElement | null | null | Custom scroll container. Uses window if null |
Outputs
| Output | Type | Description |
|---|
loadMore | void | Emits when the scroll position crosses the loadMoreThreshold. Resets when the items array length changes. |
Methods
| Method | Description |
|---|
scrollToIndex(index: number) | Scroll to bring the item at the given index into view |
scrollToOffset(px: number) | Scroll to an absolute pixel offset within the grid |
refresh() | Re-measure dimensions and recalculate layout |
Template Context
The ngxVirtualGridItem template receives the following context:
| Variable | Type | Description |
|---|
$implicit | T | The data item |
index | number | The item's index in the original array |
Zoneless Apps
The library works with both zoned and zoneless Angular apps. In zoneless mode, the loadMore output emits from a raw scroll event listener. If your handler modifies component state, use signals so the view updates:
items = signal<Item[]>([]);
onLoadMore(): void {
this.items.update(current => [...current, ...newItems]);
}