From cd68511a4c2f985c265f4e1b89df02e92c14e7c5 Mon Sep 17 00:00:00 2001 From: nename0 <26363498+nename0@users.noreply.github.com> Date: Fri, 14 Sep 2018 22:56:16 +0200 Subject: [PATCH] perf(virtual-scroll): use auditTime instead of sampleTime --- src/cdk/scrolling/virtual-scroll-viewport.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cdk/scrolling/virtual-scroll-viewport.ts b/src/cdk/scrolling/virtual-scroll-viewport.ts index 01910cc95130..da9014da345e 100644 --- a/src/cdk/scrolling/virtual-scroll-viewport.ts +++ b/src/cdk/scrolling/virtual-scroll-viewport.ts @@ -24,7 +24,7 @@ import { ViewEncapsulation, } from '@angular/core'; import {animationFrameScheduler, Observable, Subject} from 'rxjs'; -import {sampleTime, startWith, takeUntil} from 'rxjs/operators'; +import {auditTime, startWith, takeUntil} from 'rxjs/operators'; import {ScrollDispatcher} from './scroll-dispatcher'; import {CdkScrollable, ExtendedScrollToOptions} from './scrollable'; import {CdkVirtualForOf} from './virtual-for-of'; @@ -144,9 +144,10 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O .pipe( // Start off with a fake scroll event so we properly detect our initial position. startWith(null!), - // Sample the scroll stream at every animation frame. This way if there are multiple - // scroll events in the same frame we only need to recheck our layout once. - sampleTime(0, animationFrameScheduler)) + // Collect multiple events into one until the next animation frame. This way if + // there are multiple scroll events in the same frame we only need to recheck + // our layout once. + auditTime(0, animationFrameScheduler)) .subscribe(() => this._scrollStrategy.onContentScrolled()); this._markChangeDetectionNeeded();