diff --git a/src/lib/listing/table-content/table-content.component.ts b/src/lib/listing/table-content/table-content.component.ts index 2572b84..2942d7a 100644 --- a/src/lib/listing/table-content/table-content.component.ts +++ b/src/lib/listing/table-content/table-content.component.ts @@ -1,6 +1,6 @@ import { AfterViewInit, ChangeDetectionStrategy, Component, forwardRef, Inject, Input, OnDestroy, ViewChild } from '@angular/core'; import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; -import { tap } from 'rxjs/operators'; +import { delay, tap } from 'rxjs/operators'; import { AutoUnsubscribe, trackBy } from '../../utils'; import { IListable } from '../models'; import { ListingComponent, ListingService } from '../index'; @@ -39,11 +39,12 @@ export class TableContentComponent extends AutoUnsubscribe ngAfterViewInit(): void { this.addSubscription = this.scrollViewport.scrolledIndexChange.pipe(tap(index => (this._lastScrolledIndex = index))).subscribe(); - this.addSubscription = this.listingService.displayedLength$.subscribe(() => { - setTimeout(() => { - this.hasScrollbarDirective.process(); - }, 0); - }); + this.addSubscription = this.listingService.displayedLength$ + .pipe( + delay(100), + tap(() => this.hasScrollbarDirective.process()), + ) + .subscribe(); } scrollToLastIndex(): void {