I'm displaying an infinite, virtual scroll using Angular's cdk-virtual-scroll-viewport. The functionality doesn't rely on anything special from it, besides subscribing for the view position, in order to load new elements when the user scrolls to the bottom (in a custom DataSource<Item>):
connect(collectionViewer: CollectionViewer): Observable<Item[]> {
this.viewChanges = collectionViewer.viewChange.subscribe((listRange) => {
this.loadItemsFor(listRange);
});
..
}
That works fine when all the items have the same height (specified both in css and in the itemSize of the <cdk-virtual-scroll-viewport>. Now I'm trying to add a different type of item, which is of different size (lets say 100px vs 50px). This doesn't work well with the FixedSizeVirtualScrollStrategy, so I tried with autosize from the cdl-experimental (which uses AutoSizeVirtualScrollStrategy). However, with the dynamic strategy there's flickering of the scroll position once new elements are added to the datasource that backs up the virtual scroll (I assume because of the ItemAverager).
Is there a feasible way to implement a mix between the two strategies? I know the type of each item in the list, and therefore it's height, so it should be possible to have exact calculations about what's being shown and what is to be loaded? It could potentially be not so performant with large collections, of course.