Skip to content

Commit

Permalink
fix(cdk/scrolling): move setting transform to ngAfterViewChecked
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Apr 25, 2024
1 parent f8c0b8d commit 8bde81f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/cdk/scrolling/virtual-scroll-viewport.ts
Expand Up @@ -504,6 +504,14 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
}
}

ngAfterViewChecked() {
// Apply the content transform. The transform can't be set via an Angular binding because
// bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
// string literals, a variable that can only be 'X' or 'Y', and user input that is run through
// the `Number` function first to coerce it to a numeric value.
this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
}

/** Run change detection. */
private _doChangeDetection() {
if (this._isDestroyed) {
Expand All @@ -515,11 +523,6 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
afterNextRender(
() => {
this._isChangeDetectionPending = false;
// Apply the content transform. The transform can't be set via an Angular binding because
// bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
// string literals, a variable that can only be 'X' or 'Y', and user input that is run through
// the `Number` function first to coerce it to a numeric value.
this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
const runAfterChangeDetection = this._runAfterChangeDetection;
this._runAfterChangeDetection = [];
for (const fn of runAfterChangeDetection) {
Expand Down
2 changes: 2 additions & 0 deletions tools/public_api_guard/cdk/scrolling.md
Expand Up @@ -205,6 +205,8 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
// (undocumented)
static ngAcceptInputType_appendOnly: unknown;
// (undocumented)
ngAfterViewChecked(): void;
// (undocumented)
ngOnDestroy(): void;
// (undocumented)
ngOnInit(): void;
Expand Down

0 comments on commit 8bde81f

Please sign in to comment.