Skip to content

Commit

Permalink
fix(animations): Ensure async animations applies changes when loaded …
Browse files Browse the repository at this point in the history
…in zoneless

Async animations currently works in Zones because the render factory
promise resolve causes change detection to happen.

fixes angular#54919
  • Loading branch information
atscott committed Mar 29, 2024
1 parent 7c5879e commit 70aae48
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import {ɵAnimationEngine as AnimationEngine, ɵAnimationRenderer as AnimationRenderer, ɵAnimationRendererFactory as AnimationRendererFactory} from '@angular/animations/browser';
import {inject, Injectable, NgZone, OnDestroy, Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2, ɵAnimationRendererType as AnimationRendererType, ɵChangeDetectionScheduler as ChangeDetectionScheduler, ɵRuntimeError as RuntimeError} from '@angular/core';
import {NotificationType} from '@angular/core/src/change_detection/scheduling/zoneless_scheduling';
import {ɵRuntimeErrorCode as RuntimeErrorCode} from '@angular/platform-browser';

const ANIMATION_PREFIX = '@';
Expand Down Expand Up @@ -103,6 +104,8 @@ export class AsyncAnimationRendererFactory implements OnDestroy, RendererFactory
const animationRenderer =
animationRendererFactory.createRenderer(hostElement, rendererType);
dynamicRenderer.use(animationRenderer);
// Applying animations might result in new DOM state and should rerun render hooks
this.scheduler?.notify(NotificationType.AfterRenderHooks);
})
.catch(e => {
// Permanently use regular renderer when loading fails.
Expand Down

0 comments on commit 70aae48

Please sign in to comment.