Skip to content

Commit 8bde81f

Browse files
committed
fix(cdk/scrolling): move setting transform to ngAfterViewChecked
1 parent f8c0b8d commit 8bde81f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/cdk/scrolling/virtual-scroll-viewport.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
504504
}
505505
}
506506

507+
ngAfterViewChecked() {
508+
// Apply the content transform. The transform can't be set via an Angular binding because
509+
// bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
510+
// string literals, a variable that can only be 'X' or 'Y', and user input that is run through
511+
// the `Number` function first to coerce it to a numeric value.
512+
this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
513+
}
514+
507515
/** Run change detection. */
508516
private _doChangeDetection() {
509517
if (this._isDestroyed) {
@@ -515,11 +523,6 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
515523
afterNextRender(
516524
() => {
517525
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;
523526
const runAfterChangeDetection = this._runAfterChangeDetection;
524527
this._runAfterChangeDetection = [];
525528
for (const fn of runAfterChangeDetection) {

tools/public_api_guard/cdk/scrolling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
205205
// (undocumented)
206206
static ngAcceptInputType_appendOnly: unknown;
207207
// (undocumented)
208+
ngAfterViewChecked(): void;
209+
// (undocumented)
208210
ngOnDestroy(): void;
209211
// (undocumented)
210212
ngOnInit(): void;

0 commit comments

Comments
 (0)