@@ -11,6 +11,7 @@ import {ListRange} from '@angular/cdk/collections';
11
11
import { Platform } from '@angular/cdk/platform' ;
12
12
import {
13
13
afterNextRender ,
14
+ AfterViewChecked ,
14
15
booleanAttribute ,
15
16
ChangeDetectionStrategy ,
16
17
ChangeDetectorRef ,
@@ -81,7 +82,10 @@ const SCROLL_SCHEDULER =
81
82
} ,
82
83
] ,
83
84
} )
84
- export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements OnInit , OnDestroy {
85
+ export class CdkVirtualScrollViewport
86
+ extends CdkVirtualScrollable
87
+ implements AfterViewChecked , OnInit , OnDestroy
88
+ {
85
89
private _platform = inject ( Platform ) ;
86
90
87
91
/** Emits when the viewport is detached from a CdkVirtualForOf. */
@@ -504,6 +508,14 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
504
508
}
505
509
}
506
510
511
+ ngAfterViewChecked ( ) {
512
+ // Apply the content transform. The transform can't be set via an Angular binding because
513
+ // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
514
+ // string literals, a variable that can only be 'X' or 'Y', and user input that is run through
515
+ // the `Number` function first to coerce it to a numeric value.
516
+ this . _contentWrapper . nativeElement . style . transform = this . _renderedContentTransform ;
517
+ }
518
+
507
519
/** Run change detection. */
508
520
private _doChangeDetection ( ) {
509
521
if ( this . _isDestroyed ) {
@@ -515,11 +527,6 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
515
527
afterNextRender (
516
528
( ) => {
517
529
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
530
const runAfterChangeDetection = this . _runAfterChangeDetection ;
524
531
this . _runAfterChangeDetection = [ ] ;
525
532
for ( const fn of runAfterChangeDetection ) {
0 commit comments