GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - garrettld/tanstack-angular-virtual

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
angular.json
angular.json
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.app.json
tsconfig.app.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Overview

Open in StackBlitz

This is a proof of concept for an Angular adapter for TanStack Virtual that uses Angular signals. The app includes working Angular versions of each of the React examples in the TanStack Virtual docs to verify that all functionality works as expected.

Basic usage requires only a call to injectVirtualizer and a viewChild reference to the scroll element:

@Component({ ... })
class VirtualList {
    scrollElement = viewChild<ElementRef<HTMLDivElement>>('scrollElement');
    
    virtualizer = injectVirtualizer(() => ({
        scrollElement: this.scrollElement(),
        count: 10000,
        estimateSize: (index) => 100,
    }));
}

The adapter implementation is in /src/virtualizer.ts.

Imperative methods and static properties on the virtualizer object are available directly on the virtualizer. For example:

scrollToIndex(index: number) {
    this.virtualizer.scrollToIndex(index);
}

Methods and properties that depend on Virtualizer state are wrapped in signals:

virtualizer = injectVirtualizer(...);

firstRow = computed(() => this.virtualizer.getVirtualRows()[0]); // Signal<VirtualItem>
isScrollingDown = computed(() => this.virtualizer.scrollDirection() === 'forward'); // Signal<boolean>
isReallyBig = computed(() => this.virtualizer.getTotalSize() > 9000); // Signal<boolean>

Methods that accept arguments return computed signals:

virtualizer = injectVirtualizer(...);

itemAtOffset100 = this.virtualizer.getVirtualItemForOffset(100); // Signal<VirtualItem>
itemAtOffset100Index = computed(() => this.itemAtOffset100().index); // Signal<number>

autoOffset = this.virtualizer.getOffsetForAlignment(100, 'auto'); // Signal<number>

offsetForIndex9 = this.virtualizer.getOffsetForIndex(9, 'start'); // Signal<number>

Goals

  • Works with OnPush
  • Works with signals
  • Works with required inputs
  • Works with Zoneless (not sure, but I think it would?)

Questions/Feedback

  • How can we improve the API?
  • Should there be built-in directives/services/components to simplify things?
  • Do we care about supporting previous versions of Angular without signals?

About

No description, website, or topics provided.

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

1 fork
Report repository

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.