MCPcopy Index your code
hub / github.com/TanStack/virtual / AppComponent

Class AppComponent

examples/angular/sticky/src/app/app.component.ts:75–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 `,
74})
75export class AppComponent {
76 rows = rows
77
78 isSticky = (index: number) => stickyIndexesSet.has(index)
79
80 scrollElement = viewChild<ElementRef<HTMLDivElement>>('scrollElement')
81
82 virtualizer = injectVirtualizer(() => ({
83 scrollElement: this.scrollElement(),
84 count: this.rows.length,
85 estimateSize: () => 50,
86 rangeExtractor: (range) => {
87 const next = new Set([
88 reversedStickyIndexes.find((index) => range.startIndex >= index)!,
89 ...defaultRangeExtractor(range),
90 ])
91 return [...next].sort((a, b) => a - b)
92 },
93 }))
94
95 activeStickyIndex = computed(() => {
96 return this.virtualizer.getVirtualItems()[0]?.index
97 })
98
99 isActiveSticky = (index: number) => this.activeStickyIndex() === index
100}

Callers

nothing calls this directly

Calls 2

injectVirtualizerFunction · 0.90
defaultRangeExtractorFunction · 0.85

Tested by

no test coverage detected