@angular/animations 16.0.0-next.4 → 16.0.0-next.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.
Files changed (70) hide show
  1. package/browser/index.d.ts +1 -1
  2. package/browser/testing/index.d.ts +1 -1
  3. package/esm2022/browser/src/render/animation_driver.mjs +52 -0
  4. package/{esm2020 → esm2022}/browser/src/render/special_cased_styles.mjs +2 -2
  5. package/esm2022/browser/src/warning_helpers.mjs +33 -0
  6. package/esm2022/browser/testing/src/mock_animation_driver.mjs +123 -0
  7. package/{esm2020 → esm2022}/src/version.mjs +1 -1
  8. package/{fesm2015 → fesm2022}/animations.mjs +1 -1
  9. package/{fesm2020 → fesm2022}/browser/testing.mjs +2 -2
  10. package/{fesm2020 → fesm2022}/browser/testing.mjs.map +1 -1
  11. package/{fesm2020 → fesm2022}/browser.mjs +11 -11
  12. package/fesm2022/browser.mjs.map +1 -0
  13. package/index.d.ts +1 -1
  14. package/package.json +12 -22
  15. package/esm2020/browser/src/render/animation_driver.mjs +0 -52
  16. package/esm2020/browser/src/warning_helpers.mjs +0 -33
  17. package/esm2020/browser/testing/src/mock_animation_driver.mjs +0 -123
  18. package/fesm2015/animations.mjs.map +0 -1
  19. package/fesm2015/browser/testing.mjs +0 -941
  20. package/fesm2015/browser/testing.mjs.map +0 -1
  21. package/fesm2015/browser.mjs +0 -4626
  22. package/fesm2015/browser.mjs.map +0 -1
  23. package/fesm2020/animations.mjs +0 -1179
  24. package/fesm2020/browser.mjs.map +0 -1
  25. /package/{esm2020 → esm2022}/animations.mjs +0 -0
  26. /package/{esm2020 → esm2022}/browser/browser.mjs +0 -0
  27. /package/{esm2020 → esm2022}/browser/index.mjs +0 -0
  28. /package/{esm2020 → esm2022}/browser/public_api.mjs +0 -0
  29. /package/{esm2020 → esm2022}/browser/src/browser.mjs +0 -0
  30. /package/{esm2020 → esm2022}/browser/src/dsl/animation.mjs +0 -0
  31. /package/{esm2020 → esm2022}/browser/src/dsl/animation_ast.mjs +0 -0
  32. /package/{esm2020 → esm2022}/browser/src/dsl/animation_ast_builder.mjs +0 -0
  33. /package/{esm2020 → esm2022}/browser/src/dsl/animation_dsl_visitor.mjs +0 -0
  34. /package/{esm2020 → esm2022}/browser/src/dsl/animation_timeline_builder.mjs +0 -0
  35. /package/{esm2020 → esm2022}/browser/src/dsl/animation_timeline_instruction.mjs +0 -0
  36. /package/{esm2020 → esm2022}/browser/src/dsl/animation_transition_expr.mjs +0 -0
  37. /package/{esm2020 → esm2022}/browser/src/dsl/animation_transition_factory.mjs +0 -0
  38. /package/{esm2020 → esm2022}/browser/src/dsl/animation_transition_instruction.mjs +0 -0
  39. /package/{esm2020 → esm2022}/browser/src/dsl/animation_trigger.mjs +0 -0
  40. /package/{esm2020 → esm2022}/browser/src/dsl/element_instruction_map.mjs +0 -0
  41. /package/{esm2020 → esm2022}/browser/src/dsl/style_normalization/animation_style_normalizer.mjs +0 -0
  42. /package/{esm2020 → esm2022}/browser/src/dsl/style_normalization/web_animations_style_normalizer.mjs +0 -0
  43. /package/{esm2020 → esm2022}/browser/src/error_helpers.mjs +0 -0
  44. /package/{esm2020 → esm2022}/browser/src/errors.mjs +0 -0
  45. /package/{esm2020 → esm2022}/browser/src/private_export.mjs +0 -0
  46. /package/{esm2020 → esm2022}/browser/src/render/animation_engine_instruction.mjs +0 -0
  47. /package/{esm2020 → esm2022}/browser/src/render/animation_engine_next.mjs +0 -0
  48. /package/{esm2020 → esm2022}/browser/src/render/shared.mjs +0 -0
  49. /package/{esm2020 → esm2022}/browser/src/render/timeline_animation_engine.mjs +0 -0
  50. /package/{esm2020 → esm2022}/browser/src/render/transition_animation_engine.mjs +0 -0
  51. /package/{esm2020 → esm2022}/browser/src/render/web_animations/animatable_props_set.mjs +0 -0
  52. /package/{esm2020 → esm2022}/browser/src/render/web_animations/dom_animation.mjs +0 -0
  53. /package/{esm2020 → esm2022}/browser/src/render/web_animations/web_animations_driver.mjs +0 -0
  54. /package/{esm2020 → esm2022}/browser/src/render/web_animations/web_animations_player.mjs +0 -0
  55. /package/{esm2020 → esm2022}/browser/src/util.mjs +0 -0
  56. /package/{esm2020 → esm2022}/browser/testing/index.mjs +0 -0
  57. /package/{esm2020 → esm2022}/browser/testing/public_api.mjs +0 -0
  58. /package/{esm2020 → esm2022}/browser/testing/src/testing.mjs +0 -0
  59. /package/{esm2020 → esm2022}/browser/testing/testing.mjs +0 -0
  60. /package/{esm2020 → esm2022}/index.mjs +0 -0
  61. /package/{esm2020 → esm2022}/public_api.mjs +0 -0
  62. /package/{esm2020 → esm2022}/src/animation_builder.mjs +0 -0
  63. /package/{esm2020 → esm2022}/src/animation_event.mjs +0 -0
  64. /package/{esm2020 → esm2022}/src/animation_metadata.mjs +0 -0
  65. /package/{esm2020 → esm2022}/src/animations.mjs +0 -0
  66. /package/{esm2020 → esm2022}/src/players/animation_group_player.mjs +0 -0
  67. /package/{esm2020 → esm2022}/src/players/animation_player.mjs +0 -0
  68. /package/{esm2020 → esm2022}/src/private_export.mjs +0 -0
  69. /package/{esm2020 → esm2022}/src/util.mjs +0 -0
  70. /package/{fesm2020 → fesm2022}/animations.mjs.map +0 -0
@@ -1,1179 +0,0 @@
1
- /**
2
- * @license Angular v16.0.0-next.4
3
- * (c) 2010-2022 Google LLC. https://angular.io/
4
- * License: MIT
5
- */
6
-
7
- /**
8
- * An injectable service that produces an animation sequence programmatically within an
9
- * Angular component or directive.
10
- * Provided by the `BrowserAnimationsModule` or `NoopAnimationsModule`.
11
- *
12
- * @usageNotes
13
- *
14
- * To use this service, add it to your component or directive as a dependency.
15
- * The service is instantiated along with your component.
16
- *
17
- * Apps do not typically need to create their own animation players, but if you
18
- * do need to, follow these steps:
19
- *
20
- * 1. Use the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code> method
21
- * to create a programmatic animation. The method returns an `AnimationFactory` instance.
22
- *
23
- * 2. Use the factory object to create an `AnimationPlayer` and attach it to a DOM element.
24
- *
25
- * 3. Use the player object to control the animation programmatically.
26
- *
27
- * For example:
28
- *
29
- * ```ts
30
- * // import the service from BrowserAnimationsModule
31
- * import {AnimationBuilder} from '@angular/animations';
32
- * // require the service as a dependency
33
- * class MyCmp {
34
- * constructor(private _builder: AnimationBuilder) {}
35
- *
36
- * makeAnimation(element: any) {
37
- * // first define a reusable animation
38
- * const myAnimation = this._builder.build([
39
- * style({ width: 0 }),
40
- * animate(1000, style({ width: '100px' }))
41
- * ]);
42
- *
43
- * // use the returned factory object to create a player
44
- * const player = myAnimation.create(element);
45
- *
46
- * player.play();
47
- * }
48
- * }
49
- * ```
50
- *
51
- * @publicApi
52
- */
53
- class AnimationBuilder {
54
- }
55
- /**
56
- * A factory object returned from the
57
- * <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
58
- * method.
59
- *
60
- * @publicApi
61
- */
62
- class AnimationFactory {
63
- }
64
-
65
- /**
66
- * Specifies automatic styling.
67
- *
68
- * @publicApi
69
- */
70
- const AUTO_STYLE = '*';
71
- /**
72
- * Creates a named animation trigger, containing a list of [`state()`](api/animations/state)
73
- * and `transition()` entries to be evaluated when the expression
74
- * bound to the trigger changes.
75
- *
76
- * @param name An identifying string.
77
- * @param definitions An animation definition object, containing an array of
78
- * [`state()`](api/animations/state) and `transition()` declarations.
79
- *
80
- * @return An object that encapsulates the trigger data.
81
- *
82
- * @usageNotes
83
- * Define an animation trigger in the `animations` section of `@Component` metadata.
84
- * In the template, reference the trigger by name and bind it to a trigger expression that
85
- * evaluates to a defined animation state, using the following format:
86
- *
87
- * `[@triggerName]="expression"`
88
- *
89
- * Animation trigger bindings convert all values to strings, and then match the
90
- * previous and current values against any linked transitions.
91
- * Booleans can be specified as `1` or `true` and `0` or `false`.
92
- *
93
- * ### Usage Example
94
- *
95
- * The following example creates an animation trigger reference based on the provided
96
- * name value.
97
- * The provided animation value is expected to be an array consisting of state and
98
- * transition declarations.
99
- *
100
- * ```typescript
101
- * @Component({
102
- * selector: "my-component",
103
- * templateUrl: "my-component-tpl.html",
104
- * animations: [
105
- * trigger("myAnimationTrigger", [
106
- * state(...),
107
- * state(...),
108
- * transition(...),
109
- * transition(...)
110
- * ])
111
- * ]
112
- * })
113
- * class MyComponent {
114
- * myStatusExp = "something";
115
- * }
116
- * ```
117
- *
118
- * The template associated with this component makes use of the defined trigger
119
- * by binding to an element within its template code.
120
- *
121
- * ```html
122
- * <!-- somewhere inside of my-component-tpl.html -->
123
- * <div [@myAnimationTrigger]="myStatusExp">...</div>
124
- * ```
125
- *
126
- * ### Using an inline function
127
- * The `transition` animation method also supports reading an inline function which can decide
128
- * if its associated animation should be run.
129
- *
130
- * ```typescript
131
- * // this method is run each time the `myAnimationTrigger` trigger value changes.
132
- * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
133
- string]: any}): boolean {
134
- * // notice that `element` and `params` are also available here
135
- * return toState == 'yes-please-animate';
136
- * }
137
- *
138
- * @Component({
139
- * selector: 'my-component',
140
- * templateUrl: 'my-component-tpl.html',
141
- * animations: [
142
- * trigger('myAnimationTrigger', [
143
- * transition(myInlineMatcherFn, [
144
- * // the animation sequence code
145
- * ]),
146
- * ])
147
- * ]
148
- * })
149
- * class MyComponent {
150
- * myStatusExp = "yes-please-animate";
151
- * }
152
- * ```
153
- *
154
- * ### Disabling Animations
155
- * When true, the special animation control binding `@.disabled` binding prevents
156
- * all animations from rendering.
157
- * Place the `@.disabled` binding on an element to disable
158
- * animations on the element itself, as well as any inner animation triggers
159
- * within the element.
160
- *
161
- * The following example shows how to use this feature:
162
- *
163
- * ```typescript
164
- * @Component({
165
- * selector: 'my-component',
166
- * template: `
167
- * <div [@.disabled]="isDisabled">
168
- * <div [@childAnimation]="exp"></div>
169
- * </div>
170
- * `,
171
- * animations: [
172
- * trigger("childAnimation", [
173
- * // ...
174
- * ])
175
- * ]
176
- * })
177
- * class MyComponent {
178
- * isDisabled = true;
179
- * exp = '...';
180
- * }
181
- * ```
182
- *
183
- * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,
184
- * along with any inner animations.
185
- *
186
- * ### Disable animations application-wide
187
- * When an area of the template is set to have animations disabled,
188
- * **all** inner components have their animations disabled as well.
189
- * This means that you can disable all animations for an app
190
- * by placing a host binding set on `@.disabled` on the topmost Angular component.
191
- *
192
- * ```typescript
193
- * import {Component, HostBinding} from '@angular/core';
194
- *
195
- * @Component({
196
- * selector: 'app-component',
197
- * templateUrl: 'app.component.html',
198
- * })
199
- * class AppComponent {
200
- * @HostBinding('@.disabled')
201
- * public animationsDisabled = true;
202
- * }
203
- * ```
204
- *
205
- * ### Overriding disablement of inner animations
206
- * Despite inner animations being disabled, a parent animation can `query()`
207
- * for inner elements located in disabled areas of the template and still animate
208
- * them if needed. This is also the case for when a sub animation is
209
- * queried by a parent and then later animated using `animateChild()`.
210
- *
211
- * ### Detecting when an animation is disabled
212
- * If a region of the DOM (or the entire application) has its animations disabled, the animation
213
- * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
214
- * an instance of an `AnimationEvent`. If animations are disabled,
215
- * the `.disabled` flag on the event is true.
216
- *
217
- * @publicApi
218
- */
219
- function trigger(name, definitions) {
220
- return { type: 7 /* AnimationMetadataType.Trigger */, name, definitions, options: {} };
221
- }
222
- /**
223
- * Defines an animation step that combines styling information with timing information.
224
- *
225
- * @param timings Sets `AnimateTimings` for the parent animation.
226
- * A string in the format "duration [delay] [easing]".
227
- * - Duration and delay are expressed as a number and optional time unit,
228
- * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
229
- * The default unit is milliseconds.
230
- * - The easing value controls how the animation accelerates and decelerates
231
- * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
232
- * `ease-in-out`, or a `cubic-bezier()` function call.
233
- * If not supplied, no easing is applied.
234
- *
235
- * For example, the string "1s 100ms ease-out" specifies a duration of
236
- * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
237
- * which decelerates near the end of the duration.
238
- * @param styles Sets AnimationStyles for the parent animation.
239
- * A function call to either `style()` or `keyframes()`
240
- * that returns a collection of CSS style entries to be applied to the parent animation.
241
- * When null, uses the styles from the destination state.
242
- * This is useful when describing an animation step that will complete an animation;
243
- * see "Animating to the final state" in `transitions()`.
244
- * @returns An object that encapsulates the animation step.
245
- *
246
- * @usageNotes
247
- * Call within an animation `sequence()`, `{@link animations/group group()}`, or
248
- * `transition()` call to specify an animation step
249
- * that applies given style data to the parent animation for a given amount of time.
250
- *
251
- * ### Syntax Examples
252
- * **Timing examples**
253
- *
254
- * The following examples show various `timings` specifications.
255
- * - `animate(500)` : Duration is 500 milliseconds.
256
- * - `animate("1s")` : Duration is 1000 milliseconds.
257
- * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
258
- * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
259
- * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
260
- * milliseconds, easing according to a bezier curve.
261
- *
262
- * **Style examples**
263
- *
264
- * The following example calls `style()` to set a single CSS style.
265
- * ```typescript
266
- * animate(500, style({ background: "red" }))
267
- * ```
268
- * The following example calls `keyframes()` to set a CSS style
269
- * to different values for successive keyframes.
270
- * ```typescript
271
- * animate(500, keyframes(
272
- * [
273
- * style({ background: "blue" }),
274
- * style({ background: "red" })
275
- * ])
276
- * ```
277
- *
278
- * @publicApi
279
- */
280
- function animate(timings, styles = null) {
281
- return { type: 4 /* AnimationMetadataType.Animate */, styles, timings };
282
- }
283
- /**
284
- * @description Defines a list of animation steps to be run in parallel.
285
- *
286
- * @param steps An array of animation step objects.
287
- * - When steps are defined by `style()` or `animate()`
288
- * function calls, each call within the group is executed instantly.
289
- * - To specify offset styles to be applied at a later time, define steps with
290
- * `keyframes()`, or use `animate()` calls with a delay value.
291
- * For example:
292
- *
293
- * ```typescript
294
- * group([
295
- * animate("1s", style({ background: "black" })),
296
- * animate("2s", style({ color: "white" }))
297
- * ])
298
- * ```
299
- *
300
- * @param options An options object containing a delay and
301
- * developer-defined parameters that provide styling defaults and
302
- * can be overridden on invocation.
303
- *
304
- * @return An object that encapsulates the group data.
305
- *
306
- * @usageNotes
307
- * Grouped animations are useful when a series of styles must be
308
- * animated at different starting times and closed off at different ending times.
309
- *
310
- * When called within a `sequence()` or a
311
- * `transition()` call, does not continue to the next
312
- * instruction until all of the inner animation steps have completed.
313
- *
314
- * @publicApi
315
- */
316
- function group(steps, options = null) {
317
- return { type: 3 /* AnimationMetadataType.Group */, steps, options };
318
- }
319
- /**
320
- * Defines a list of animation steps to be run sequentially, one by one.
321
- *
322
- * @param steps An array of animation step objects.
323
- * - Steps defined by `style()` calls apply the styling data immediately.
324
- * - Steps defined by `animate()` calls apply the styling data over time
325
- * as specified by the timing data.
326
- *
327
- * ```typescript
328
- * sequence([
329
- * style({ opacity: 0 }),
330
- * animate("1s", style({ opacity: 1 }))
331
- * ])
332
- * ```
333
- *
334
- * @param options An options object containing a delay and
335
- * developer-defined parameters that provide styling defaults and
336
- * can be overridden on invocation.
337
- *
338
- * @return An object that encapsulates the sequence data.
339
- *
340
- * @usageNotes
341
- * When you pass an array of steps to a
342
- * `transition()` call, the steps run sequentially by default.
343
- * Compare this to the `{@link animations/group group()}` call, which runs animation steps in
344
- *parallel.
345
- *
346
- * When a sequence is used within a `{@link animations/group group()}` or a `transition()` call,
347
- * execution continues to the next instruction only after each of the inner animation
348
- * steps have completed.
349
- *
350
- * @publicApi
351
- **/
352
- function sequence(steps, options = null) {
353
- return { type: 2 /* AnimationMetadataType.Sequence */, steps, options };
354
- }
355
- /**
356
- * Declares a key/value object containing CSS properties/styles that
357
- * can then be used for an animation [`state`](api/animations/state), within an animation
358
- *`sequence`, or as styling data for calls to `animate()` and `keyframes()`.
359
- *
360
- * @param tokens A set of CSS styles or HTML styles associated with an animation state.
361
- * The value can be any of the following:
362
- * - A key-value style pair associating a CSS property with a value.
363
- * - An array of key-value style pairs.
364
- * - An asterisk (*), to use auto-styling, where styles are derived from the element
365
- * being animated and applied to the animation when it starts.
366
- *
367
- * Auto-styling can be used to define a state that depends on layout or other
368
- * environmental factors.
369
- *
370
- * @return An object that encapsulates the style data.
371
- *
372
- * @usageNotes
373
- * The following examples create animation styles that collect a set of
374
- * CSS property values:
375
- *
376
- * ```typescript
377
- * // string values for CSS properties
378
- * style({ background: "red", color: "blue" })
379
- *
380
- * // numerical pixel values
381
- * style({ width: 100, height: 0 })
382
- * ```
383
- *
384
- * The following example uses auto-styling to allow an element to animate from
385
- * a height of 0 up to its full height:
386
- *
387
- * ```
388
- * style({ height: 0 }),
389
- * animate("1s", style({ height: "*" }))
390
- * ```
391
- *
392
- * @publicApi
393
- **/
394
- function style(tokens) {
395
- return { type: 6 /* AnimationMetadataType.Style */, styles: tokens, offset: null };
396
- }
397
- /**
398
- * Declares an animation state within a trigger attached to an element.
399
- *
400
- * @param name One or more names for the defined state in a comma-separated string.
401
- * The following reserved state names can be supplied to define a style for specific use
402
- * cases:
403
- *
404
- * - `void` You can associate styles with this name to be used when
405
- * the element is detached from the application. For example, when an `ngIf` evaluates
406
- * to false, the state of the associated element is void.
407
- * - `*` (asterisk) Indicates the default state. You can associate styles with this name
408
- * to be used as the fallback when the state that is being animated is not declared
409
- * within the trigger.
410
- *
411
- * @param styles A set of CSS styles associated with this state, created using the
412
- * `style()` function.
413
- * This set of styles persists on the element once the state has been reached.
414
- * @param options Parameters that can be passed to the state when it is invoked.
415
- * 0 or more key-value pairs.
416
- * @return An object that encapsulates the new state data.
417
- *
418
- * @usageNotes
419
- * Use the `trigger()` function to register states to an animation trigger.
420
- * Use the `transition()` function to animate between states.
421
- * When a state is active within a component, its associated styles persist on the element,
422
- * even when the animation ends.
423
- *
424
- * @publicApi
425
- **/
426
- function state(name, styles, options) {
427
- return { type: 0 /* AnimationMetadataType.State */, name, styles, options };
428
- }
429
- /**
430
- * Defines a set of animation styles, associating each style with an optional `offset` value.
431
- *
432
- * @param steps A set of animation styles with optional offset data.
433
- * The optional `offset` value for a style specifies a percentage of the total animation
434
- * time at which that style is applied.
435
- * @returns An object that encapsulates the keyframes data.
436
- *
437
- * @usageNotes
438
- * Use with the `animate()` call. Instead of applying animations
439
- * from the current state
440
- * to the destination state, keyframes describe how each style entry is applied and at what point
441
- * within the animation arc.
442
- * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
443
- *
444
- * ### Usage
445
- *
446
- * In the following example, the offset values describe
447
- * when each `backgroundColor` value is applied. The color is red at the start, and changes to
448
- * blue when 20% of the total time has elapsed.
449
- *
450
- * ```typescript
451
- * // the provided offset values
452
- * animate("5s", keyframes([
453
- * style({ backgroundColor: "red", offset: 0 }),
454
- * style({ backgroundColor: "blue", offset: 0.2 }),
455
- * style({ backgroundColor: "orange", offset: 0.3 }),
456
- * style({ backgroundColor: "black", offset: 1 })
457
- * ]))
458
- * ```
459
- *
460
- * If there are no `offset` values specified in the style entries, the offsets
461
- * are calculated automatically.
462
- *
463
- * ```typescript
464
- * animate("5s", keyframes([
465
- * style({ backgroundColor: "red" }) // offset = 0
466
- * style({ backgroundColor: "blue" }) // offset = 0.33
467
- * style({ backgroundColor: "orange" }) // offset = 0.66
468
- * style({ backgroundColor: "black" }) // offset = 1
469
- * ]))
470
- *```
471
-
472
- * @publicApi
473
- */
474
- function keyframes(steps) {
475
- return { type: 5 /* AnimationMetadataType.Keyframes */, steps };
476
- }
477
- /**
478
- * Declares an animation transition which is played when a certain specified condition is met.
479
- *
480
- * @param stateChangeExpr A string with a specific format or a function that specifies when the
481
- * animation transition should occur (see [State Change Expression](#state-change-expression)).
482
- *
483
- * @param steps One or more animation objects that represent the animation's instructions.
484
- *
485
- * @param options An options object that can be used to specify a delay for the animation or provide
486
- * custom parameters for it.
487
- *
488
- * @returns An object that encapsulates the transition data.
489
- *
490
- * @usageNotes
491
- *
492
- * ### State Change Expression
493
- *
494
- * The State Change Expression instructs Angular when to run the transition's animations, it can
495
- *either be
496
- * - a string with a specific syntax
497
- * - or a function that compares the previous and current state (value of the expression bound to
498
- * the element's trigger) and returns `true` if the transition should occur or `false` otherwise
499
- *
500
- * The string format can be:
501
- * - `fromState => toState`, which indicates that the transition's animations should occur then the
502
- * expression bound to the trigger's element goes from `fromState` to `toState`
503
- *
504
- * _Example:_
505
- * ```typescript
506
- * transition('open => closed', animate('.5s ease-out', style({ height: 0 }) ))
507
- * ```
508
- *
509
- * - `fromState <=> toState`, which indicates that the transition's animations should occur then
510
- * the expression bound to the trigger's element goes from `fromState` to `toState` or vice versa
511
- *
512
- * _Example:_
513
- * ```typescript
514
- * transition('enabled <=> disabled', animate('1s cubic-bezier(0.8,0.3,0,1)'))
515
- * ```
516
- *
517
- * - `:enter`/`:leave`, which indicates that the transition's animations should occur when the
518
- * element enters or exists the DOM
519
- *
520
- * _Example:_
521
- * ```typescript
522
- * transition(':enter', [
523
- * style({ opacity: 0 }),
524
- * animate('500ms', style({ opacity: 1 }))
525
- * ])
526
- * ```
527
- *
528
- * - `:increment`/`:decrement`, which indicates that the transition's animations should occur when
529
- * the numerical expression bound to the trigger's element has increased in value or decreased
530
- *
531
- * _Example:_
532
- * ```typescript
533
- * transition(':increment', query('@counter', animateChild()))
534
- * ```
535
- *
536
- * - a sequence of any of the above divided by commas, which indicates that transition's animations
537
- * should occur whenever one of the state change expressions matches
538
- *
539
- * _Example:_
540
- * ```typescript
541
- * transition(':increment, * => enabled, :enter', animate('1s ease', keyframes([
542
- * style({ transform: 'scale(1)', offset: 0}),
543
- * style({ transform: 'scale(1.1)', offset: 0.7}),
544
- * style({ transform: 'scale(1)', offset: 1})
545
- * ]))),
546
- * ```
547
- *
548
- * Also note that in such context:
549
- * - `void` can be used to indicate the absence of the element
550
- * - asterisks can be used as wildcards that match any state
551
- * - (as a consequence of the above, `void => *` is equivalent to `:enter` and `* => void` is
552
- * equivalent to `:leave`)
553
- * - `true` and `false` also match expression values of `1` and `0` respectively (but do not match
554
- * _truthy_ and _falsy_ values)
555
- *
556
- * <div class="alert is-helpful">
557
- *
558
- * Be careful about entering end leaving elements as their transitions present a common
559
- * pitfall for developers.
560
- *
561
- * Note that when an element with a trigger enters the DOM its `:enter` transition always
562
- * gets executed, but its `:leave` transition will not be executed if the element is removed
563
- * alongside its parent (as it will be removed "without warning" before its transition has
564
- * a chance to be executed, the only way that such transition can occur is if the element
565
- * is exiting the DOM on its own).
566
- *
567
- *
568
- * </div>
569
- *
570
- * ### Animating to a Final State
571
- *
572
- * If the final step in a transition is a call to `animate()` that uses a timing value
573
- * with no `style` data, that step is automatically considered the final animation arc,
574
- * for the element to reach the final state, in such case Angular automatically adds or removes
575
- * CSS styles to ensure that the element is in the correct final state.
576
- *
577
- *
578
- * ### Usage Examples
579
- *
580
- * - Transition animations applied based on
581
- * the trigger's expression value
582
- *
583
- * ```HTML
584
- * <div [@myAnimationTrigger]="myStatusExp">
585
- * ...
586
- * </div>
587
- * ```
588
- *
589
- * ```typescript
590
- * trigger("myAnimationTrigger", [
591
- * ..., // states
592
- * transition("on => off, open => closed", animate(500)),
593
- * transition("* <=> error", query('.indicator', animateChild()))
594
- * ])
595
- * ```
596
- *
597
- * - Transition animations applied based on custom logic dependent
598
- * on the trigger's expression value and provided parameters
599
- *
600
- * ```HTML
601
- * <div [@myAnimationTrigger]="{
602
- * value: stepName,
603
- * params: { target: currentTarget }
604
- * }">
605
- * ...
606
- * </div>
607
- * ```
608
- *
609
- * ```typescript
610
- * trigger("myAnimationTrigger", [
611
- * ..., // states
612
- * transition(
613
- * (fromState, toState, _element, params) =>
614
- * ['firststep', 'laststep'].includes(fromState.toLowerCase())
615
- * && toState === params?.['target'],
616
- * animate('1s')
617
- * )
618
- * ])
619
- * ```
620
- *
621
- * @publicApi
622
- **/
623
- function transition(stateChangeExpr, steps, options = null) {
624
- return { type: 1 /* AnimationMetadataType.Transition */, expr: stateChangeExpr, animation: steps, options };
625
- }
626
- /**
627
- * Produces a reusable animation that can be invoked in another animation or sequence,
628
- * by calling the `useAnimation()` function.
629
- *
630
- * @param steps One or more animation objects, as returned by the `animate()`
631
- * or `sequence()` function, that form a transformation from one state to another.
632
- * A sequence is used by default when you pass an array.
633
- * @param options An options object that can contain a delay value for the start of the
634
- * animation, and additional developer-defined parameters.
635
- * Provided values for additional parameters are used as defaults,
636
- * and override values can be passed to the caller on invocation.
637
- * @returns An object that encapsulates the animation data.
638
- *
639
- * @usageNotes
640
- * The following example defines a reusable animation, providing some default parameter
641
- * values.
642
- *
643
- * ```typescript
644
- * var fadeAnimation = animation([
645
- * style({ opacity: '{{ start }}' }),
646
- * animate('{{ time }}',
647
- * style({ opacity: '{{ end }}'}))
648
- * ],
649
- * { params: { time: '1000ms', start: 0, end: 1 }});
650
- * ```
651
- *
652
- * The following invokes the defined animation with a call to `useAnimation()`,
653
- * passing in override parameter values.
654
- *
655
- * ```js
656
- * useAnimation(fadeAnimation, {
657
- * params: {
658
- * time: '2s',
659
- * start: 1,
660
- * end: 0
661
- * }
662
- * })
663
- * ```
664
- *
665
- * If any of the passed-in parameter values are missing from this call,
666
- * the default values are used. If one or more parameter values are missing before a step is
667
- * animated, `useAnimation()` throws an error.
668
- *
669
- * @publicApi
670
- */
671
- function animation(steps, options = null) {
672
- return { type: 8 /* AnimationMetadataType.Reference */, animation: steps, options };
673
- }
674
- /**
675
- * Executes a queried inner animation element within an animation sequence.
676
- *
677
- * @param options An options object that can contain a delay value for the start of the
678
- * animation, and additional override values for developer-defined parameters.
679
- * @return An object that encapsulates the child animation data.
680
- *
681
- * @usageNotes
682
- * Each time an animation is triggered in Angular, the parent animation
683
- * has priority and any child animations are blocked. In order
684
- * for a child animation to run, the parent animation must query each of the elements
685
- * containing child animations, and run them using this function.
686
- *
687
- * Note that this feature is designed to be used with `query()` and it will only work
688
- * with animations that are assigned using the Angular animation library. CSS keyframes
689
- * and transitions are not handled by this API.
690
- *
691
- * @publicApi
692
- */
693
- function animateChild(options = null) {
694
- return { type: 9 /* AnimationMetadataType.AnimateChild */, options };
695
- }
696
- /**
697
- * Starts a reusable animation that is created using the `animation()` function.
698
- *
699
- * @param animation The reusable animation to start.
700
- * @param options An options object that can contain a delay value for the start of
701
- * the animation, and additional override values for developer-defined parameters.
702
- * @return An object that contains the animation parameters.
703
- *
704
- * @publicApi
705
- */
706
- function useAnimation(animation, options = null) {
707
- return { type: 10 /* AnimationMetadataType.AnimateRef */, animation, options };
708
- }
709
- /**
710
- * Finds one or more inner elements within the current element that is
711
- * being animated within a sequence. Use with `animate()`.
712
- *
713
- * @param selector The element to query, or a set of elements that contain Angular-specific
714
- * characteristics, specified with one or more of the following tokens.
715
- * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements (not
716
- * all elements can be queried via these tokens, see
717
- * [Entering and Leaving Elements](#entering-and-leaving-elements))
718
- * - `query(":animating")` : Query all currently animating elements.
719
- * - `query("@triggerName")` : Query elements that contain an animation trigger.
720
- * - `query("@*")` : Query all elements that contain an animation triggers.
721
- * - `query(":self")` : Include the current element into the animation sequence.
722
- *
723
- * @param animation One or more animation steps to apply to the queried element or elements.
724
- * An array is treated as an animation sequence.
725
- * @param options An options object. Use the 'limit' field to limit the total number of
726
- * items to collect.
727
- * @return An object that encapsulates the query data.
728
- *
729
- * @usageNotes
730
- *
731
- * ### Multiple Tokens
732
- *
733
- * Tokens can be merged into a combined query selector string. For example:
734
- *
735
- * ```typescript
736
- * query(':self, .record:enter, .record:leave, @subTrigger', [...])
737
- * ```
738
- *
739
- * The `query()` function collects multiple elements and works internally by using
740
- * `element.querySelectorAll`. Use the `limit` field of an options object to limit
741
- * the total number of items to be collected. For example:
742
- *
743
- * ```js
744
- * query('div', [
745
- * animate(...),
746
- * animate(...)
747
- * ], { limit: 1 })
748
- * ```
749
- *
750
- * By default, throws an error when zero items are found. Set the
751
- * `optional` flag to ignore this error. For example:
752
- *
753
- * ```js
754
- * query('.some-element-that-may-not-be-there', [
755
- * animate(...),
756
- * animate(...)
757
- * ], { optional: true })
758
- * ```
759
- *
760
- * ### Entering and Leaving Elements
761
- *
762
- * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones
763
- * that can are those that Angular assumes can enter/leave based on their own logic
764
- * (if their insertion/removal is simply a consequence of that of their parent they
765
- * should be queried via a different token in their parent's `:enter`/`:leave` transitions).
766
- *
767
- * The only elements Angular assumes can enter/leave based on their own logic (thus the only
768
- * ones that can be queried via the `:enter` and `:leave` tokens) are:
769
- * - Those inserted dynamically (via `ViewContainerRef`)
770
- * - Those that have a structural directive (which, under the hood, are a subset of the above ones)
771
- *
772
- * <div class="alert is-helpful">
773
- *
774
- * Note that elements will be successfully queried via `:enter`/`:leave` even if their
775
- * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural
776
- * directive (e.g. they enter/exit alongside their parent).
777
- *
778
- * </div>
779
- *
780
- * <div class="alert is-important">
781
- *
782
- * There is an exception to what previously mentioned, besides elements entering/leaving based on
783
- * their own logic, elements with an animation trigger can always be queried via `:leave` when
784
- * their parent is also leaving.
785
- *
786
- * </div>
787
- *
788
- * ### Usage Example
789
- *
790
- * The following example queries for inner elements and animates them
791
- * individually using `animate()`.
792
- *
793
- * ```typescript
794
- * @Component({
795
- * selector: 'inner',
796
- * template: `
797
- * <div [@queryAnimation]="exp">
798
- * <h1>Title</h1>
799
- * <div class="content">
800
- * Blah blah blah
801
- * </div>
802
- * </div>
803
- * `,
804
- * animations: [
805
- * trigger('queryAnimation', [
806
- * transition('* => goAnimate', [
807
- * // hide the inner elements
808
- * query('h1', style({ opacity: 0 })),
809
- * query('.content', style({ opacity: 0 })),
810
- *
811
- * // animate the inner elements in, one by one
812
- * query('h1', animate(1000, style({ opacity: 1 }))),
813
- * query('.content', animate(1000, style({ opacity: 1 }))),
814
- * ])
815
- * ])
816
- * ]
817
- * })
818
- * class Cmp {
819
- * exp = '';
820
- *
821
- * goAnimate() {
822
- * this.exp = 'goAnimate';
823
- * }
824
- * }
825
- * ```
826
- *
827
- * @publicApi
828
- */
829
- function query(selector, animation, options = null) {
830
- return { type: 11 /* AnimationMetadataType.Query */, selector, animation, options };
831
- }
832
- /**
833
- * Use within an animation `query()` call to issue a timing gap after
834
- * each queried item is animated.
835
- *
836
- * @param timings A delay value.
837
- * @param animation One ore more animation steps.
838
- * @returns An object that encapsulates the stagger data.
839
- *
840
- * @usageNotes
841
- * In the following example, a container element wraps a list of items stamped out
842
- * by an `ngFor`. The container element contains an animation trigger that will later be set
843
- * to query for each of the inner items.
844
- *
845
- * Each time items are added, the opacity fade-in animation runs,
846
- * and each removed item is faded out.
847
- * When either of these animations occur, the stagger effect is
848
- * applied after each item's animation is started.
849
- *
850
- * ```html
851
- * <!-- list.component.html -->
852
- * <button (click)="toggle()">Show / Hide Items</button>
853
- * <hr />
854
- * <div [@listAnimation]="items.length">
855
- * <div *ngFor="let item of items">
856
- * {{ item }}
857
- * </div>
858
- * </div>
859
- * ```
860
- *
861
- * Here is the component code:
862
- *
863
- * ```typescript
864
- * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';
865
- * @Component({
866
- * templateUrl: 'list.component.html',
867
- * animations: [
868
- * trigger('listAnimation', [
869
- * ...
870
- * ])
871
- * ]
872
- * })
873
- * class ListComponent {
874
- * items = [];
875
- *
876
- * showItems() {
877
- * this.items = [0,1,2,3,4];
878
- * }
879
- *
880
- * hideItems() {
881
- * this.items = [];
882
- * }
883
- *
884
- * toggle() {
885
- * this.items.length ? this.hideItems() : this.showItems();
886
- * }
887
- * }
888
- * ```
889
- *
890
- * Here is the animation trigger code:
891
- *
892
- * ```typescript
893
- * trigger('listAnimation', [
894
- * transition('* => *', [ // each time the binding value changes
895
- * query(':leave', [
896
- * stagger(100, [
897
- * animate('0.5s', style({ opacity: 0 }))
898
- * ])
899
- * ]),
900
- * query(':enter', [
901
- * style({ opacity: 0 }),
902
- * stagger(100, [
903
- * animate('0.5s', style({ opacity: 1 }))
904
- * ])
905
- * ])
906
- * ])
907
- * ])
908
- * ```
909
- *
910
- * @publicApi
911
- */
912
- function stagger(timings, animation) {
913
- return { type: 12 /* AnimationMetadataType.Stagger */, timings, animation };
914
- }
915
-
916
- function scheduleMicroTask(cb) {
917
- Promise.resolve().then(cb);
918
- }
919
-
920
- /**
921
- * An empty programmatic controller for reusable animations.
922
- * Used internally when animations are disabled, to avoid
923
- * checking for the null case when an animation player is expected.
924
- *
925
- * @see `animate()`
926
- * @see `AnimationPlayer`
927
- * @see `GroupPlayer`
928
- *
929
- * @publicApi
930
- */
931
- class NoopAnimationPlayer {
932
- constructor(duration = 0, delay = 0) {
933
- this._onDoneFns = [];
934
- this._onStartFns = [];
935
- this._onDestroyFns = [];
936
- this._originalOnDoneFns = [];
937
- this._originalOnStartFns = [];
938
- this._started = false;
939
- this._destroyed = false;
940
- this._finished = false;
941
- this._position = 0;
942
- this.parentPlayer = null;
943
- this.totalTime = duration + delay;
944
- }
945
- _onFinish() {
946
- if (!this._finished) {
947
- this._finished = true;
948
- this._onDoneFns.forEach(fn => fn());
949
- this._onDoneFns = [];
950
- }
951
- }
952
- onStart(fn) {
953
- this._originalOnStartFns.push(fn);
954
- this._onStartFns.push(fn);
955
- }
956
- onDone(fn) {
957
- this._originalOnDoneFns.push(fn);
958
- this._onDoneFns.push(fn);
959
- }
960
- onDestroy(fn) {
961
- this._onDestroyFns.push(fn);
962
- }
963
- hasStarted() {
964
- return this._started;
965
- }
966
- init() { }
967
- play() {
968
- if (!this.hasStarted()) {
969
- this._onStart();
970
- this.triggerMicrotask();
971
- }
972
- this._started = true;
973
- }
974
- /** @internal */
975
- triggerMicrotask() {
976
- scheduleMicroTask(() => this._onFinish());
977
- }
978
- _onStart() {
979
- this._onStartFns.forEach(fn => fn());
980
- this._onStartFns = [];
981
- }
982
- pause() { }
983
- restart() { }
984
- finish() {
985
- this._onFinish();
986
- }
987
- destroy() {
988
- if (!this._destroyed) {
989
- this._destroyed = true;
990
- if (!this.hasStarted()) {
991
- this._onStart();
992
- }
993
- this.finish();
994
- this._onDestroyFns.forEach(fn => fn());
995
- this._onDestroyFns = [];
996
- }
997
- }
998
- reset() {
999
- this._started = false;
1000
- this._finished = false;
1001
- this._onStartFns = this._originalOnStartFns;
1002
- this._onDoneFns = this._originalOnDoneFns;
1003
- }
1004
- setPosition(position) {
1005
- this._position = this.totalTime ? position * this.totalTime : 1;
1006
- }
1007
- getPosition() {
1008
- return this.totalTime ? this._position / this.totalTime : 1;
1009
- }
1010
- /** @internal */
1011
- triggerCallback(phaseName) {
1012
- const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
1013
- methods.forEach(fn => fn());
1014
- methods.length = 0;
1015
- }
1016
- }
1017
-
1018
- /**
1019
- * A programmatic controller for a group of reusable animations.
1020
- * Used internally to control animations.
1021
- *
1022
- * @see `AnimationPlayer`
1023
- * @see `{@link animations/group group()}`
1024
- *
1025
- */
1026
- class AnimationGroupPlayer {
1027
- constructor(_players) {
1028
- this._onDoneFns = [];
1029
- this._onStartFns = [];
1030
- this._finished = false;
1031
- this._started = false;
1032
- this._destroyed = false;
1033
- this._onDestroyFns = [];
1034
- this.parentPlayer = null;
1035
- this.totalTime = 0;
1036
- this.players = _players;
1037
- let doneCount = 0;
1038
- let destroyCount = 0;
1039
- let startCount = 0;
1040
- const total = this.players.length;
1041
- if (total == 0) {
1042
- scheduleMicroTask(() => this._onFinish());
1043
- }
1044
- else {
1045
- this.players.forEach(player => {
1046
- player.onDone(() => {
1047
- if (++doneCount == total) {
1048
- this._onFinish();
1049
- }
1050
- });
1051
- player.onDestroy(() => {
1052
- if (++destroyCount == total) {
1053
- this._onDestroy();
1054
- }
1055
- });
1056
- player.onStart(() => {
1057
- if (++startCount == total) {
1058
- this._onStart();
1059
- }
1060
- });
1061
- });
1062
- }
1063
- this.totalTime = this.players.reduce((time, player) => Math.max(time, player.totalTime), 0);
1064
- }
1065
- _onFinish() {
1066
- if (!this._finished) {
1067
- this._finished = true;
1068
- this._onDoneFns.forEach(fn => fn());
1069
- this._onDoneFns = [];
1070
- }
1071
- }
1072
- init() {
1073
- this.players.forEach(player => player.init());
1074
- }
1075
- onStart(fn) {
1076
- this._onStartFns.push(fn);
1077
- }
1078
- _onStart() {
1079
- if (!this.hasStarted()) {
1080
- this._started = true;
1081
- this._onStartFns.forEach(fn => fn());
1082
- this._onStartFns = [];
1083
- }
1084
- }
1085
- onDone(fn) {
1086
- this._onDoneFns.push(fn);
1087
- }
1088
- onDestroy(fn) {
1089
- this._onDestroyFns.push(fn);
1090
- }
1091
- hasStarted() {
1092
- return this._started;
1093
- }
1094
- play() {
1095
- if (!this.parentPlayer) {
1096
- this.init();
1097
- }
1098
- this._onStart();
1099
- this.players.forEach(player => player.play());
1100
- }
1101
- pause() {
1102
- this.players.forEach(player => player.pause());
1103
- }
1104
- restart() {
1105
- this.players.forEach(player => player.restart());
1106
- }
1107
- finish() {
1108
- this._onFinish();
1109
- this.players.forEach(player => player.finish());
1110
- }
1111
- destroy() {
1112
- this._onDestroy();
1113
- }
1114
- _onDestroy() {
1115
- if (!this._destroyed) {
1116
- this._destroyed = true;
1117
- this._onFinish();
1118
- this.players.forEach(player => player.destroy());
1119
- this._onDestroyFns.forEach(fn => fn());
1120
- this._onDestroyFns = [];
1121
- }
1122
- }
1123
- reset() {
1124
- this.players.forEach(player => player.reset());
1125
- this._destroyed = false;
1126
- this._finished = false;
1127
- this._started = false;
1128
- }
1129
- setPosition(p) {
1130
- const timeAtPosition = p * this.totalTime;
1131
- this.players.forEach(player => {
1132
- const position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;
1133
- player.setPosition(position);
1134
- });
1135
- }
1136
- getPosition() {
1137
- const longestPlayer = this.players.reduce((longestSoFar, player) => {
1138
- const newPlayerIsLongest = longestSoFar === null || player.totalTime > longestSoFar.totalTime;
1139
- return newPlayerIsLongest ? player : longestSoFar;
1140
- }, null);
1141
- return longestPlayer != null ? longestPlayer.getPosition() : 0;
1142
- }
1143
- beforeDestroy() {
1144
- this.players.forEach(player => {
1145
- if (player.beforeDestroy) {
1146
- player.beforeDestroy();
1147
- }
1148
- });
1149
- }
1150
- /** @internal */
1151
- triggerCallback(phaseName) {
1152
- const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
1153
- methods.forEach(fn => fn());
1154
- methods.length = 0;
1155
- }
1156
- }
1157
-
1158
- const ɵPRE_STYLE = '!';
1159
-
1160
- /**
1161
- * @module
1162
- * @description
1163
- * Entry point for all animation APIs of the animation package.
1164
- */
1165
-
1166
- /**
1167
- * @module
1168
- * @description
1169
- * Entry point for all public APIs of this package.
1170
- */
1171
-
1172
- // This file is not used to build this module. It is only used during editing
1173
-
1174
- /**
1175
- * Generated bundle index. Do not edit.
1176
- */
1177
-
1178
- export { AUTO_STYLE, AnimationBuilder, AnimationFactory, NoopAnimationPlayer, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, AnimationGroupPlayer as ɵAnimationGroupPlayer, ɵPRE_STYLE };
1179
- //# sourceMappingURL=animations.mjs.map