@angular/animations 19.2.4 → 19.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.2.4
2
+ * @license Angular v19.2.6
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -7,933 +7,8 @@
7
7
  import { DOCUMENT } from '@angular/common';
8
8
  import * as i0 from '@angular/core';
9
9
  import { inject, ANIMATION_MODULE_TYPE, ViewEncapsulation, ɵRuntimeError as _RuntimeError, Injectable, Inject } from '@angular/core';
10
-
11
- /**
12
- * @description Constants for the categories of parameters that can be defined for animations.
13
- *
14
- * A corresponding function defines a set of parameters for each category, and
15
- * collects them into a corresponding `AnimationMetadata` object.
16
- *
17
- * @publicApi
18
- */
19
- var AnimationMetadataType;
20
- (function (AnimationMetadataType) {
21
- /**
22
- * Associates a named animation state with a set of CSS styles.
23
- * See [`state()`](api/animations/state)
24
- */
25
- AnimationMetadataType[AnimationMetadataType["State"] = 0] = "State";
26
- /**
27
- * Data for a transition from one animation state to another.
28
- * See `transition()`
29
- */
30
- AnimationMetadataType[AnimationMetadataType["Transition"] = 1] = "Transition";
31
- /**
32
- * Contains a set of animation steps.
33
- * See `sequence()`
34
- */
35
- AnimationMetadataType[AnimationMetadataType["Sequence"] = 2] = "Sequence";
36
- /**
37
- * Contains a set of animation steps.
38
- * See `{@link /api/animations/group group()}`
39
- */
40
- AnimationMetadataType[AnimationMetadataType["Group"] = 3] = "Group";
41
- /**
42
- * Contains an animation step.
43
- * See `animate()`
44
- */
45
- AnimationMetadataType[AnimationMetadataType["Animate"] = 4] = "Animate";
46
- /**
47
- * Contains a set of animation steps.
48
- * See `keyframes()`
49
- */
50
- AnimationMetadataType[AnimationMetadataType["Keyframes"] = 5] = "Keyframes";
51
- /**
52
- * Contains a set of CSS property-value pairs into a named style.
53
- * See `style()`
54
- */
55
- AnimationMetadataType[AnimationMetadataType["Style"] = 6] = "Style";
56
- /**
57
- * Associates an animation with an entry trigger that can be attached to an element.
58
- * See `trigger()`
59
- */
60
- AnimationMetadataType[AnimationMetadataType["Trigger"] = 7] = "Trigger";
61
- /**
62
- * Contains a re-usable animation.
63
- * See `animation()`
64
- */
65
- AnimationMetadataType[AnimationMetadataType["Reference"] = 8] = "Reference";
66
- /**
67
- * Contains data to use in executing child animations returned by a query.
68
- * See `animateChild()`
69
- */
70
- AnimationMetadataType[AnimationMetadataType["AnimateChild"] = 9] = "AnimateChild";
71
- /**
72
- * Contains animation parameters for a re-usable animation.
73
- * See `useAnimation()`
74
- */
75
- AnimationMetadataType[AnimationMetadataType["AnimateRef"] = 10] = "AnimateRef";
76
- /**
77
- * Contains child-animation query data.
78
- * See `query()`
79
- */
80
- AnimationMetadataType[AnimationMetadataType["Query"] = 11] = "Query";
81
- /**
82
- * Contains data for staggering an animation sequence.
83
- * See `stagger()`
84
- */
85
- AnimationMetadataType[AnimationMetadataType["Stagger"] = 12] = "Stagger";
86
- })(AnimationMetadataType || (AnimationMetadataType = {}));
87
- /**
88
- * Specifies automatic styling.
89
- *
90
- * @publicApi
91
- */
92
- const AUTO_STYLE = '*';
93
- /**
94
- * Creates a named animation trigger, containing a list of [`state()`](api/animations/state)
95
- * and `transition()` entries to be evaluated when the expression
96
- * bound to the trigger changes.
97
- *
98
- * @param name An identifying string.
99
- * @param definitions An animation definition object, containing an array of
100
- * [`state()`](api/animations/state) and `transition()` declarations.
101
- *
102
- * @return An object that encapsulates the trigger data.
103
- *
104
- * @usageNotes
105
- * Define an animation trigger in the `animations` section of `@Component` metadata.
106
- * In the template, reference the trigger by name and bind it to a trigger expression that
107
- * evaluates to a defined animation state, using the following format:
108
- *
109
- * `[@triggerName]="expression"`
110
- *
111
- * Animation trigger bindings convert all values to strings, and then match the
112
- * previous and current values against any linked transitions.
113
- * Booleans can be specified as `1` or `true` and `0` or `false`.
114
- *
115
- * ### Usage Example
116
- *
117
- * The following example creates an animation trigger reference based on the provided
118
- * name value.
119
- * The provided animation value is expected to be an array consisting of state and
120
- * transition declarations.
121
- *
122
- * ```ts
123
- * @Component({
124
- * selector: "my-component",
125
- * templateUrl: "my-component-tpl.html",
126
- * animations: [
127
- * trigger("myAnimationTrigger", [
128
- * state(...),
129
- * state(...),
130
- * transition(...),
131
- * transition(...)
132
- * ])
133
- * ]
134
- * })
135
- * class MyComponent {
136
- * myStatusExp = "something";
137
- * }
138
- * ```
139
- *
140
- * The template associated with this component makes use of the defined trigger
141
- * by binding to an element within its template code.
142
- *
143
- * ```html
144
- * <!-- somewhere inside of my-component-tpl.html -->
145
- * <div [@myAnimationTrigger]="myStatusExp">...</div>
146
- * ```
147
- *
148
- * ### Using an inline function
149
- * The `transition` animation method also supports reading an inline function which can decide
150
- * if its associated animation should be run.
151
- *
152
- * ```ts
153
- * // this method is run each time the `myAnimationTrigger` trigger value changes.
154
- * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
155
- string]: any}): boolean {
156
- * // notice that `element` and `params` are also available here
157
- * return toState == 'yes-please-animate';
158
- * }
159
- *
160
- * @Component({
161
- * selector: 'my-component',
162
- * templateUrl: 'my-component-tpl.html',
163
- * animations: [
164
- * trigger('myAnimationTrigger', [
165
- * transition(myInlineMatcherFn, [
166
- * // the animation sequence code
167
- * ]),
168
- * ])
169
- * ]
170
- * })
171
- * class MyComponent {
172
- * myStatusExp = "yes-please-animate";
173
- * }
174
- * ```
175
- *
176
- * ### Disabling Animations
177
- * When true, the special animation control binding `@.disabled` binding prevents
178
- * all animations from rendering.
179
- * Place the `@.disabled` binding on an element to disable
180
- * animations on the element itself, as well as any inner animation triggers
181
- * within the element.
182
- *
183
- * The following example shows how to use this feature:
184
- *
185
- * ```angular-ts
186
- * @Component({
187
- * selector: 'my-component',
188
- * template: `
189
- * <div [@.disabled]="isDisabled">
190
- * <div [@childAnimation]="exp"></div>
191
- * </div>
192
- * `,
193
- * animations: [
194
- * trigger("childAnimation", [
195
- * // ...
196
- * ])
197
- * ]
198
- * })
199
- * class MyComponent {
200
- * isDisabled = true;
201
- * exp = '...';
202
- * }
203
- * ```
204
- *
205
- * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,
206
- * along with any inner animations.
207
- *
208
- * ### Disable animations application-wide
209
- * When an area of the template is set to have animations disabled,
210
- * **all** inner components have their animations disabled as well.
211
- * This means that you can disable all animations for an app
212
- * by placing a host binding set on `@.disabled` on the topmost Angular component.
213
- *
214
- * ```ts
215
- * import {Component, HostBinding} from '@angular/core';
216
- *
217
- * @Component({
218
- * selector: 'app-component',
219
- * templateUrl: 'app.component.html',
220
- * })
221
- * class AppComponent {
222
- * @HostBinding('@.disabled')
223
- * public animationsDisabled = true;
224
- * }
225
- * ```
226
- *
227
- * ### Overriding disablement of inner animations
228
- * Despite inner animations being disabled, a parent animation can `query()`
229
- * for inner elements located in disabled areas of the template and still animate
230
- * them if needed. This is also the case for when a sub animation is
231
- * queried by a parent and then later animated using `animateChild()`.
232
- *
233
- * ### Detecting when an animation is disabled
234
- * If a region of the DOM (or the entire application) has its animations disabled, the animation
235
- * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
236
- * an instance of an `AnimationEvent`. If animations are disabled,
237
- * the `.disabled` flag on the event is true.
238
- *
239
- * @publicApi
240
- */
241
- function trigger(name, definitions) {
242
- return { type: AnimationMetadataType.Trigger, name, definitions, options: {} };
243
- }
244
- /**
245
- * Defines an animation step that combines styling information with timing information.
246
- *
247
- * @param timings Sets `AnimateTimings` for the parent animation.
248
- * A string in the format "duration [delay] [easing]".
249
- * - Duration and delay are expressed as a number and optional time unit,
250
- * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
251
- * The default unit is milliseconds.
252
- * - The easing value controls how the animation accelerates and decelerates
253
- * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
254
- * `ease-in-out`, or a `cubic-bezier()` function call.
255
- * If not supplied, no easing is applied.
256
- *
257
- * For example, the string "1s 100ms ease-out" specifies a duration of
258
- * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
259
- * which decelerates near the end of the duration.
260
- * @param styles Sets AnimationStyles for the parent animation.
261
- * A function call to either `style()` or `keyframes()`
262
- * that returns a collection of CSS style entries to be applied to the parent animation.
263
- * When null, uses the styles from the destination state.
264
- * This is useful when describing an animation step that will complete an animation;
265
- * see "Animating to the final state" in `transitions()`.
266
- * @returns An object that encapsulates the animation step.
267
- *
268
- * @usageNotes
269
- * Call within an animation `sequence()`, {@link /api/animations/group group()}, or
270
- * `transition()` call to specify an animation step
271
- * that applies given style data to the parent animation for a given amount of time.
272
- *
273
- * ### Syntax Examples
274
- * **Timing examples**
275
- *
276
- * The following examples show various `timings` specifications.
277
- * - `animate(500)` : Duration is 500 milliseconds.
278
- * - `animate("1s")` : Duration is 1000 milliseconds.
279
- * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
280
- * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
281
- * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
282
- * milliseconds, easing according to a bezier curve.
283
- *
284
- * **Style examples**
285
- *
286
- * The following example calls `style()` to set a single CSS style.
287
- * ```ts
288
- * animate(500, style({ background: "red" }))
289
- * ```
290
- * The following example calls `keyframes()` to set a CSS style
291
- * to different values for successive keyframes.
292
- * ```ts
293
- * animate(500, keyframes(
294
- * [
295
- * style({ background: "blue" }),
296
- * style({ background: "red" })
297
- * ])
298
- * ```
299
- *
300
- * @publicApi
301
- */
302
- function animate(timings, styles = null) {
303
- return { type: AnimationMetadataType.Animate, styles, timings };
304
- }
305
- /**
306
- * @description Defines a list of animation steps to be run in parallel.
307
- *
308
- * @param steps An array of animation step objects.
309
- * - When steps are defined by `style()` or `animate()`
310
- * function calls, each call within the group is executed instantly.
311
- * - To specify offset styles to be applied at a later time, define steps with
312
- * `keyframes()`, or use `animate()` calls with a delay value.
313
- * For example:
314
- *
315
- * ```ts
316
- * group([
317
- * animate("1s", style({ background: "black" })),
318
- * animate("2s", style({ color: "white" }))
319
- * ])
320
- * ```
321
- *
322
- * @param options An options object containing a delay and
323
- * developer-defined parameters that provide styling defaults and
324
- * can be overridden on invocation.
325
- *
326
- * @return An object that encapsulates the group data.
327
- *
328
- * @usageNotes
329
- * Grouped animations are useful when a series of styles must be
330
- * animated at different starting times and closed off at different ending times.
331
- *
332
- * When called within a `sequence()` or a
333
- * `transition()` call, does not continue to the next
334
- * instruction until all of the inner animation steps have completed.
335
- *
336
- * @publicApi
337
- */
338
- function group(steps, options = null) {
339
- return { type: AnimationMetadataType.Group, steps, options };
340
- }
341
- /**
342
- * Defines a list of animation steps to be run sequentially, one by one.
343
- *
344
- * @param steps An array of animation step objects.
345
- * - Steps defined by `style()` calls apply the styling data immediately.
346
- * - Steps defined by `animate()` calls apply the styling data over time
347
- * as specified by the timing data.
348
- *
349
- * ```ts
350
- * sequence([
351
- * style({ opacity: 0 }),
352
- * animate("1s", style({ opacity: 1 }))
353
- * ])
354
- * ```
355
- *
356
- * @param options An options object containing a delay and
357
- * developer-defined parameters that provide styling defaults and
358
- * can be overridden on invocation.
359
- *
360
- * @return An object that encapsulates the sequence data.
361
- *
362
- * @usageNotes
363
- * When you pass an array of steps to a
364
- * `transition()` call, the steps run sequentially by default.
365
- * Compare this to the {@link /api/animations/group group()} call, which runs animation steps in
366
- *parallel.
367
- *
368
- * When a sequence is used within a {@link /api/animations/group group()} or a `transition()` call,
369
- * execution continues to the next instruction only after each of the inner animation
370
- * steps have completed.
371
- *
372
- * @publicApi
373
- **/
374
- function sequence(steps, options = null) {
375
- return { type: AnimationMetadataType.Sequence, steps, options };
376
- }
377
- /**
378
- * Declares a key/value object containing CSS properties/styles that
379
- * can then be used for an animation [`state`](api/animations/state), within an animation
380
- *`sequence`, or as styling data for calls to `animate()` and `keyframes()`.
381
- *
382
- * @param tokens A set of CSS styles or HTML styles associated with an animation state.
383
- * The value can be any of the following:
384
- * - A key-value style pair associating a CSS property with a value.
385
- * - An array of key-value style pairs.
386
- * - An asterisk (*), to use auto-styling, where styles are derived from the element
387
- * being animated and applied to the animation when it starts.
388
- *
389
- * Auto-styling can be used to define a state that depends on layout or other
390
- * environmental factors.
391
- *
392
- * @return An object that encapsulates the style data.
393
- *
394
- * @usageNotes
395
- * The following examples create animation styles that collect a set of
396
- * CSS property values:
397
- *
398
- * ```ts
399
- * // string values for CSS properties
400
- * style({ background: "red", color: "blue" })
401
- *
402
- * // numerical pixel values
403
- * style({ width: 100, height: 0 })
404
- * ```
405
- *
406
- * The following example uses auto-styling to allow an element to animate from
407
- * a height of 0 up to its full height:
408
- *
409
- * ```ts
410
- * style({ height: 0 }),
411
- * animate("1s", style({ height: "*" }))
412
- * ```
413
- *
414
- * @publicApi
415
- **/
416
- function style(tokens) {
417
- return { type: AnimationMetadataType.Style, styles: tokens, offset: null };
418
- }
419
- /**
420
- * Declares an animation state within a trigger attached to an element.
421
- *
422
- * @param name One or more names for the defined state in a comma-separated string.
423
- * The following reserved state names can be supplied to define a style for specific use
424
- * cases:
425
- *
426
- * - `void` You can associate styles with this name to be used when
427
- * the element is detached from the application. For example, when an `ngIf` evaluates
428
- * to false, the state of the associated element is void.
429
- * - `*` (asterisk) Indicates the default state. You can associate styles with this name
430
- * to be used as the fallback when the state that is being animated is not declared
431
- * within the trigger.
432
- *
433
- * @param styles A set of CSS styles associated with this state, created using the
434
- * `style()` function.
435
- * This set of styles persists on the element once the state has been reached.
436
- * @param options Parameters that can be passed to the state when it is invoked.
437
- * 0 or more key-value pairs.
438
- * @return An object that encapsulates the new state data.
439
- *
440
- * @usageNotes
441
- * Use the `trigger()` function to register states to an animation trigger.
442
- * Use the `transition()` function to animate between states.
443
- * When a state is active within a component, its associated styles persist on the element,
444
- * even when the animation ends.
445
- *
446
- * @publicApi
447
- **/
448
- function state(name, styles, options) {
449
- return { type: AnimationMetadataType.State, name, styles, options };
450
- }
451
- /**
452
- * Defines a set of animation styles, associating each style with an optional `offset` value.
453
- *
454
- * @param steps A set of animation styles with optional offset data.
455
- * The optional `offset` value for a style specifies a percentage of the total animation
456
- * time at which that style is applied.
457
- * @returns An object that encapsulates the keyframes data.
458
- *
459
- * @usageNotes
460
- * Use with the `animate()` call. Instead of applying animations
461
- * from the current state
462
- * to the destination state, keyframes describe how each style entry is applied and at what point
463
- * within the animation arc.
464
- * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
465
- *
466
- * ### Usage
467
- *
468
- * In the following example, the offset values describe
469
- * when each `backgroundColor` value is applied. The color is red at the start, and changes to
470
- * blue when 20% of the total time has elapsed.
471
- *
472
- * ```ts
473
- * // the provided offset values
474
- * animate("5s", keyframes([
475
- * style({ backgroundColor: "red", offset: 0 }),
476
- * style({ backgroundColor: "blue", offset: 0.2 }),
477
- * style({ backgroundColor: "orange", offset: 0.3 }),
478
- * style({ backgroundColor: "black", offset: 1 })
479
- * ]))
480
- * ```
481
- *
482
- * If there are no `offset` values specified in the style entries, the offsets
483
- * are calculated automatically.
484
- *
485
- * ```ts
486
- * animate("5s", keyframes([
487
- * style({ backgroundColor: "red" }) // offset = 0
488
- * style({ backgroundColor: "blue" }) // offset = 0.33
489
- * style({ backgroundColor: "orange" }) // offset = 0.66
490
- * style({ backgroundColor: "black" }) // offset = 1
491
- * ]))
492
- *```
493
-
494
- * @publicApi
495
- */
496
- function keyframes(steps) {
497
- return { type: AnimationMetadataType.Keyframes, steps };
498
- }
499
- /**
500
- * Declares an animation transition which is played when a certain specified condition is met.
501
- *
502
- * @param stateChangeExpr A string with a specific format or a function that specifies when the
503
- * animation transition should occur (see [State Change Expression](#state-change-expression)).
504
- *
505
- * @param steps One or more animation objects that represent the animation's instructions.
506
- *
507
- * @param options An options object that can be used to specify a delay for the animation or provide
508
- * custom parameters for it.
509
- *
510
- * @returns An object that encapsulates the transition data.
511
- *
512
- * @usageNotes
513
- *
514
- * ### State Change Expression
515
- *
516
- * The State Change Expression instructs Angular when to run the transition's animations, it can
517
- *either be
518
- * - a string with a specific syntax
519
- * - or a function that compares the previous and current state (value of the expression bound to
520
- * the element's trigger) and returns `true` if the transition should occur or `false` otherwise
521
- *
522
- * The string format can be:
523
- * - `fromState => toState`, which indicates that the transition's animations should occur then the
524
- * expression bound to the trigger's element goes from `fromState` to `toState`
525
- *
526
- * _Example:_
527
- * ```ts
528
- * transition('open => closed', animate('.5s ease-out', style({ height: 0 }) ))
529
- * ```
530
- *
531
- * - `fromState <=> toState`, which indicates that the transition's animations should occur then
532
- * the expression bound to the trigger's element goes from `fromState` to `toState` or vice versa
533
- *
534
- * _Example:_
535
- * ```ts
536
- * transition('enabled <=> disabled', animate('1s cubic-bezier(0.8,0.3,0,1)'))
537
- * ```
538
- *
539
- * - `:enter`/`:leave`, which indicates that the transition's animations should occur when the
540
- * element enters or exists the DOM
541
- *
542
- * _Example:_
543
- * ```ts
544
- * transition(':enter', [
545
- * style({ opacity: 0 }),
546
- * animate('500ms', style({ opacity: 1 }))
547
- * ])
548
- * ```
549
- *
550
- * - `:increment`/`:decrement`, which indicates that the transition's animations should occur when
551
- * the numerical expression bound to the trigger's element has increased in value or decreased
552
- *
553
- * _Example:_
554
- * ```ts
555
- * transition(':increment', query('@counter', animateChild()))
556
- * ```
557
- *
558
- * - a sequence of any of the above divided by commas, which indicates that transition's animations
559
- * should occur whenever one of the state change expressions matches
560
- *
561
- * _Example:_
562
- * ```ts
563
- * transition(':increment, * => enabled, :enter', animate('1s ease', keyframes([
564
- * style({ transform: 'scale(1)', offset: 0}),
565
- * style({ transform: 'scale(1.1)', offset: 0.7}),
566
- * style({ transform: 'scale(1)', offset: 1})
567
- * ]))),
568
- * ```
569
- *
570
- * Also note that in such context:
571
- * - `void` can be used to indicate the absence of the element
572
- * - asterisks can be used as wildcards that match any state
573
- * - (as a consequence of the above, `void => *` is equivalent to `:enter` and `* => void` is
574
- * equivalent to `:leave`)
575
- * - `true` and `false` also match expression values of `1` and `0` respectively (but do not match
576
- * _truthy_ and _falsy_ values)
577
- *
578
- * <div class="docs-alert docs-alert-helpful">
579
- *
580
- * Be careful about entering end leaving elements as their transitions present a common
581
- * pitfall for developers.
582
- *
583
- * Note that when an element with a trigger enters the DOM its `:enter` transition always
584
- * gets executed, but its `:leave` transition will not be executed if the element is removed
585
- * alongside its parent (as it will be removed "without warning" before its transition has
586
- * a chance to be executed, the only way that such transition can occur is if the element
587
- * is exiting the DOM on its own).
588
- *
589
- *
590
- * </div>
591
- *
592
- * ### Animating to a Final State
593
- *
594
- * If the final step in a transition is a call to `animate()` that uses a timing value
595
- * with no `style` data, that step is automatically considered the final animation arc,
596
- * for the element to reach the final state, in such case Angular automatically adds or removes
597
- * CSS styles to ensure that the element is in the correct final state.
598
- *
599
- *
600
- * ### Usage Examples
601
- *
602
- * - Transition animations applied based on
603
- * the trigger's expression value
604
- *
605
- * ```html
606
- * <div [@myAnimationTrigger]="myStatusExp">
607
- * ...
608
- * </div>
609
- * ```
610
- *
611
- * ```ts
612
- * trigger("myAnimationTrigger", [
613
- * ..., // states
614
- * transition("on => off, open => closed", animate(500)),
615
- * transition("* <=> error", query('.indicator', animateChild()))
616
- * ])
617
- * ```
618
- *
619
- * - Transition animations applied based on custom logic dependent
620
- * on the trigger's expression value and provided parameters
621
- *
622
- * ```html
623
- * <div [@myAnimationTrigger]="{
624
- * value: stepName,
625
- * params: { target: currentTarget }
626
- * }">
627
- * ...
628
- * </div>
629
- * ```
630
- *
631
- * ```ts
632
- * trigger("myAnimationTrigger", [
633
- * ..., // states
634
- * transition(
635
- * (fromState, toState, _element, params) =>
636
- * ['firststep', 'laststep'].includes(fromState.toLowerCase())
637
- * && toState === params?.['target'],
638
- * animate('1s')
639
- * )
640
- * ])
641
- * ```
642
- *
643
- * @publicApi
644
- **/
645
- function transition(stateChangeExpr, steps, options = null) {
646
- return { type: AnimationMetadataType.Transition, expr: stateChangeExpr, animation: steps, options };
647
- }
648
- /**
649
- * Produces a reusable animation that can be invoked in another animation or sequence,
650
- * by calling the `useAnimation()` function.
651
- *
652
- * @param steps One or more animation objects, as returned by the `animate()`
653
- * or `sequence()` function, that form a transformation from one state to another.
654
- * A sequence is used by default when you pass an array.
655
- * @param options An options object that can contain a delay value for the start of the
656
- * animation, and additional developer-defined parameters.
657
- * Provided values for additional parameters are used as defaults,
658
- * and override values can be passed to the caller on invocation.
659
- * @returns An object that encapsulates the animation data.
660
- *
661
- * @usageNotes
662
- * The following example defines a reusable animation, providing some default parameter
663
- * values.
664
- *
665
- * ```ts
666
- * var fadeAnimation = animation([
667
- * style({ opacity: '{{ start }}' }),
668
- * animate('{{ time }}',
669
- * style({ opacity: '{{ end }}'}))
670
- * ],
671
- * { params: { time: '1000ms', start: 0, end: 1 }});
672
- * ```
673
- *
674
- * The following invokes the defined animation with a call to `useAnimation()`,
675
- * passing in override parameter values.
676
- *
677
- * ```js
678
- * useAnimation(fadeAnimation, {
679
- * params: {
680
- * time: '2s',
681
- * start: 1,
682
- * end: 0
683
- * }
684
- * })
685
- * ```
686
- *
687
- * If any of the passed-in parameter values are missing from this call,
688
- * the default values are used. If one or more parameter values are missing before a step is
689
- * animated, `useAnimation()` throws an error.
690
- *
691
- * @publicApi
692
- */
693
- function animation(steps, options = null) {
694
- return { type: AnimationMetadataType.Reference, animation: steps, options };
695
- }
696
- /**
697
- * Executes a queried inner animation element within an animation sequence.
698
- *
699
- * @param options An options object that can contain a delay value for the start of the
700
- * animation, and additional override values for developer-defined parameters.
701
- * @return An object that encapsulates the child animation data.
702
- *
703
- * @usageNotes
704
- * Each time an animation is triggered in Angular, the parent animation
705
- * has priority and any child animations are blocked. In order
706
- * for a child animation to run, the parent animation must query each of the elements
707
- * containing child animations, and run them using this function.
708
- *
709
- * Note that this feature is designed to be used with `query()` and it will only work
710
- * with animations that are assigned using the Angular animation library. CSS keyframes
711
- * and transitions are not handled by this API.
712
- *
713
- * @publicApi
714
- */
715
- function animateChild(options = null) {
716
- return { type: AnimationMetadataType.AnimateChild, options };
717
- }
718
- /**
719
- * Starts a reusable animation that is created using the `animation()` function.
720
- *
721
- * @param animation The reusable animation to start.
722
- * @param options An options object that can contain a delay value for the start of
723
- * the animation, and additional override values for developer-defined parameters.
724
- * @return An object that contains the animation parameters.
725
- *
726
- * @publicApi
727
- */
728
- function useAnimation(animation, options = null) {
729
- return { type: AnimationMetadataType.AnimateRef, animation, options };
730
- }
731
- /**
732
- * Finds one or more inner elements within the current element that is
733
- * being animated within a sequence. Use with `animate()`.
734
- *
735
- * @param selector The element to query, or a set of elements that contain Angular-specific
736
- * characteristics, specified with one or more of the following tokens.
737
- * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements (not
738
- * all elements can be queried via these tokens, see
739
- * [Entering and Leaving Elements](#entering-and-leaving-elements))
740
- * - `query(":animating")` : Query all currently animating elements.
741
- * - `query("@triggerName")` : Query elements that contain an animation trigger.
742
- * - `query("@*")` : Query all elements that contain an animation triggers.
743
- * - `query(":self")` : Include the current element into the animation sequence.
744
- *
745
- * @param animation One or more animation steps to apply to the queried element or elements.
746
- * An array is treated as an animation sequence.
747
- * @param options An options object. Use the 'limit' field to limit the total number of
748
- * items to collect.
749
- * @return An object that encapsulates the query data.
750
- *
751
- * @usageNotes
752
- *
753
- * ### Multiple Tokens
754
- *
755
- * Tokens can be merged into a combined query selector string. For example:
756
- *
757
- * ```ts
758
- * query(':self, .record:enter, .record:leave, @subTrigger', [...])
759
- * ```
760
- *
761
- * The `query()` function collects multiple elements and works internally by using
762
- * `element.querySelectorAll`. Use the `limit` field of an options object to limit
763
- * the total number of items to be collected. For example:
764
- *
765
- * ```js
766
- * query('div', [
767
- * animate(...),
768
- * animate(...)
769
- * ], { limit: 1 })
770
- * ```
771
- *
772
- * By default, throws an error when zero items are found. Set the
773
- * `optional` flag to ignore this error. For example:
774
- *
775
- * ```js
776
- * query('.some-element-that-may-not-be-there', [
777
- * animate(...),
778
- * animate(...)
779
- * ], { optional: true })
780
- * ```
781
- *
782
- * ### Entering and Leaving Elements
783
- *
784
- * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones
785
- * that can are those that Angular assumes can enter/leave based on their own logic
786
- * (if their insertion/removal is simply a consequence of that of their parent they
787
- * should be queried via a different token in their parent's `:enter`/`:leave` transitions).
788
- *
789
- * The only elements Angular assumes can enter/leave based on their own logic (thus the only
790
- * ones that can be queried via the `:enter` and `:leave` tokens) are:
791
- * - Those inserted dynamically (via `ViewContainerRef`)
792
- * - Those that have a structural directive (which, under the hood, are a subset of the above ones)
793
- *
794
- * <div class="docs-alert docs-alert-helpful">
795
- *
796
- * Note that elements will be successfully queried via `:enter`/`:leave` even if their
797
- * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural
798
- * directive (e.g. they enter/exit alongside their parent).
799
- *
800
- * </div>
801
- *
802
- * <div class="docs-alert docs-alert-important">
803
- *
804
- * There is an exception to what previously mentioned, besides elements entering/leaving based on
805
- * their own logic, elements with an animation trigger can always be queried via `:leave` when
806
- * their parent is also leaving.
807
- *
808
- * </div>
809
- *
810
- * ### Usage Example
811
- *
812
- * The following example queries for inner elements and animates them
813
- * individually using `animate()`.
814
- *
815
- * ```angular-ts
816
- * @Component({
817
- * selector: 'inner',
818
- * template: `
819
- * <div [@queryAnimation]="exp">
820
- * <h1>Title</h1>
821
- * <div class="content">
822
- * Blah blah blah
823
- * </div>
824
- * </div>
825
- * `,
826
- * animations: [
827
- * trigger('queryAnimation', [
828
- * transition('* => goAnimate', [
829
- * // hide the inner elements
830
- * query('h1', style({ opacity: 0 })),
831
- * query('.content', style({ opacity: 0 })),
832
- *
833
- * // animate the inner elements in, one by one
834
- * query('h1', animate(1000, style({ opacity: 1 }))),
835
- * query('.content', animate(1000, style({ opacity: 1 }))),
836
- * ])
837
- * ])
838
- * ]
839
- * })
840
- * class Cmp {
841
- * exp = '';
842
- *
843
- * goAnimate() {
844
- * this.exp = 'goAnimate';
845
- * }
846
- * }
847
- * ```
848
- *
849
- * @publicApi
850
- */
851
- function query(selector, animation, options = null) {
852
- return { type: AnimationMetadataType.Query, selector, animation, options };
853
- }
854
- /**
855
- * Use within an animation `query()` call to issue a timing gap after
856
- * each queried item is animated.
857
- *
858
- * @param timings A delay value.
859
- * @param animation One ore more animation steps.
860
- * @returns An object that encapsulates the stagger data.
861
- *
862
- * @usageNotes
863
- * In the following example, a container element wraps a list of items stamped out
864
- * by an `ngFor`. The container element contains an animation trigger that will later be set
865
- * to query for each of the inner items.
866
- *
867
- * Each time items are added, the opacity fade-in animation runs,
868
- * and each removed item is faded out.
869
- * When either of these animations occur, the stagger effect is
870
- * applied after each item's animation is started.
871
- *
872
- * ```html
873
- * <!-- list.component.html -->
874
- * <button (click)="toggle()">Show / Hide Items</button>
875
- * <hr />
876
- * <div [@listAnimation]="items.length">
877
- * <div *ngFor="let item of items">
878
- * {{ item }}
879
- * </div>
880
- * </div>
881
- * ```
882
- *
883
- * Here is the component code:
884
- *
885
- * ```ts
886
- * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';
887
- * @Component({
888
- * templateUrl: 'list.component.html',
889
- * animations: [
890
- * trigger('listAnimation', [
891
- * ...
892
- * ])
893
- * ]
894
- * })
895
- * class ListComponent {
896
- * items = [];
897
- *
898
- * showItems() {
899
- * this.items = [0,1,2,3,4];
900
- * }
901
- *
902
- * hideItems() {
903
- * this.items = [];
904
- * }
905
- *
906
- * toggle() {
907
- * this.items.length ? this.hideItems() : this.showItems();
908
- * }
909
- * }
910
- * ```
911
- *
912
- * Here is the animation trigger code:
913
- *
914
- * ```ts
915
- * trigger('listAnimation', [
916
- * transition('* => *', [ // each time the binding value changes
917
- * query(':leave', [
918
- * stagger(100, [
919
- * animate('0.5s', style({ opacity: 0 }))
920
- * ])
921
- * ]),
922
- * query(':enter', [
923
- * style({ opacity: 0 }),
924
- * stagger(100, [
925
- * animate('0.5s', style({ opacity: 1 }))
926
- * ])
927
- * ])
928
- * ])
929
- * ])
930
- * ```
931
- *
932
- * @publicApi
933
- */
934
- function stagger(timings, animation) {
935
- return { type: AnimationMetadataType.Stagger, timings, animation };
936
- }
10
+ import { sequence } from './private_export-CacKMzxJ.mjs';
11
+ export { AUTO_STYLE, AnimationMetadataType, NoopAnimationPlayer, animate, animateChild, animation, group, keyframes, query, stagger, state, style, transition, trigger, useAnimation, AnimationGroupPlayer as ɵAnimationGroupPlayer, ɵPRE_STYLE } from './private_export-CacKMzxJ.mjs';
937
12
 
938
13
  /**
939
14
  * An injectable service that produces an animation sequence programmatically within an
@@ -982,10 +57,10 @@ function stagger(timings, animation) {
982
57
  * @publicApi
983
58
  */
984
59
  class AnimationBuilder {
985
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: AnimationBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
986
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: AnimationBuilder, providedIn: 'root', useFactory: () => inject(BrowserAnimationBuilder) });
60
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AnimationBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
61
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AnimationBuilder, providedIn: 'root', useFactory: () => inject(BrowserAnimationBuilder) });
987
62
  }
988
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: AnimationBuilder, decorators: [{
63
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AnimationBuilder, decorators: [{
989
64
  type: Injectable,
990
65
  args: [{ providedIn: 'root', useFactory: () => inject(BrowserAnimationBuilder) }]
991
66
  }] });
@@ -1025,10 +100,10 @@ class BrowserAnimationBuilder extends AnimationBuilder {
1025
100
  issueAnimationCommand(this._renderer, null, id, 'register', [entry]);
1026
101
  return new BrowserAnimationFactory(id, this._renderer);
1027
102
  }
1028
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: BrowserAnimationBuilder, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
1029
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: BrowserAnimationBuilder, providedIn: 'root' });
103
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: BrowserAnimationBuilder, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
104
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: BrowserAnimationBuilder, providedIn: 'root' });
1030
105
  }
1031
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: BrowserAnimationBuilder, decorators: [{
106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: BrowserAnimationBuilder, decorators: [{
1032
107
  type: Injectable,
1033
108
  args: [{ providedIn: 'root' }]
1034
109
  }], ctorParameters: () => [{ type: i0.RendererFactory2 }, { type: Document, decorators: [{
@@ -1130,246 +205,5 @@ function isAnimationRenderer(renderer) {
1130
205
  return type === 0 /* AnimationRendererType.Regular */ || type === 1 /* AnimationRendererType.Delegated */;
1131
206
  }
1132
207
 
1133
- /**
1134
- * An empty programmatic controller for reusable animations.
1135
- * Used internally when animations are disabled, to avoid
1136
- * checking for the null case when an animation player is expected.
1137
- *
1138
- * @see {@link animate}
1139
- * @see {@link AnimationPlayer}
1140
- *
1141
- * @publicApi
1142
- */
1143
- class NoopAnimationPlayer {
1144
- _onDoneFns = [];
1145
- _onStartFns = [];
1146
- _onDestroyFns = [];
1147
- _originalOnDoneFns = [];
1148
- _originalOnStartFns = [];
1149
- _started = false;
1150
- _destroyed = false;
1151
- _finished = false;
1152
- _position = 0;
1153
- parentPlayer = null;
1154
- totalTime;
1155
- constructor(duration = 0, delay = 0) {
1156
- this.totalTime = duration + delay;
1157
- }
1158
- _onFinish() {
1159
- if (!this._finished) {
1160
- this._finished = true;
1161
- this._onDoneFns.forEach((fn) => fn());
1162
- this._onDoneFns = [];
1163
- }
1164
- }
1165
- onStart(fn) {
1166
- this._originalOnStartFns.push(fn);
1167
- this._onStartFns.push(fn);
1168
- }
1169
- onDone(fn) {
1170
- this._originalOnDoneFns.push(fn);
1171
- this._onDoneFns.push(fn);
1172
- }
1173
- onDestroy(fn) {
1174
- this._onDestroyFns.push(fn);
1175
- }
1176
- hasStarted() {
1177
- return this._started;
1178
- }
1179
- init() { }
1180
- play() {
1181
- if (!this.hasStarted()) {
1182
- this._onStart();
1183
- this.triggerMicrotask();
1184
- }
1185
- this._started = true;
1186
- }
1187
- /** @internal */
1188
- triggerMicrotask() {
1189
- queueMicrotask(() => this._onFinish());
1190
- }
1191
- _onStart() {
1192
- this._onStartFns.forEach((fn) => fn());
1193
- this._onStartFns = [];
1194
- }
1195
- pause() { }
1196
- restart() { }
1197
- finish() {
1198
- this._onFinish();
1199
- }
1200
- destroy() {
1201
- if (!this._destroyed) {
1202
- this._destroyed = true;
1203
- if (!this.hasStarted()) {
1204
- this._onStart();
1205
- }
1206
- this.finish();
1207
- this._onDestroyFns.forEach((fn) => fn());
1208
- this._onDestroyFns = [];
1209
- }
1210
- }
1211
- reset() {
1212
- this._started = false;
1213
- this._finished = false;
1214
- this._onStartFns = this._originalOnStartFns;
1215
- this._onDoneFns = this._originalOnDoneFns;
1216
- }
1217
- setPosition(position) {
1218
- this._position = this.totalTime ? position * this.totalTime : 1;
1219
- }
1220
- getPosition() {
1221
- return this.totalTime ? this._position / this.totalTime : 1;
1222
- }
1223
- /** @internal */
1224
- triggerCallback(phaseName) {
1225
- const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
1226
- methods.forEach((fn) => fn());
1227
- methods.length = 0;
1228
- }
1229
- }
1230
-
1231
- /**
1232
- * A programmatic controller for a group of reusable animations.
1233
- * Used internally to control animations.
1234
- *
1235
- * @see {@link AnimationPlayer}
1236
- * @see {@link animations/group group}
1237
- *
1238
- */
1239
- class AnimationGroupPlayer {
1240
- _onDoneFns = [];
1241
- _onStartFns = [];
1242
- _finished = false;
1243
- _started = false;
1244
- _destroyed = false;
1245
- _onDestroyFns = [];
1246
- parentPlayer = null;
1247
- totalTime = 0;
1248
- players;
1249
- constructor(_players) {
1250
- this.players = _players;
1251
- let doneCount = 0;
1252
- let destroyCount = 0;
1253
- let startCount = 0;
1254
- const total = this.players.length;
1255
- if (total == 0) {
1256
- queueMicrotask(() => this._onFinish());
1257
- }
1258
- else {
1259
- this.players.forEach((player) => {
1260
- player.onDone(() => {
1261
- if (++doneCount == total) {
1262
- this._onFinish();
1263
- }
1264
- });
1265
- player.onDestroy(() => {
1266
- if (++destroyCount == total) {
1267
- this._onDestroy();
1268
- }
1269
- });
1270
- player.onStart(() => {
1271
- if (++startCount == total) {
1272
- this._onStart();
1273
- }
1274
- });
1275
- });
1276
- }
1277
- this.totalTime = this.players.reduce((time, player) => Math.max(time, player.totalTime), 0);
1278
- }
1279
- _onFinish() {
1280
- if (!this._finished) {
1281
- this._finished = true;
1282
- this._onDoneFns.forEach((fn) => fn());
1283
- this._onDoneFns = [];
1284
- }
1285
- }
1286
- init() {
1287
- this.players.forEach((player) => player.init());
1288
- }
1289
- onStart(fn) {
1290
- this._onStartFns.push(fn);
1291
- }
1292
- _onStart() {
1293
- if (!this.hasStarted()) {
1294
- this._started = true;
1295
- this._onStartFns.forEach((fn) => fn());
1296
- this._onStartFns = [];
1297
- }
1298
- }
1299
- onDone(fn) {
1300
- this._onDoneFns.push(fn);
1301
- }
1302
- onDestroy(fn) {
1303
- this._onDestroyFns.push(fn);
1304
- }
1305
- hasStarted() {
1306
- return this._started;
1307
- }
1308
- play() {
1309
- if (!this.parentPlayer) {
1310
- this.init();
1311
- }
1312
- this._onStart();
1313
- this.players.forEach((player) => player.play());
1314
- }
1315
- pause() {
1316
- this.players.forEach((player) => player.pause());
1317
- }
1318
- restart() {
1319
- this.players.forEach((player) => player.restart());
1320
- }
1321
- finish() {
1322
- this._onFinish();
1323
- this.players.forEach((player) => player.finish());
1324
- }
1325
- destroy() {
1326
- this._onDestroy();
1327
- }
1328
- _onDestroy() {
1329
- if (!this._destroyed) {
1330
- this._destroyed = true;
1331
- this._onFinish();
1332
- this.players.forEach((player) => player.destroy());
1333
- this._onDestroyFns.forEach((fn) => fn());
1334
- this._onDestroyFns = [];
1335
- }
1336
- }
1337
- reset() {
1338
- this.players.forEach((player) => player.reset());
1339
- this._destroyed = false;
1340
- this._finished = false;
1341
- this._started = false;
1342
- }
1343
- setPosition(p) {
1344
- const timeAtPosition = p * this.totalTime;
1345
- this.players.forEach((player) => {
1346
- const position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;
1347
- player.setPosition(position);
1348
- });
1349
- }
1350
- getPosition() {
1351
- const longestPlayer = this.players.reduce((longestSoFar, player) => {
1352
- const newPlayerIsLongest = longestSoFar === null || player.totalTime > longestSoFar.totalTime;
1353
- return newPlayerIsLongest ? player : longestSoFar;
1354
- }, null);
1355
- return longestPlayer != null ? longestPlayer.getPosition() : 0;
1356
- }
1357
- beforeDestroy() {
1358
- this.players.forEach((player) => {
1359
- if (player.beforeDestroy) {
1360
- player.beforeDestroy();
1361
- }
1362
- });
1363
- }
1364
- /** @internal */
1365
- triggerCallback(phaseName) {
1366
- const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
1367
- methods.forEach((fn) => fn());
1368
- methods.length = 0;
1369
- }
1370
- }
1371
-
1372
- const ɵPRE_STYLE = '!';
1373
-
1374
- export { AUTO_STYLE, AnimationBuilder, AnimationFactory, AnimationMetadataType, NoopAnimationPlayer, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, AnimationGroupPlayer as ɵAnimationGroupPlayer, BrowserAnimationBuilder as ɵBrowserAnimationBuilder, ɵPRE_STYLE };
208
+ export { AnimationBuilder, AnimationFactory, sequence, BrowserAnimationBuilder as ɵBrowserAnimationBuilder };
1375
209
  //# sourceMappingURL=animations.mjs.map