( lView: LView | undefined, tNode: TNode, animations: AnimationLViewData | undefined, nodesWithExitAnimations: Map<number, LeaveNodeAnimations>, callback: Function, )
| 228 | } |
| 229 | |
| 230 | function executeLeaveAnimations( |
| 231 | lView: LView | undefined, |
| 232 | tNode: TNode, |
| 233 | animations: AnimationLViewData | undefined, |
| 234 | nodesWithExitAnimations: Map<number, LeaveNodeAnimations>, |
| 235 | callback: Function, |
| 236 | ) { |
| 237 | // it's possible that in the time between when the leave animation was |
| 238 | // and the time it was executed, the data structure changed. So we need |
| 239 | // to be safe here. |
| 240 | const runningAnimations: Promise<unknown>[] = []; |
| 241 | |
| 242 | if (animations) { |
| 243 | if (animations.leave) { |
| 244 | for (const [index] of nodesWithExitAnimations) { |
| 245 | if (!animations.leave.has(index)) continue; |
| 246 | |
| 247 | const currentAnimationData = animations.leave.get(index)!; |
| 248 | for (const animationFn of currentAnimationData.animateFns) { |
| 249 | const {promise} = animationFn() as ReturnType<RunLeaveAnimationFn>; |
| 250 | runningAnimations.push(promise); |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | animations.detachedLeaveAnimationFns = undefined; |
| 255 | } |
| 256 | |
| 257 | // Also add nested view animations |
| 258 | if (lView) { |
| 259 | collectNestedViewAnimations(lView, tNode, runningAnimations); |
| 260 | } |
| 261 | |
| 262 | if (runningAnimations.length > 0) { |
| 263 | const currentAnimations = animations || lView?.[ANIMATIONS]; |
| 264 | if (currentAnimations) { |
| 265 | const prevRunning = currentAnimations.running; |
| 266 | if (prevRunning) { |
| 267 | runningAnimations.push(prevRunning); |
| 268 | } |
| 269 | currentAnimations.running = Promise.allSettled(runningAnimations); |
| 270 | runAfterLeaveAnimations(lView!, tNode, currentAnimations.running, callback); |
| 271 | } else { |
| 272 | Promise.allSettled(runningAnimations).then(() => { |
| 273 | if (lView) allLeavingAnimations.delete(lView[ID]); |
| 274 | clearTrackedLeavingNode(lView, tNode); |
| 275 | callback(true); |
| 276 | }); |
| 277 | } |
| 278 | } else { |
| 279 | if (lView) allLeavingAnimations.delete(lView[ID]); |
| 280 | clearTrackedLeavingNode(lView, tNode); |
| 281 | callback(false); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Checks whether nested views (containers only, NOT child components) have any leave animations, |
no test coverage detected