MCPcopy Create free account
hub / github.com/angular/angular / runLeaveAnimations

Function runLeaveAnimations

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

Source from the content-addressed store, hash-verified

307}
308
309function runLeaveAnimations(
310 lView: LView,
311 tNode: TNode,
312 value: string | AnimationClassBindingFn,
313 ngZone: NgZone,
314): {promise: Promise<void>; resolve: VoidFunction} {
315 const {promise, resolve} = promiseWithResolvers<void>();
316 const nativeElement = getNativeByTNode(tNode, lView) as Element;
317
318 ngDevMode && assertElementNodes(nativeElement, 'animate.leave');
319
320 const activeClasses = getClassListFromValue(value);
321 if (activeClasses && activeClasses.length > 0) {
322 const renderer = lView[RENDERER];
323 allLeavingAnimations.add(lView[ID]);
324 (getLViewLeaveAnimations(lView).get(tNode.index)!.resolvers ??= []).push(resolve);
325 animateLeaveClassRunner(
326 nativeElement as HTMLElement,
327 tNode,
328 lView,
329 activeClasses,
330 renderer,
331 ngZone,
332 );
333 } else {
334 resolve();
335 }
336
337 return {promise, resolve};
338}
339
340/**
341 * 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
getClassListFromValueFunction · 0.90
getLViewLeaveAnimationsFunction · 0.90
animateLeaveClassRunnerFunction · 0.85
addMethod · 0.65
getMethod · 0.65
resolveFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected