@@ -496,11 +496,7 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
496
496
// properties sequentially we only have to run `_doChangeDetection` once at the end.
497
497
if ( ! this . _isChangeDetectionPending ) {
498
498
this . _isChangeDetectionPending = true ;
499
- this . ngZone . runOutsideAngular ( ( ) =>
500
- Promise . resolve ( ) . then ( ( ) => {
501
- this . _doChangeDetection ( ) ;
502
- } ) ,
503
- ) ;
499
+ this . ngZone . runOutsideAngular ( ( ) => queueMicrotask ( ( ) => this . _doChangeDetection ( ) ) ) ;
504
500
}
505
501
}
506
502
@@ -511,15 +507,20 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
511
507
}
512
508
513
509
this . ngZone . run ( ( ) => {
510
+ // Apply changes to Angular bindings. Note: We must call `markForCheck` to run change detection
511
+ // from the root, since the repeated items are content projected in. Calling `detectChanges`
512
+ // instead does not properly check the projected content.
514
513
this . _changeDetectorRef . markForCheck ( ) ;
514
+
515
+ // Apply the content transform. The transform can't be set via an Angular binding because
516
+ // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
517
+ // string literals, a variable that can only be 'X' or 'Y', and user input that is run through
518
+ // the `Number` function first to coerce it to a numeric value.
519
+ this . _contentWrapper . nativeElement . style . transform = this . _renderedContentTransform ;
520
+
515
521
afterNextRender (
516
522
( ) => {
517
523
this . _isChangeDetectionPending = false ;
518
- // Apply the content transform. The transform can't be set via an Angular binding because
519
- // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
520
- // string literals, a variable that can only be 'X' or 'Y', and user input that is run through
521
- // the `Number` function first to coerce it to a numeric value.
522
- this . _contentWrapper . nativeElement . style . transform = this . _renderedContentTransform ;
523
524
const runAfterChangeDetection = this . _runAfterChangeDetection ;
524
525
this . _runAfterChangeDetection = [ ] ;
525
526
for ( const fn of runAfterChangeDetection ) {
0 commit comments