MCPcopy
hub / github.com/angular/angular / runLeaveAnimations

Function runLeaveAnimations

packages/core/src/render3/instructions/animation.ts:280–310  ·  view source on GitHub ↗
(
  lView: LView,
  tNode: TNode,
  value: string | AnimationClassBindingFn,
  ngZone: NgZone,
)

Source from the content-addressed store, hash-verified

278}
279
280function runLeaveAnimations(
281 lView: LView,
282 tNode: TNode,
283 value: string | AnimationClassBindingFn,
284 ngZone: NgZone,
285): {promise: Promise<void>; resolve: VoidFunction} {
286 const {promise, resolve} = promiseWithResolvers<void>();
287 const nativeElement = getNativeByTNode(tNode, lView) as Element;
288
289 ngDevMode && assertElementNodes(nativeElement, 'animate.leave');
290
291 const renderer = lView[RENDERER];
292 allLeavingAnimations.add(lView[ID]);
293 (getLViewLeaveAnimations(lView).get(tNode.index)!.resolvers ??= []).push(resolve);
294
295 const activeClasses = getClassListFromValue(value);
296 if (activeClasses && activeClasses.length > 0) {
297 animateLeaveClassRunner(
298 nativeElement as HTMLElement,
299 tNode,
300 lView,
301 activeClasses,
302 renderer,
303 ngZone,
304 );
305 } else {
306 resolve();
307 }
308
309 return {promise, resolve};
310}
311
312/**
313 * This function actually adds the classes that animate element that's leaving the DOM.

Callers 1

ɵɵanimateLeaveFunction · 0.85

Calls 10

promiseWithResolversFunction · 0.90
getNativeByTNodeFunction · 0.90
assertElementNodesFunction · 0.90
getLViewLeaveAnimationsFunction · 0.90
getClassListFromValueFunction · 0.90
animateLeaveClassRunnerFunction · 0.85
addMethod · 0.65
getMethod · 0.65
resolveFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…