Skip to content
Source
Sign inSign up
TanStack/virtual
Open History to see the last commit

app.component.ts

39 lines1.3 KB

1import { ChangeDetectionStrategy, Component } from '@angular/core'
2​
3import { ColumnVirtualizerPadding } from './column-virtualizer-padding.component'
4import { GridVirtualizerPadding } from './grid-virtualizer-padding.component'
5import { RowVirtualizerPadding } from './row-virtualizer-padding.component'
6​
7@Component({
8 selector: 'app-root',
9 standalone: true,
10 changeDetection: ChangeDetectionStrategy.OnPush,
11 imports: [
12 ColumnVirtualizerPadding,
13 GridVirtualizerPadding,
14 RowVirtualizerPadding,
15 ],
16 template: `
17 <p>
18 These components are using <strong>dynamic</strong> sizes. This means that
19 each element's exact dimensions are unknown when rendered. An estimated
20 dimension is used to get an a initial measurement, then this measurement
21 is readjusted on the fly as each element is rendered. Each component has
22 padding at the beginning and end of its scroll container.
23 </p>
24​
25 <row-virtualizer-padding [rows]="rows" />
26 <column-virtualizer-padding [columns]="columns" />
27 <grid-virtualizer-padding [columns]="columns" [rows]="rows" />
28 `,
29 styles: [],
30})
31export class AppComponent {
32 rows = new Array(10000)
33 .fill(true)
34 .map(() => 25 + Math.round(Math.random() * 100))
35​
36 columns = new Array(10000)
37 .fill(true)
38 .map(() => 75 + Math.round(Math.random() * 100))