@angular/animations 19.2.1 → 19.2.3

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.
package/index.d.ts CHANGED
@@ -1,112 +1,29 @@
1
1
  /**
2
- * @license Angular v19.2.1
2
+ * @license Angular v19.2.3
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
-
8
7
  import * as i0 from '@angular/core';
9
8
  import { RendererFactory2 } from '@angular/core';
10
9
 
11
10
  /**
12
- * Defines an animation step that combines styling information with timing information.
13
- *
14
- * @param timings Sets `AnimateTimings` for the parent animation.
15
- * A string in the format "duration [delay] [easing]".
16
- * - Duration and delay are expressed as a number and optional time unit,
17
- * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
18
- * The default unit is milliseconds.
19
- * - The easing value controls how the animation accelerates and decelerates
20
- * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
21
- * `ease-in-out`, or a `cubic-bezier()` function call.
22
- * If not supplied, no easing is applied.
23
- *
24
- * For example, the string "1s 100ms ease-out" specifies a duration of
25
- * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
26
- * which decelerates near the end of the duration.
27
- * @param styles Sets AnimationStyles for the parent animation.
28
- * A function call to either `style()` or `keyframes()`
29
- * that returns a collection of CSS style entries to be applied to the parent animation.
30
- * When null, uses the styles from the destination state.
31
- * This is useful when describing an animation step that will complete an animation;
32
- * see "Animating to the final state" in `transitions()`.
33
- * @returns An object that encapsulates the animation step.
34
- *
35
- * @usageNotes
36
- * Call within an animation `sequence()`, {@link /api/animations/group group()}, or
37
- * `transition()` call to specify an animation step
38
- * that applies given style data to the parent animation for a given amount of time.
39
- *
40
- * ### Syntax Examples
41
- * **Timing examples**
42
- *
43
- * The following examples show various `timings` specifications.
44
- * - `animate(500)` : Duration is 500 milliseconds.
45
- * - `animate("1s")` : Duration is 1000 milliseconds.
46
- * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
47
- * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
48
- * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
49
- * milliseconds, easing according to a bezier curve.
50
- *
51
- * **Style examples**
52
- *
53
- * The following example calls `style()` to set a single CSS style.
54
- * ```ts
55
- * animate(500, style({ background: "red" }))
56
- * ```
57
- * The following example calls `keyframes()` to set a CSS style
58
- * to different values for successive keyframes.
59
- * ```ts
60
- * animate(500, keyframes(
61
- * [
62
- * style({ background: "blue" }),
63
- * style({ background: "red" })
64
- * ])
65
- * ```
66
- *
67
- * @publicApi
68
- */
69
- export declare function animate(timings: string | number, styles?: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null): AnimationAnimateMetadata;
70
-
71
- /**
72
- * Executes a queried inner animation element within an animation sequence.
73
- *
74
- * @param options An options object that can contain a delay value for the start of the
75
- * animation, and additional override values for developer-defined parameters.
76
- * @return An object that encapsulates the child animation data.
77
- *
78
- * @usageNotes
79
- * Each time an animation is triggered in Angular, the parent animation
80
- * has priority and any child animations are blocked. In order
81
- * for a child animation to run, the parent animation must query each of the elements
82
- * containing child animations, and run them using this function.
83
- *
84
- * Note that this feature is designed to be used with `query()` and it will only work
85
- * with animations that are assigned using the Angular animation library. CSS keyframes
86
- * and transitions are not handled by this API.
87
- *
88
- * @publicApi
11
+ * Represents a set of CSS styles for use in an animation style as a generic.
89
12
  */
90
- export declare function animateChild(options?: AnimateChildOptions | null): AnimationAnimateChildMetadata;
91
-
13
+ interface ɵStyleData {
14
+ [key: string]: string | number;
15
+ }
92
16
  /**
93
- * Adds duration options to control animation styling and timing for a child animation.
94
- *
95
- * @see {@link animateChild}
96
- *
97
- * @publicApi
17
+ * Represents a set of CSS styles for use in an animation style as a Map.
98
18
  */
99
- export declare interface AnimateChildOptions extends AnimationOptions {
100
- duration?: number | string;
101
- }
102
-
19
+ type ɵStyleDataMap = Map<string, string | number>;
103
20
  /**
104
21
  * Represents animation-step timing parameters for an animation step.
105
22
  * @see {@link animate}
106
23
  *
107
24
  * @publicApi
108
25
  */
109
- export declare type AnimateTimings = {
26
+ declare type AnimateTimings = {
110
27
  /**
111
28
  * The full duration of an animation step. A number and optional time unit,
112
29
  * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
@@ -128,259 +45,228 @@ export declare type AnimateTimings = {
128
45
  */
129
46
  easing: string | null;
130
47
  };
131
-
132
48
  /**
133
- * Produces a reusable animation that can be invoked in another animation or sequence,
134
- * by calling the `useAnimation()` function.
135
- *
136
- * @param steps One or more animation objects, as returned by the `animate()`
137
- * or `sequence()` function, that form a transformation from one state to another.
138
- * A sequence is used by default when you pass an array.
139
- * @param options An options object that can contain a delay value for the start of the
140
- * animation, and additional developer-defined parameters.
141
- * Provided values for additional parameters are used as defaults,
142
- * and override values can be passed to the caller on invocation.
143
- * @returns An object that encapsulates the animation data.
144
- *
145
- * @usageNotes
146
- * The following example defines a reusable animation, providing some default parameter
147
- * values.
148
- *
149
- * ```ts
150
- * var fadeAnimation = animation([
151
- * style({ opacity: '{{ start }}' }),
152
- * animate('{{ time }}',
153
- * style({ opacity: '{{ end }}'}))
154
- * ],
155
- * { params: { time: '1000ms', start: 0, end: 1 }});
156
- * ```
49
+ * @description Options that control animation styling and timing.
157
50
  *
158
- * The following invokes the defined animation with a call to `useAnimation()`,
159
- * passing in override parameter values.
51
+ * The following animation functions accept `AnimationOptions` data:
160
52
  *
161
- * ```js
162
- * useAnimation(fadeAnimation, {
163
- * params: {
164
- * time: '2s',
165
- * start: 1,
166
- * end: 0
167
- * }
168
- * })
169
- * ```
53
+ * - `transition()`
54
+ * - `sequence()`
55
+ * - `{@link /api/animations/group group()}`
56
+ * - `query()`
57
+ * - `animation()`
58
+ * - `useAnimation()`
59
+ * - `animateChild()`
170
60
  *
171
- * If any of the passed-in parameter values are missing from this call,
172
- * the default values are used. If one or more parameter values are missing before a step is
173
- * animated, `useAnimation()` throws an error.
61
+ * Programmatic animations built using the `AnimationBuilder` service also
62
+ * make use of `AnimationOptions`.
174
63
  *
175
64
  * @publicApi
176
65
  */
177
- export declare function animation(steps: AnimationMetadata | AnimationMetadata[], options?: AnimationOptions | null): AnimationReferenceMetadata;
178
-
66
+ declare interface AnimationOptions {
67
+ /**
68
+ * Sets a time-delay for initiating an animation action.
69
+ * A number and optional time unit, such as "1s" or "10ms" for one second
70
+ * and 10 milliseconds, respectively.The default unit is milliseconds.
71
+ * Default value is 0, meaning no delay.
72
+ */
73
+ delay?: number | string;
74
+ /**
75
+ * A set of developer-defined parameters that modify styling and timing
76
+ * when an animation action starts. An array of key-value pairs, where the provided value
77
+ * is used as a default.
78
+ */
79
+ params?: {
80
+ [name: string]: any;
81
+ };
82
+ }
179
83
  /**
180
- * Encapsulates a child animation, that can be run explicitly when the parent is run.
181
- * Instantiated and returned by the `animateChild` function.
84
+ * Adds duration options to control animation styling and timing for a child animation.
85
+ *
86
+ * @see {@link animateChild}
182
87
  *
183
88
  * @publicApi
184
89
  */
185
- export declare interface AnimationAnimateChildMetadata extends AnimationMetadata {
186
- /**
187
- * An options object containing a delay and
188
- * developer-defined parameters that provide styling defaults and
189
- * can be overridden on invocation. Default delay is 0.
190
- */
191
- options: AnimationOptions | null;
90
+ declare interface AnimateChildOptions extends AnimationOptions {
91
+ duration?: number | string;
192
92
  }
193
-
194
93
  /**
195
- * Encapsulates an animation step. Instantiated and returned by
196
- * the `animate()` function.
94
+ * @description Constants for the categories of parameters that can be defined for animations.
95
+ *
96
+ * A corresponding function defines a set of parameters for each category, and
97
+ * collects them into a corresponding `AnimationMetadata` object.
197
98
  *
198
99
  * @publicApi
199
100
  */
200
- export declare interface AnimationAnimateMetadata extends AnimationMetadata {
101
+ declare enum AnimationMetadataType {
201
102
  /**
202
- * The timing data for the step.
103
+ * Associates a named animation state with a set of CSS styles.
104
+ * See [`state()`](api/animations/state)
203
105
  */
204
- timings: string | number | AnimateTimings;
106
+ State = 0,
205
107
  /**
206
- * A set of styles used in the step.
108
+ * Data for a transition from one animation state to another.
109
+ * See `transition()`
207
110
  */
208
- styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null;
209
- }
210
-
211
- /**
212
- * Encapsulates a reusable animation.
213
- * Instantiated and returned by the `useAnimation()` function.
214
- *
215
- * @publicApi
216
- */
217
- export declare interface AnimationAnimateRefMetadata extends AnimationMetadata {
111
+ Transition = 1,
218
112
  /**
219
- * An animation reference object.
113
+ * Contains a set of animation steps.
114
+ * See `sequence()`
220
115
  */
221
- animation: AnimationReferenceMetadata;
116
+ Sequence = 2,
222
117
  /**
223
- * An options object containing a delay and
224
- * developer-defined parameters that provide styling defaults and
225
- * can be overridden on invocation. Default delay is 0.
118
+ * Contains a set of animation steps.
119
+ * See `{@link /api/animations/group group()}`
226
120
  */
227
- options: AnimationOptions | null;
121
+ Group = 3,
122
+ /**
123
+ * Contains an animation step.
124
+ * See `animate()`
125
+ */
126
+ Animate = 4,
127
+ /**
128
+ * Contains a set of animation steps.
129
+ * See `keyframes()`
130
+ */
131
+ Keyframes = 5,
132
+ /**
133
+ * Contains a set of CSS property-value pairs into a named style.
134
+ * See `style()`
135
+ */
136
+ Style = 6,
137
+ /**
138
+ * Associates an animation with an entry trigger that can be attached to an element.
139
+ * See `trigger()`
140
+ */
141
+ Trigger = 7,
142
+ /**
143
+ * Contains a re-usable animation.
144
+ * See `animation()`
145
+ */
146
+ Reference = 8,
147
+ /**
148
+ * Contains data to use in executing child animations returned by a query.
149
+ * See `animateChild()`
150
+ */
151
+ AnimateChild = 9,
152
+ /**
153
+ * Contains animation parameters for a re-usable animation.
154
+ * See `useAnimation()`
155
+ */
156
+ AnimateRef = 10,
157
+ /**
158
+ * Contains child-animation query data.
159
+ * See `query()`
160
+ */
161
+ Query = 11,
162
+ /**
163
+ * Contains data for staggering an animation sequence.
164
+ * See `stagger()`
165
+ */
166
+ Stagger = 12
228
167
  }
229
-
230
168
  /**
231
- * An injectable service that produces an animation sequence programmatically within an
232
- * Angular component or directive.
233
- * Provided by the `BrowserAnimationsModule` or `NoopAnimationsModule`.
169
+ * Specifies automatic styling.
234
170
  *
235
- * @usageNotes
236
- *
237
- * To use this service, add it to your component or directive as a dependency.
238
- * The service is instantiated along with your component.
239
- *
240
- * Apps do not typically need to create their own animation players, but if you
241
- * do need to, follow these steps:
242
- *
243
- * 1. Use the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code> method
244
- * to create a programmatic animation. The method returns an `AnimationFactory` instance.
245
- *
246
- * 2. Use the factory object to create an `AnimationPlayer` and attach it to a DOM element.
247
- *
248
- * 3. Use the player object to control the animation programmatically.
249
- *
250
- * For example:
251
- *
252
- * ```ts
253
- * // import the service from BrowserAnimationsModule
254
- * import {AnimationBuilder} from '@angular/animations';
255
- * // require the service as a dependency
256
- * class MyCmp {
257
- * constructor(private _builder: AnimationBuilder) {}
258
- *
259
- * makeAnimation(element: any) {
260
- * // first define a reusable animation
261
- * const myAnimation = this._builder.build([
262
- * style({ width: 0 }),
263
- * animate(1000, style({ width: '100px' }))
264
- * ]);
265
- *
266
- * // use the returned factory object to create a player
267
- * const player = myAnimation.create(element);
268
- *
269
- * player.play();
270
- * }
271
- * }
272
- * ```
171
+ * @publicApi
172
+ */
173
+ declare const AUTO_STYLE = "*";
174
+ /**
175
+ * Base for animation data structures.
273
176
  *
274
177
  * @publicApi
275
178
  */
276
- export declare abstract class AnimationBuilder {
277
- /**
278
- * Builds a factory for producing a defined animation.
279
- * @param animation A reusable animation definition.
280
- * @returns A factory object that can create a player for the defined animation.
281
- * @see {@link animate}
282
- */
283
- abstract build(animation: AnimationMetadata | AnimationMetadata[]): AnimationFactory;
284
- static ɵfac: i0.ɵɵFactoryDeclaration<AnimationBuilder, never>;
285
- static ɵprov: i0.ɵɵInjectableDeclaration<AnimationBuilder>;
179
+ interface AnimationMetadata {
180
+ type: AnimationMetadataType;
286
181
  }
287
-
288
-
289
182
  /**
290
- * An instance of this class is returned as an event parameter when an animation
291
- * callback is captured for an animation either during the start or done phase.
292
- *
293
- * ```ts
294
- * @Component({
295
- * host: {
296
- * '[@myAnimationTrigger]': 'someExpression',
297
- * '(@myAnimationTrigger.start)': 'captureStartEvent($event)',
298
- * '(@myAnimationTrigger.done)': 'captureDoneEvent($event)',
299
- * },
300
- * animations: [
301
- * trigger("myAnimationTrigger", [
302
- * // ...
303
- * ])
304
- * ]
305
- * })
306
- * class MyComponent {
307
- * someExpression: any = false;
308
- * captureStartEvent(event: AnimationEvent) {
309
- * // the toState, fromState and totalTime data is accessible from the event variable
310
- * }
311
- *
312
- * captureDoneEvent(event: AnimationEvent) {
313
- * // the toState, fromState and totalTime data is accessible from the event variable
314
- * }
315
- * }
316
- * ```
183
+ * Contains an animation trigger. Instantiated and returned by the
184
+ * `trigger()` function.
317
185
  *
318
186
  * @publicApi
319
187
  */
320
- declare interface AnimationEvent_2 {
321
- /**
322
- * The name of the state from which the animation is triggered.
323
- */
324
- fromState: string;
188
+ interface AnimationTriggerMetadata extends AnimationMetadata {
325
189
  /**
326
- * The name of the state in which the animation completes.
190
+ * The trigger name, used to associate it with an element. Unique within the component.
327
191
  */
328
- toState: string;
192
+ name: string;
329
193
  /**
330
- * The time it takes the animation to complete, in milliseconds.
194
+ * An animation definition object, containing an array of state and transition declarations.
331
195
  */
332
- totalTime: number;
196
+ definitions: AnimationMetadata[];
333
197
  /**
334
- * The animation phase in which the callback was invoked, one of
335
- * "start" or "done".
198
+ * An options object containing a delay and
199
+ * developer-defined parameters that provide styling defaults and
200
+ * can be overridden on invocation. Default delay is 0.
336
201
  */
337
- phaseName: string;
202
+ options: {
203
+ params?: {
204
+ [name: string]: any;
205
+ };
206
+ } | null;
207
+ }
208
+ /**
209
+ * Encapsulates an animation state by associating a state name with a set of CSS styles.
210
+ * Instantiated and returned by the [`state()`](api/animations/state) function.
211
+ *
212
+ * @publicApi
213
+ */
214
+ interface AnimationStateMetadata extends AnimationMetadata {
338
215
  /**
339
- * The element to which the animation is attached.
216
+ * The state name, unique within the component.
340
217
  */
341
- element: any;
218
+ name: string;
342
219
  /**
343
- * Internal.
220
+ * The CSS styles associated with this state.
344
221
  */
345
- triggerName: string;
222
+ styles: AnimationStyleMetadata;
346
223
  /**
347
- * Internal.
224
+ * An options object containing
225
+ * developer-defined parameters that provide styling defaults and
226
+ * can be overridden on invocation.
348
227
  */
349
- disabled: boolean;
228
+ options?: {
229
+ params: {
230
+ [name: string]: any;
231
+ };
232
+ };
350
233
  }
351
- export { AnimationEvent_2 as AnimationEvent }
352
-
353
234
  /**
354
- * A factory object returned from the
355
- * <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
356
- * method.
235
+ * Encapsulates an animation transition. Instantiated and returned by the
236
+ * `transition()` function.
357
237
  *
358
238
  * @publicApi
359
239
  */
360
- export declare abstract class AnimationFactory {
240
+ interface AnimationTransitionMetadata extends AnimationMetadata {
361
241
  /**
362
- * Creates an `AnimationPlayer` instance for the reusable animation defined by
363
- * the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
364
- * method that created this factory and attaches the new player a DOM element.
365
- *
366
- * @param element The DOM element to which to attach the player.
367
- * @param options A set of options that can include a time delay and
368
- * additional developer-defined parameters.
242
+ * An expression that describes a state change.
369
243
  */
370
- abstract create(element: any, options?: AnimationOptions): AnimationPlayer;
244
+ expr: string | ((fromState: string, toState: string, element?: any, params?: {
245
+ [key: string]: any;
246
+ }) => boolean);
247
+ /**
248
+ * One or more animation objects to which this transition applies.
249
+ */
250
+ animation: AnimationMetadata | AnimationMetadata[];
251
+ /**
252
+ * An options object containing a delay and
253
+ * developer-defined parameters that provide styling defaults and
254
+ * can be overridden on invocation. Default delay is 0.
255
+ */
256
+ options: AnimationOptions | null;
371
257
  }
372
-
373
258
  /**
374
- * Encapsulates an animation group.
375
- * Instantiated and returned by the `group()` function.
259
+ * Encapsulates a reusable animation, which is a collection of individual animation steps.
260
+ * Instantiated and returned by the `animation()` function, and
261
+ * passed to the `useAnimation()` function.
376
262
  *
377
263
  * @publicApi
378
264
  */
379
- export declare interface AnimationGroupMetadata extends AnimationMetadata {
265
+ interface AnimationReferenceMetadata extends AnimationMetadata {
380
266
  /**
381
- * One or more animation or style steps that form this group.
267
+ * One or more animation step objects.
382
268
  */
383
- steps: AnimationMetadata[];
269
+ animation: AnimationMetadata | AnimationMetadata[];
384
270
  /**
385
271
  * An options object containing a delay and
386
272
  * developer-defined parameters that provide styling defaults and
@@ -388,261 +274,149 @@ export declare interface AnimationGroupMetadata extends AnimationMetadata {
388
274
  */
389
275
  options: AnimationOptions | null;
390
276
  }
391
-
277
+ /**
278
+ * Encapsulates an animation query. Instantiated and returned by
279
+ * the `query()` function.
280
+ *
281
+ * @publicApi
282
+ */
283
+ interface AnimationQueryMetadata extends AnimationMetadata {
284
+ /**
285
+ * The CSS selector for this query.
286
+ */
287
+ selector: string;
288
+ /**
289
+ * One or more animation step objects.
290
+ */
291
+ animation: AnimationMetadata | AnimationMetadata[];
292
+ /**
293
+ * A query options object.
294
+ */
295
+ options: AnimationQueryOptions | null;
296
+ }
392
297
  /**
393
298
  * Encapsulates a keyframes sequence. Instantiated and returned by
394
299
  * the `keyframes()` function.
395
300
  *
396
301
  * @publicApi
397
302
  */
398
- export declare interface AnimationKeyframesSequenceMetadata extends AnimationMetadata {
303
+ interface AnimationKeyframesSequenceMetadata extends AnimationMetadata {
399
304
  /**
400
305
  * An array of animation styles.
401
306
  */
402
307
  steps: AnimationStyleMetadata[];
403
308
  }
404
-
405
309
  /**
406
- * Base for animation data structures.
310
+ * Encapsulates an animation style. Instantiated and returned by
311
+ * the `style()` function.
407
312
  *
408
313
  * @publicApi
409
314
  */
410
- export declare interface AnimationMetadata {
411
- type: AnimationMetadataType;
315
+ interface AnimationStyleMetadata extends AnimationMetadata {
316
+ /**
317
+ * A set of CSS style properties.
318
+ */
319
+ styles: '*' | {
320
+ [key: string]: string | number;
321
+ } | Array<{
322
+ [key: string]: string | number;
323
+ } | '*'>;
324
+ /**
325
+ * A percentage of the total animate time at which the style is to be applied.
326
+ */
327
+ offset: number | null;
412
328
  }
413
-
414
329
  /**
415
- * @description Constants for the categories of parameters that can be defined for animations.
416
- *
417
- * A corresponding function defines a set of parameters for each category, and
418
- * collects them into a corresponding `AnimationMetadata` object.
330
+ * Encapsulates an animation step. Instantiated and returned by
331
+ * the `animate()` function.
419
332
  *
420
333
  * @publicApi
421
334
  */
422
- export declare enum AnimationMetadataType {
335
+ interface AnimationAnimateMetadata extends AnimationMetadata {
423
336
  /**
424
- * Associates a named animation state with a set of CSS styles.
425
- * See [`state()`](api/animations/state)
337
+ * The timing data for the step.
426
338
  */
427
- State = 0,
339
+ timings: string | number | AnimateTimings;
428
340
  /**
429
- * Data for a transition from one animation state to another.
430
- * See `transition()`
341
+ * A set of styles used in the step.
431
342
  */
432
- Transition = 1,
343
+ styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null;
344
+ }
345
+ /**
346
+ * Encapsulates a child animation, that can be run explicitly when the parent is run.
347
+ * Instantiated and returned by the `animateChild` function.
348
+ *
349
+ * @publicApi
350
+ */
351
+ interface AnimationAnimateChildMetadata extends AnimationMetadata {
433
352
  /**
434
- * Contains a set of animation steps.
435
- * See `sequence()`
353
+ * An options object containing a delay and
354
+ * developer-defined parameters that provide styling defaults and
355
+ * can be overridden on invocation. Default delay is 0.
436
356
  */
437
- Sequence = 2,
357
+ options: AnimationOptions | null;
358
+ }
359
+ /**
360
+ * Encapsulates a reusable animation.
361
+ * Instantiated and returned by the `useAnimation()` function.
362
+ *
363
+ * @publicApi
364
+ */
365
+ interface AnimationAnimateRefMetadata extends AnimationMetadata {
438
366
  /**
439
- * Contains a set of animation steps.
440
- * See `{@link /api/animations/group group()}`
367
+ * An animation reference object.
441
368
  */
442
- Group = 3,
369
+ animation: AnimationReferenceMetadata;
443
370
  /**
444
- * Contains an animation step.
445
- * See `animate()`
371
+ * An options object containing a delay and
372
+ * developer-defined parameters that provide styling defaults and
373
+ * can be overridden on invocation. Default delay is 0.
446
374
  */
447
- Animate = 4,
448
- /**
449
- * Contains a set of animation steps.
450
- * See `keyframes()`
451
- */
452
- Keyframes = 5,
453
- /**
454
- * Contains a set of CSS property-value pairs into a named style.
455
- * See `style()`
456
- */
457
- Style = 6,
458
- /**
459
- * Associates an animation with an entry trigger that can be attached to an element.
460
- * See `trigger()`
461
- */
462
- Trigger = 7,
463
- /**
464
- * Contains a re-usable animation.
465
- * See `animation()`
466
- */
467
- Reference = 8,
468
- /**
469
- * Contains data to use in executing child animations returned by a query.
470
- * See `animateChild()`
471
- */
472
- AnimateChild = 9,
473
- /**
474
- * Contains animation parameters for a re-usable animation.
475
- * See `useAnimation()`
476
- */
477
- AnimateRef = 10,
478
- /**
479
- * Contains child-animation query data.
480
- * See `query()`
481
- */
482
- Query = 11,
483
- /**
484
- * Contains data for staggering an animation sequence.
485
- * See `stagger()`
486
- */
487
- Stagger = 12
488
- }
489
-
490
- /**
491
- * @description Options that control animation styling and timing.
492
- *
493
- * The following animation functions accept `AnimationOptions` data:
494
- *
495
- * - `transition()`
496
- * - `sequence()`
497
- * - `{@link /api/animations/group group()}`
498
- * - `query()`
499
- * - `animation()`
500
- * - `useAnimation()`
501
- * - `animateChild()`
502
- *
503
- * Programmatic animations built using the `AnimationBuilder` service also
504
- * make use of `AnimationOptions`.
505
- *
506
- * @publicApi
507
- */
508
- export declare interface AnimationOptions {
509
- /**
510
- * Sets a time-delay for initiating an animation action.
511
- * A number and optional time unit, such as "1s" or "10ms" for one second
512
- * and 10 milliseconds, respectively.The default unit is milliseconds.
513
- * Default value is 0, meaning no delay.
514
- */
515
- delay?: number | string;
516
- /**
517
- * A set of developer-defined parameters that modify styling and timing
518
- * when an animation action starts. An array of key-value pairs, where the provided value
519
- * is used as a default.
520
- */
521
- params?: {
522
- [name: string]: any;
523
- };
375
+ options: AnimationOptions | null;
524
376
  }
525
-
526
-
527
377
  /**
528
- * Provides programmatic control of a reusable animation sequence,
529
- * built using the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
530
- * method which returns an `AnimationFactory`, whose
531
- * <code>[create](api/animations/AnimationFactory#create)()</code> method instantiates and
532
- * initializes this interface.
533
- *
534
- * @see {@link AnimationBuilder}
535
- * @see {@link AnimationFactory}
536
- * @see {@link animate}
378
+ * Encapsulates an animation sequence.
379
+ * Instantiated and returned by the `sequence()` function.
537
380
  *
538
381
  * @publicApi
539
382
  */
540
- export declare interface AnimationPlayer {
541
- /**
542
- * Provides a callback to invoke when the animation finishes.
543
- * @param fn The callback function.
544
- * @see {@link #finish}
545
- */
546
- onDone(fn: () => void): void;
547
- /**
548
- * Provides a callback to invoke when the animation starts.
549
- * @param fn The callback function.
550
- * @see {@link #play}
551
- */
552
- onStart(fn: () => void): void;
553
- /**
554
- * Provides a callback to invoke after the animation is destroyed.
555
- * @param fn The callback function.
556
- * @see {@link #destroy}
557
- * @see {@link #beforeDestroy}
558
- */
559
- onDestroy(fn: () => void): void;
560
- /**
561
- * Initializes the animation.
562
- */
563
- init(): void;
564
- /**
565
- * Reports whether the animation has started.
566
- * @returns True if the animation has started, false otherwise.
567
- */
568
- hasStarted(): boolean;
569
- /**
570
- * Runs the animation, invoking the `onStart()` callback.
571
- */
572
- play(): void;
573
- /**
574
- * Pauses the animation.
575
- */
576
- pause(): void;
577
- /**
578
- * Restarts the paused animation.
579
- */
580
- restart(): void;
383
+ interface AnimationSequenceMetadata extends AnimationMetadata {
581
384
  /**
582
- * Ends the animation, invoking the `onDone()` callback.
583
- */
584
- finish(): void;
585
- /**
586
- * Destroys the animation, after invoking the `beforeDestroy()` callback.
587
- * Calls the `onDestroy()` callback when destruction is completed.
588
- */
589
- destroy(): void;
590
- /**
591
- * Resets the animation to its initial state.
592
- */
593
- reset(): void;
594
- /**
595
- * Sets the position of the animation.
596
- * @param position A fractional value, representing the progress through the animation.
597
- */
598
- setPosition(position: number): void;
599
- /**
600
- * Reports the current position of the animation.
601
- * @returns A fractional value, representing the progress through the animation.
602
- */
603
- getPosition(): number;
604
- /**
605
- * The parent of this player, if any.
606
- */
607
- parentPlayer: AnimationPlayer | null;
608
- /**
609
- * The total run time of the animation, in milliseconds.
385
+ * An array of animation step objects.
610
386
  */
611
- readonly totalTime: number;
387
+ steps: AnimationMetadata[];
612
388
  /**
613
- * Provides a callback to invoke before the animation is destroyed.
389
+ * An options object containing a delay and
390
+ * developer-defined parameters that provide styling defaults and
391
+ * can be overridden on invocation. Default delay is 0.
614
392
  */
615
- beforeDestroy?: () => any;
393
+ options: AnimationOptions | null;
616
394
  }
617
-
618
395
  /**
619
- * Encapsulates an animation query. Instantiated and returned by
620
- * the `query()` function.
396
+ * Encapsulates an animation group.
397
+ * Instantiated and returned by the `group()` function.
621
398
  *
622
399
  * @publicApi
623
400
  */
624
- export declare interface AnimationQueryMetadata extends AnimationMetadata {
625
- /**
626
- * The CSS selector for this query.
627
- */
628
- selector: string;
401
+ interface AnimationGroupMetadata extends AnimationMetadata {
629
402
  /**
630
- * One or more animation step objects.
403
+ * One or more animation or style steps that form this group.
631
404
  */
632
- animation: AnimationMetadata | AnimationMetadata[];
405
+ steps: AnimationMetadata[];
633
406
  /**
634
- * A query options object.
407
+ * An options object containing a delay and
408
+ * developer-defined parameters that provide styling defaults and
409
+ * can be overridden on invocation. Default delay is 0.
635
410
  */
636
- options: AnimationQueryOptions | null;
411
+ options: AnimationOptions | null;
637
412
  }
638
-
639
413
  /**
640
414
  * Encapsulates animation query options.
641
415
  * Passed to the `query()` function.
642
416
  *
643
417
  * @publicApi
644
418
  */
645
- export declare interface AnimationQueryOptions extends AnimationOptions {
419
+ declare interface AnimationQueryOptions extends AnimationOptions {
646
420
  /**
647
421
  * True if this query is optional, false if it is required. Default is false.
648
422
  * A required query throws an error if no elements are retrieved when
@@ -657,53 +431,13 @@ export declare interface AnimationQueryOptions extends AnimationOptions {
657
431
  */
658
432
  limit?: number;
659
433
  }
660
-
661
- /**
662
- * Encapsulates a reusable animation, which is a collection of individual animation steps.
663
- * Instantiated and returned by the `animation()` function, and
664
- * passed to the `useAnimation()` function.
665
- *
666
- * @publicApi
667
- */
668
- export declare interface AnimationReferenceMetadata extends AnimationMetadata {
669
- /**
670
- * One or more animation step objects.
671
- */
672
- animation: AnimationMetadata | AnimationMetadata[];
673
- /**
674
- * An options object containing a delay and
675
- * developer-defined parameters that provide styling defaults and
676
- * can be overridden on invocation. Default delay is 0.
677
- */
678
- options: AnimationOptions | null;
679
- }
680
-
681
- /**
682
- * Encapsulates an animation sequence.
683
- * Instantiated and returned by the `sequence()` function.
684
- *
685
- * @publicApi
686
- */
687
- export declare interface AnimationSequenceMetadata extends AnimationMetadata {
688
- /**
689
- * An array of animation step objects.
690
- */
691
- steps: AnimationMetadata[];
692
- /**
693
- * An options object containing a delay and
694
- * developer-defined parameters that provide styling defaults and
695
- * can be overridden on invocation. Default delay is 0.
696
- */
697
- options: AnimationOptions | null;
698
- }
699
-
700
434
  /**
701
435
  * Encapsulates parameters for staggering the start times of a set of animation steps.
702
436
  * Instantiated and returned by the `stagger()` function.
703
437
  *
704
438
  * @publicApi
705
439
  **/
706
- export declare interface AnimationStaggerMetadata extends AnimationMetadata {
440
+ interface AnimationStaggerMetadata extends AnimationMetadata {
707
441
  /**
708
442
  * The timing data for the steps.
709
443
  */
@@ -713,358 +447,248 @@ export declare interface AnimationStaggerMetadata extends AnimationMetadata {
713
447
  */
714
448
  animation: AnimationMetadata | AnimationMetadata[];
715
449
  }
716
-
717
- /**
718
- * Encapsulates an animation state by associating a state name with a set of CSS styles.
719
- * Instantiated and returned by the [`state()`](api/animations/state) function.
720
- *
721
- * @publicApi
722
- */
723
- export declare interface AnimationStateMetadata extends AnimationMetadata {
724
- /**
725
- * The state name, unique within the component.
726
- */
727
- name: string;
728
- /**
729
- * The CSS styles associated with this state.
730
- */
731
- styles: AnimationStyleMetadata;
732
- /**
733
- * An options object containing
734
- * developer-defined parameters that provide styling defaults and
735
- * can be overridden on invocation.
736
- */
737
- options?: {
738
- params: {
739
- [name: string]: any;
740
- };
741
- };
742
- }
743
-
744
450
  /**
745
- * Encapsulates an animation style. Instantiated and returned by
746
- * the `style()` function.
451
+ * Creates a named animation trigger, containing a list of [`state()`](api/animations/state)
452
+ * and `transition()` entries to be evaluated when the expression
453
+ * bound to the trigger changes.
747
454
  *
748
- * @publicApi
749
- */
750
- export declare interface AnimationStyleMetadata extends AnimationMetadata {
751
- /**
752
- * A set of CSS style properties.
753
- */
754
- styles: '*' | {
755
- [key: string]: string | number;
756
- } | Array<{
757
- [key: string]: string | number;
758
- } | '*'>;
759
- /**
760
- * A percentage of the total animate time at which the style is to be applied.
761
- */
762
- offset: number | null;
763
- }
764
-
765
- /**
766
- * Encapsulates an animation transition. Instantiated and returned by the
767
- * `transition()` function.
455
+ * @param name An identifying string.
456
+ * @param definitions An animation definition object, containing an array of
457
+ * [`state()`](api/animations/state) and `transition()` declarations.
768
458
  *
769
- * @publicApi
770
- */
771
- export declare interface AnimationTransitionMetadata extends AnimationMetadata {
772
- /**
773
- * An expression that describes a state change.
774
- */
775
- expr: string | ((fromState: string, toState: string, element?: any, params?: {
776
- [key: string]: any;
777
- }) => boolean);
778
- /**
779
- * One or more animation objects to which this transition applies.
780
- */
781
- animation: AnimationMetadata | AnimationMetadata[];
782
- /**
783
- * An options object containing a delay and
784
- * developer-defined parameters that provide styling defaults and
785
- * can be overridden on invocation. Default delay is 0.
786
- */
787
- options: AnimationOptions | null;
788
- }
789
-
790
- /**
791
- * Contains an animation trigger. Instantiated and returned by the
792
- * `trigger()` function.
459
+ * @return An object that encapsulates the trigger data.
793
460
  *
794
- * @publicApi
795
- */
796
- export declare interface AnimationTriggerMetadata extends AnimationMetadata {
797
- /**
798
- * The trigger name, used to associate it with an element. Unique within the component.
799
- */
800
- name: string;
801
- /**
802
- * An animation definition object, containing an array of state and transition declarations.
803
- */
804
- definitions: AnimationMetadata[];
805
- /**
806
- * An options object containing a delay and
807
- * developer-defined parameters that provide styling defaults and
808
- * can be overridden on invocation. Default delay is 0.
809
- */
810
- options: {
811
- params?: {
812
- [name: string]: any;
813
- };
814
- } | null;
815
- }
816
-
817
- /**
818
- * Specifies automatic styling.
461
+ * @usageNotes
462
+ * Define an animation trigger in the `animations` section of `@Component` metadata.
463
+ * In the template, reference the trigger by name and bind it to a trigger expression that
464
+ * evaluates to a defined animation state, using the following format:
819
465
  *
820
- * @publicApi
821
- */
822
- export declare const AUTO_STYLE = "*";
823
-
824
- /**
825
- * @description Defines a list of animation steps to be run in parallel.
466
+ * `[@triggerName]="expression"`
826
467
  *
827
- * @param steps An array of animation step objects.
828
- * - When steps are defined by `style()` or `animate()`
829
- * function calls, each call within the group is executed instantly.
830
- * - To specify offset styles to be applied at a later time, define steps with
831
- * `keyframes()`, or use `animate()` calls with a delay value.
832
- * For example:
468
+ * Animation trigger bindings convert all values to strings, and then match the
469
+ * previous and current values against any linked transitions.
470
+ * Booleans can be specified as `1` or `true` and `0` or `false`.
471
+ *
472
+ * ### Usage Example
473
+ *
474
+ * The following example creates an animation trigger reference based on the provided
475
+ * name value.
476
+ * The provided animation value is expected to be an array consisting of state and
477
+ * transition declarations.
833
478
  *
834
479
  * ```ts
835
- * group([
836
- * animate("1s", style({ background: "black" })),
837
- * animate("2s", style({ color: "white" }))
838
- * ])
480
+ * @Component({
481
+ * selector: "my-component",
482
+ * templateUrl: "my-component-tpl.html",
483
+ * animations: [
484
+ * trigger("myAnimationTrigger", [
485
+ * state(...),
486
+ * state(...),
487
+ * transition(...),
488
+ * transition(...)
489
+ * ])
490
+ * ]
491
+ * })
492
+ * class MyComponent {
493
+ * myStatusExp = "something";
494
+ * }
839
495
  * ```
840
496
  *
841
- * @param options An options object containing a delay and
842
- * developer-defined parameters that provide styling defaults and
843
- * can be overridden on invocation.
497
+ * The template associated with this component makes use of the defined trigger
498
+ * by binding to an element within its template code.
844
499
  *
845
- * @return An object that encapsulates the group data.
500
+ * ```html
501
+ * <!-- somewhere inside of my-component-tpl.html -->
502
+ * <div [@myAnimationTrigger]="myStatusExp">...</div>
503
+ * ```
846
504
  *
847
- * @usageNotes
848
- * Grouped animations are useful when a series of styles must be
849
- * animated at different starting times and closed off at different ending times.
505
+ * ### Using an inline function
506
+ * The `transition` animation method also supports reading an inline function which can decide
507
+ * if its associated animation should be run.
850
508
  *
851
- * When called within a `sequence()` or a
852
- * `transition()` call, does not continue to the next
853
- * instruction until all of the inner animation steps have completed.
509
+ * ```ts
510
+ * // this method is run each time the `myAnimationTrigger` trigger value changes.
511
+ * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
512
+ string]: any}): boolean {
513
+ * // notice that `element` and `params` are also available here
514
+ * return toState == 'yes-please-animate';
515
+ * }
854
516
  *
855
- * @publicApi
856
- */
857
- export declare function group(steps: AnimationMetadata[], options?: AnimationOptions | null): AnimationGroupMetadata;
858
-
859
- /**
860
- * Defines a set of animation styles, associating each style with an optional `offset` value.
517
+ * @Component({
518
+ * selector: 'my-component',
519
+ * templateUrl: 'my-component-tpl.html',
520
+ * animations: [
521
+ * trigger('myAnimationTrigger', [
522
+ * transition(myInlineMatcherFn, [
523
+ * // the animation sequence code
524
+ * ]),
525
+ * ])
526
+ * ]
527
+ * })
528
+ * class MyComponent {
529
+ * myStatusExp = "yes-please-animate";
530
+ * }
531
+ * ```
861
532
  *
862
- * @param steps A set of animation styles with optional offset data.
863
- * The optional `offset` value for a style specifies a percentage of the total animation
864
- * time at which that style is applied.
865
- * @returns An object that encapsulates the keyframes data.
533
+ * ### Disabling Animations
534
+ * When true, the special animation control binding `@.disabled` binding prevents
535
+ * all animations from rendering.
536
+ * Place the `@.disabled` binding on an element to disable
537
+ * animations on the element itself, as well as any inner animation triggers
538
+ * within the element.
866
539
  *
867
- * @usageNotes
868
- * Use with the `animate()` call. Instead of applying animations
869
- * from the current state
870
- * to the destination state, keyframes describe how each style entry is applied and at what point
871
- * within the animation arc.
872
- * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
540
+ * The following example shows how to use this feature:
873
541
  *
874
- * ### Usage
542
+ * ```angular-ts
543
+ * @Component({
544
+ * selector: 'my-component',
545
+ * template: `
546
+ * <div [@.disabled]="isDisabled">
547
+ * <div [@childAnimation]="exp"></div>
548
+ * </div>
549
+ * `,
550
+ * animations: [
551
+ * trigger("childAnimation", [
552
+ * // ...
553
+ * ])
554
+ * ]
555
+ * })
556
+ * class MyComponent {
557
+ * isDisabled = true;
558
+ * exp = '...';
559
+ * }
560
+ * ```
875
561
  *
876
- * In the following example, the offset values describe
877
- * when each `backgroundColor` value is applied. The color is red at the start, and changes to
878
- * blue when 20% of the total time has elapsed.
562
+ * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,
563
+ * along with any inner animations.
564
+ *
565
+ * ### Disable animations application-wide
566
+ * When an area of the template is set to have animations disabled,
567
+ * **all** inner components have their animations disabled as well.
568
+ * This means that you can disable all animations for an app
569
+ * by placing a host binding set on `@.disabled` on the topmost Angular component.
879
570
  *
880
571
  * ```ts
881
- * // the provided offset values
882
- * animate("5s", keyframes([
883
- * style({ backgroundColor: "red", offset: 0 }),
884
- * style({ backgroundColor: "blue", offset: 0.2 }),
885
- * style({ backgroundColor: "orange", offset: 0.3 }),
886
- * style({ backgroundColor: "black", offset: 1 })
887
- * ]))
888
- * ```
572
+ * import {Component, HostBinding} from '@angular/core';
889
573
  *
890
- * If there are no `offset` values specified in the style entries, the offsets
891
- * are calculated automatically.
574
+ * @Component({
575
+ * selector: 'app-component',
576
+ * templateUrl: 'app.component.html',
577
+ * })
578
+ * class AppComponent {
579
+ * @HostBinding('@.disabled')
580
+ * public animationsDisabled = true;
581
+ * }
582
+ * ```
892
583
  *
893
- * ```ts
894
- * animate("5s", keyframes([
895
- * style({ backgroundColor: "red" }) // offset = 0
896
- * style({ backgroundColor: "blue" }) // offset = 0.33
897
- * style({ backgroundColor: "orange" }) // offset = 0.66
898
- * style({ backgroundColor: "black" }) // offset = 1
899
- * ]))
900
- *```
901
-
902
- * @publicApi
903
- */
904
- export declare function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSequenceMetadata;
905
-
906
- /**
907
- * An empty programmatic controller for reusable animations.
908
- * Used internally when animations are disabled, to avoid
909
- * checking for the null case when an animation player is expected.
584
+ * ### Overriding disablement of inner animations
585
+ * Despite inner animations being disabled, a parent animation can `query()`
586
+ * for inner elements located in disabled areas of the template and still animate
587
+ * them if needed. This is also the case for when a sub animation is
588
+ * queried by a parent and then later animated using `animateChild()`.
910
589
  *
911
- * @see {@link animate}
912
- * @see {@link AnimationPlayer}
590
+ * ### Detecting when an animation is disabled
591
+ * If a region of the DOM (or the entire application) has its animations disabled, the animation
592
+ * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
593
+ * an instance of an `AnimationEvent`. If animations are disabled,
594
+ * the `.disabled` flag on the event is true.
913
595
  *
914
596
  * @publicApi
915
597
  */
916
- export declare class NoopAnimationPlayer implements AnimationPlayer {
917
- private _onDoneFns;
918
- private _onStartFns;
919
- private _onDestroyFns;
920
- private _originalOnDoneFns;
921
- private _originalOnStartFns;
922
- private _started;
923
- private _destroyed;
924
- private _finished;
925
- private _position;
926
- parentPlayer: AnimationPlayer | null;
927
- readonly totalTime: number;
928
- constructor(duration?: number, delay?: number);
929
- private _onFinish;
930
- onStart(fn: () => void): void;
931
- onDone(fn: () => void): void;
932
- onDestroy(fn: () => void): void;
933
- hasStarted(): boolean;
934
- init(): void;
935
- play(): void;
936
- private _onStart;
937
- pause(): void;
938
- restart(): void;
939
- finish(): void;
940
- destroy(): void;
941
- reset(): void;
942
- setPosition(position: number): void;
943
- getPosition(): number;
944
- }
945
-
598
+ declare function trigger(name: string, definitions: AnimationMetadata[]): AnimationTriggerMetadata;
946
599
  /**
947
- * Finds one or more inner elements within the current element that is
948
- * being animated within a sequence. Use with `animate()`.
600
+ * Defines an animation step that combines styling information with timing information.
949
601
  *
950
- * @param selector The element to query, or a set of elements that contain Angular-specific
951
- * characteristics, specified with one or more of the following tokens.
952
- * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements (not
953
- * all elements can be queried via these tokens, see
954
- * [Entering and Leaving Elements](#entering-and-leaving-elements))
955
- * - `query(":animating")` : Query all currently animating elements.
956
- * - `query("@triggerName")` : Query elements that contain an animation trigger.
957
- * - `query("@*")` : Query all elements that contain an animation triggers.
958
- * - `query(":self")` : Include the current element into the animation sequence.
602
+ * @param timings Sets `AnimateTimings` for the parent animation.
603
+ * A string in the format "duration [delay] [easing]".
604
+ * - Duration and delay are expressed as a number and optional time unit,
605
+ * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
606
+ * The default unit is milliseconds.
607
+ * - The easing value controls how the animation accelerates and decelerates
608
+ * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
609
+ * `ease-in-out`, or a `cubic-bezier()` function call.
610
+ * If not supplied, no easing is applied.
959
611
  *
960
- * @param animation One or more animation steps to apply to the queried element or elements.
961
- * An array is treated as an animation sequence.
962
- * @param options An options object. Use the 'limit' field to limit the total number of
963
- * items to collect.
964
- * @return An object that encapsulates the query data.
612
+ * For example, the string "1s 100ms ease-out" specifies a duration of
613
+ * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
614
+ * which decelerates near the end of the duration.
615
+ * @param styles Sets AnimationStyles for the parent animation.
616
+ * A function call to either `style()` or `keyframes()`
617
+ * that returns a collection of CSS style entries to be applied to the parent animation.
618
+ * When null, uses the styles from the destination state.
619
+ * This is useful when describing an animation step that will complete an animation;
620
+ * see "Animating to the final state" in `transitions()`.
621
+ * @returns An object that encapsulates the animation step.
965
622
  *
966
623
  * @usageNotes
624
+ * Call within an animation `sequence()`, {@link /api/animations/group group()}, or
625
+ * `transition()` call to specify an animation step
626
+ * that applies given style data to the parent animation for a given amount of time.
967
627
  *
968
- * ### Multiple Tokens
969
- *
970
- * Tokens can be merged into a combined query selector string. For example:
628
+ * ### Syntax Examples
629
+ * **Timing examples**
971
630
  *
972
- * ```ts
973
- * query(':self, .record:enter, .record:leave, @subTrigger', [...])
974
- * ```
631
+ * The following examples show various `timings` specifications.
632
+ * - `animate(500)` : Duration is 500 milliseconds.
633
+ * - `animate("1s")` : Duration is 1000 milliseconds.
634
+ * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
635
+ * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
636
+ * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
637
+ * milliseconds, easing according to a bezier curve.
975
638
  *
976
- * The `query()` function collects multiple elements and works internally by using
977
- * `element.querySelectorAll`. Use the `limit` field of an options object to limit
978
- * the total number of items to be collected. For example:
639
+ * **Style examples**
979
640
  *
980
- * ```js
981
- * query('div', [
982
- * animate(...),
983
- * animate(...)
984
- * ], { limit: 1 })
641
+ * The following example calls `style()` to set a single CSS style.
642
+ * ```ts
643
+ * animate(500, style({ background: "red" }))
985
644
  * ```
986
- *
987
- * By default, throws an error when zero items are found. Set the
988
- * `optional` flag to ignore this error. For example:
989
- *
990
- * ```js
991
- * query('.some-element-that-may-not-be-there', [
992
- * animate(...),
993
- * animate(...)
994
- * ], { optional: true })
645
+ * The following example calls `keyframes()` to set a CSS style
646
+ * to different values for successive keyframes.
647
+ * ```ts
648
+ * animate(500, keyframes(
649
+ * [
650
+ * style({ background: "blue" }),
651
+ * style({ background: "red" })
652
+ * ])
995
653
  * ```
996
654
  *
997
- * ### Entering and Leaving Elements
998
- *
999
- * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones
1000
- * that can are those that Angular assumes can enter/leave based on their own logic
1001
- * (if their insertion/removal is simply a consequence of that of their parent they
1002
- * should be queried via a different token in their parent's `:enter`/`:leave` transitions).
1003
- *
1004
- * The only elements Angular assumes can enter/leave based on their own logic (thus the only
1005
- * ones that can be queried via the `:enter` and `:leave` tokens) are:
1006
- * - Those inserted dynamically (via `ViewContainerRef`)
1007
- * - Those that have a structural directive (which, under the hood, are a subset of the above ones)
1008
- *
1009
- * <div class="docs-alert docs-alert-helpful">
1010
- *
1011
- * Note that elements will be successfully queried via `:enter`/`:leave` even if their
1012
- * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural
1013
- * directive (e.g. they enter/exit alongside their parent).
1014
- *
1015
- * </div>
1016
- *
1017
- * <div class="docs-alert docs-alert-important">
1018
- *
1019
- * There is an exception to what previously mentioned, besides elements entering/leaving based on
1020
- * their own logic, elements with an animation trigger can always be queried via `:leave` when
1021
- * their parent is also leaving.
655
+ * @publicApi
656
+ */
657
+ declare function animate(timings: string | number, styles?: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null): AnimationAnimateMetadata;
658
+ /**
659
+ * @description Defines a list of animation steps to be run in parallel.
1022
660
  *
1023
- * </div>
661
+ * @param steps An array of animation step objects.
662
+ * - When steps are defined by `style()` or `animate()`
663
+ * function calls, each call within the group is executed instantly.
664
+ * - To specify offset styles to be applied at a later time, define steps with
665
+ * `keyframes()`, or use `animate()` calls with a delay value.
666
+ * For example:
1024
667
  *
1025
- * ### Usage Example
668
+ * ```ts
669
+ * group([
670
+ * animate("1s", style({ background: "black" })),
671
+ * animate("2s", style({ color: "white" }))
672
+ * ])
673
+ * ```
1026
674
  *
1027
- * The following example queries for inner elements and animates them
1028
- * individually using `animate()`.
675
+ * @param options An options object containing a delay and
676
+ * developer-defined parameters that provide styling defaults and
677
+ * can be overridden on invocation.
1029
678
  *
1030
- * ```angular-ts
1031
- * @Component({
1032
- * selector: 'inner',
1033
- * template: `
1034
- * <div [@queryAnimation]="exp">
1035
- * <h1>Title</h1>
1036
- * <div class="content">
1037
- * Blah blah blah
1038
- * </div>
1039
- * </div>
1040
- * `,
1041
- * animations: [
1042
- * trigger('queryAnimation', [
1043
- * transition('* => goAnimate', [
1044
- * // hide the inner elements
1045
- * query('h1', style({ opacity: 0 })),
1046
- * query('.content', style({ opacity: 0 })),
679
+ * @return An object that encapsulates the group data.
1047
680
  *
1048
- * // animate the inner elements in, one by one
1049
- * query('h1', animate(1000, style({ opacity: 1 }))),
1050
- * query('.content', animate(1000, style({ opacity: 1 }))),
1051
- * ])
1052
- * ])
1053
- * ]
1054
- * })
1055
- * class Cmp {
1056
- * exp = '';
681
+ * @usageNotes
682
+ * Grouped animations are useful when a series of styles must be
683
+ * animated at different starting times and closed off at different ending times.
1057
684
  *
1058
- * goAnimate() {
1059
- * this.exp = 'goAnimate';
1060
- * }
1061
- * }
1062
- * ```
685
+ * When called within a `sequence()` or a
686
+ * `transition()` call, does not continue to the next
687
+ * instruction until all of the inner animation steps have completed.
1063
688
  *
1064
689
  * @publicApi
1065
690
  */
1066
- export declare function query(selector: string, animation: AnimationMetadata | AnimationMetadata[], options?: AnimationQueryOptions | null): AnimationQueryMetadata;
1067
-
691
+ declare function group(steps: AnimationMetadata[], options?: AnimationOptions | null): AnimationGroupMetadata;
1068
692
  /**
1069
693
  * Defines a list of animation steps to be run sequentially, one by one.
1070
694
  *
@@ -1098,90 +722,51 @@ export declare function query(selector: string, animation: AnimationMetadata | A
1098
722
  *
1099
723
  * @publicApi
1100
724
  **/
1101
- export declare function sequence(steps: AnimationMetadata[], options?: AnimationOptions | null): AnimationSequenceMetadata;
1102
-
725
+ declare function sequence(steps: AnimationMetadata[], options?: AnimationOptions | null): AnimationSequenceMetadata;
1103
726
  /**
1104
- * Use within an animation `query()` call to issue a timing gap after
1105
- * each queried item is animated.
1106
- *
1107
- * @param timings A delay value.
1108
- * @param animation One ore more animation steps.
1109
- * @returns An object that encapsulates the stagger data.
1110
- *
1111
- * @usageNotes
1112
- * In the following example, a container element wraps a list of items stamped out
1113
- * by an `ngFor`. The container element contains an animation trigger that will later be set
1114
- * to query for each of the inner items.
1115
- *
1116
- * Each time items are added, the opacity fade-in animation runs,
1117
- * and each removed item is faded out.
1118
- * When either of these animations occur, the stagger effect is
1119
- * applied after each item's animation is started.
1120
- *
1121
- * ```html
1122
- * <!-- list.component.html -->
1123
- * <button (click)="toggle()">Show / Hide Items</button>
1124
- * <hr />
1125
- * <div [@listAnimation]="items.length">
1126
- * <div *ngFor="let item of items">
1127
- * {{ item }}
1128
- * </div>
1129
- * </div>
1130
- * ```
1131
- *
1132
- * Here is the component code:
727
+ * Declares a key/value object containing CSS properties/styles that
728
+ * can then be used for an animation [`state`](api/animations/state), within an animation
729
+ *`sequence`, or as styling data for calls to `animate()` and `keyframes()`.
1133
730
  *
1134
- * ```ts
1135
- * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';
1136
- * @Component({
1137
- * templateUrl: 'list.component.html',
1138
- * animations: [
1139
- * trigger('listAnimation', [
1140
- * ...
1141
- * ])
1142
- * ]
1143
- * })
1144
- * class ListComponent {
1145
- * items = [];
731
+ * @param tokens A set of CSS styles or HTML styles associated with an animation state.
732
+ * The value can be any of the following:
733
+ * - A key-value style pair associating a CSS property with a value.
734
+ * - An array of key-value style pairs.
735
+ * - An asterisk (*), to use auto-styling, where styles are derived from the element
736
+ * being animated and applied to the animation when it starts.
1146
737
  *
1147
- * showItems() {
1148
- * this.items = [0,1,2,3,4];
1149
- * }
738
+ * Auto-styling can be used to define a state that depends on layout or other
739
+ * environmental factors.
1150
740
  *
1151
- * hideItems() {
1152
- * this.items = [];
1153
- * }
741
+ * @return An object that encapsulates the style data.
1154
742
  *
1155
- * toggle() {
1156
- * this.items.length ? this.hideItems() : this.showItems();
1157
- * }
1158
- * }
743
+ * @usageNotes
744
+ * The following examples create animation styles that collect a set of
745
+ * CSS property values:
746
+ *
747
+ * ```ts
748
+ * // string values for CSS properties
749
+ * style({ background: "red", color: "blue" })
750
+ *
751
+ * // numerical pixel values
752
+ * style({ width: 100, height: 0 })
1159
753
  * ```
1160
754
  *
1161
- * Here is the animation trigger code:
755
+ * The following example uses auto-styling to allow an element to animate from
756
+ * a height of 0 up to its full height:
1162
757
  *
1163
758
  * ```ts
1164
- * trigger('listAnimation', [
1165
- * transition('* => *', [ // each time the binding value changes
1166
- * query(':leave', [
1167
- * stagger(100, [
1168
- * animate('0.5s', style({ opacity: 0 }))
1169
- * ])
1170
- * ]),
1171
- * query(':enter', [
1172
- * style({ opacity: 0 }),
1173
- * stagger(100, [
1174
- * animate('0.5s', style({ opacity: 1 }))
1175
- * ])
1176
- * ])
1177
- * ])
1178
- * ])
759
+ * style({ height: 0 }),
760
+ * animate("1s", style({ height: "*" }))
1179
761
  * ```
1180
762
  *
1181
763
  * @publicApi
1182
- */
1183
- export declare function stagger(timings: string | number, animation: AnimationMetadata | AnimationMetadata[]): AnimationStaggerMetadata;
1184
-
764
+ **/
765
+ declare function style(tokens: '*' | {
766
+ [key: string]: string | number;
767
+ } | Array<'*' | {
768
+ [key: string]: string | number;
769
+ }>): AnimationStyleMetadata;
1185
770
  /**
1186
771
  * Declares an animation state within a trigger attached to an element.
1187
772
  *
@@ -1211,57 +796,57 @@ export declare function stagger(timings: string | number, animation: AnimationMe
1211
796
  *
1212
797
  * @publicApi
1213
798
  **/
1214
- export declare function state(name: string, styles: AnimationStyleMetadata, options?: {
799
+ declare function state(name: string, styles: AnimationStyleMetadata, options?: {
1215
800
  params: {
1216
801
  [name: string]: any;
1217
802
  };
1218
803
  }): AnimationStateMetadata;
1219
-
1220
804
  /**
1221
- * Declares a key/value object containing CSS properties/styles that
1222
- * can then be used for an animation [`state`](api/animations/state), within an animation
1223
- *`sequence`, or as styling data for calls to `animate()` and `keyframes()`.
805
+ * Defines a set of animation styles, associating each style with an optional `offset` value.
1224
806
  *
1225
- * @param tokens A set of CSS styles or HTML styles associated with an animation state.
1226
- * The value can be any of the following:
1227
- * - A key-value style pair associating a CSS property with a value.
1228
- * - An array of key-value style pairs.
1229
- * - An asterisk (*), to use auto-styling, where styles are derived from the element
1230
- * being animated and applied to the animation when it starts.
807
+ * @param steps A set of animation styles with optional offset data.
808
+ * The optional `offset` value for a style specifies a percentage of the total animation
809
+ * time at which that style is applied.
810
+ * @returns An object that encapsulates the keyframes data.
1231
811
  *
1232
- * Auto-styling can be used to define a state that depends on layout or other
1233
- * environmental factors.
812
+ * @usageNotes
813
+ * Use with the `animate()` call. Instead of applying animations
814
+ * from the current state
815
+ * to the destination state, keyframes describe how each style entry is applied and at what point
816
+ * within the animation arc.
817
+ * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
1234
818
  *
1235
- * @return An object that encapsulates the style data.
819
+ * ### Usage
1236
820
  *
1237
- * @usageNotes
1238
- * The following examples create animation styles that collect a set of
1239
- * CSS property values:
821
+ * In the following example, the offset values describe
822
+ * when each `backgroundColor` value is applied. The color is red at the start, and changes to
823
+ * blue when 20% of the total time has elapsed.
1240
824
  *
1241
825
  * ```ts
1242
- * // string values for CSS properties
1243
- * style({ background: "red", color: "blue" })
1244
- *
1245
- * // numerical pixel values
1246
- * style({ width: 100, height: 0 })
826
+ * // the provided offset values
827
+ * animate("5s", keyframes([
828
+ * style({ backgroundColor: "red", offset: 0 }),
829
+ * style({ backgroundColor: "blue", offset: 0.2 }),
830
+ * style({ backgroundColor: "orange", offset: 0.3 }),
831
+ * style({ backgroundColor: "black", offset: 1 })
832
+ * ]))
1247
833
  * ```
1248
834
  *
1249
- * The following example uses auto-styling to allow an element to animate from
1250
- * a height of 0 up to its full height:
835
+ * If there are no `offset` values specified in the style entries, the offsets
836
+ * are calculated automatically.
1251
837
  *
1252
838
  * ```ts
1253
- * style({ height: 0 }),
1254
- * animate("1s", style({ height: "*" }))
1255
- * ```
1256
- *
1257
- * @publicApi
1258
- **/
1259
- export declare function style(tokens: '*' | {
1260
- [key: string]: string | number;
1261
- } | Array<'*' | {
1262
- [key: string]: string | number;
1263
- }>): AnimationStyleMetadata;
839
+ * animate("5s", keyframes([
840
+ * style({ backgroundColor: "red" }) // offset = 0
841
+ * style({ backgroundColor: "blue" }) // offset = 0.33
842
+ * style({ backgroundColor: "orange" }) // offset = 0.66
843
+ * style({ backgroundColor: "black" }) // offset = 1
844
+ * ]))
845
+ *```
1264
846
 
847
+ * @publicApi
848
+ */
849
+ declare function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSequenceMetadata;
1265
850
  /**
1266
851
  * Declares an animation transition which is played when a certain specified condition is met.
1267
852
  *
@@ -1406,230 +991,575 @@ export declare function style(tokens: '*' | {
1406
991
  * ])
1407
992
  * ```
1408
993
  *
1409
- * @publicApi
1410
- **/
1411
- export declare function transition(stateChangeExpr: string | ((fromState: string, toState: string, element?: any, params?: {
1412
- [key: string]: any;
1413
- }) => boolean), steps: AnimationMetadata | AnimationMetadata[], options?: AnimationOptions | null): AnimationTransitionMetadata;
1414
-
1415
- /**
1416
- * Creates a named animation trigger, containing a list of [`state()`](api/animations/state)
1417
- * and `transition()` entries to be evaluated when the expression
1418
- * bound to the trigger changes.
994
+ * @publicApi
995
+ **/
996
+ declare function transition(stateChangeExpr: string | ((fromState: string, toState: string, element?: any, params?: {
997
+ [key: string]: any;
998
+ }) => boolean), steps: AnimationMetadata | AnimationMetadata[], options?: AnimationOptions | null): AnimationTransitionMetadata;
999
+ /**
1000
+ * Produces a reusable animation that can be invoked in another animation or sequence,
1001
+ * by calling the `useAnimation()` function.
1002
+ *
1003
+ * @param steps One or more animation objects, as returned by the `animate()`
1004
+ * or `sequence()` function, that form a transformation from one state to another.
1005
+ * A sequence is used by default when you pass an array.
1006
+ * @param options An options object that can contain a delay value for the start of the
1007
+ * animation, and additional developer-defined parameters.
1008
+ * Provided values for additional parameters are used as defaults,
1009
+ * and override values can be passed to the caller on invocation.
1010
+ * @returns An object that encapsulates the animation data.
1011
+ *
1012
+ * @usageNotes
1013
+ * The following example defines a reusable animation, providing some default parameter
1014
+ * values.
1015
+ *
1016
+ * ```ts
1017
+ * var fadeAnimation = animation([
1018
+ * style({ opacity: '{{ start }}' }),
1019
+ * animate('{{ time }}',
1020
+ * style({ opacity: '{{ end }}'}))
1021
+ * ],
1022
+ * { params: { time: '1000ms', start: 0, end: 1 }});
1023
+ * ```
1024
+ *
1025
+ * The following invokes the defined animation with a call to `useAnimation()`,
1026
+ * passing in override parameter values.
1027
+ *
1028
+ * ```js
1029
+ * useAnimation(fadeAnimation, {
1030
+ * params: {
1031
+ * time: '2s',
1032
+ * start: 1,
1033
+ * end: 0
1034
+ * }
1035
+ * })
1036
+ * ```
1037
+ *
1038
+ * If any of the passed-in parameter values are missing from this call,
1039
+ * the default values are used. If one or more parameter values are missing before a step is
1040
+ * animated, `useAnimation()` throws an error.
1041
+ *
1042
+ * @publicApi
1043
+ */
1044
+ declare function animation(steps: AnimationMetadata | AnimationMetadata[], options?: AnimationOptions | null): AnimationReferenceMetadata;
1045
+ /**
1046
+ * Executes a queried inner animation element within an animation sequence.
1047
+ *
1048
+ * @param options An options object that can contain a delay value for the start of the
1049
+ * animation, and additional override values for developer-defined parameters.
1050
+ * @return An object that encapsulates the child animation data.
1051
+ *
1052
+ * @usageNotes
1053
+ * Each time an animation is triggered in Angular, the parent animation
1054
+ * has priority and any child animations are blocked. In order
1055
+ * for a child animation to run, the parent animation must query each of the elements
1056
+ * containing child animations, and run them using this function.
1057
+ *
1058
+ * Note that this feature is designed to be used with `query()` and it will only work
1059
+ * with animations that are assigned using the Angular animation library. CSS keyframes
1060
+ * and transitions are not handled by this API.
1061
+ *
1062
+ * @publicApi
1063
+ */
1064
+ declare function animateChild(options?: AnimateChildOptions | null): AnimationAnimateChildMetadata;
1065
+ /**
1066
+ * Starts a reusable animation that is created using the `animation()` function.
1067
+ *
1068
+ * @param animation The reusable animation to start.
1069
+ * @param options An options object that can contain a delay value for the start of
1070
+ * the animation, and additional override values for developer-defined parameters.
1071
+ * @return An object that contains the animation parameters.
1072
+ *
1073
+ * @publicApi
1074
+ */
1075
+ declare function useAnimation(animation: AnimationReferenceMetadata, options?: AnimationOptions | null): AnimationAnimateRefMetadata;
1076
+ /**
1077
+ * Finds one or more inner elements within the current element that is
1078
+ * being animated within a sequence. Use with `animate()`.
1079
+ *
1080
+ * @param selector The element to query, or a set of elements that contain Angular-specific
1081
+ * characteristics, specified with one or more of the following tokens.
1082
+ * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements (not
1083
+ * all elements can be queried via these tokens, see
1084
+ * [Entering and Leaving Elements](#entering-and-leaving-elements))
1085
+ * - `query(":animating")` : Query all currently animating elements.
1086
+ * - `query("@triggerName")` : Query elements that contain an animation trigger.
1087
+ * - `query("@*")` : Query all elements that contain an animation triggers.
1088
+ * - `query(":self")` : Include the current element into the animation sequence.
1089
+ *
1090
+ * @param animation One or more animation steps to apply to the queried element or elements.
1091
+ * An array is treated as an animation sequence.
1092
+ * @param options An options object. Use the 'limit' field to limit the total number of
1093
+ * items to collect.
1094
+ * @return An object that encapsulates the query data.
1095
+ *
1096
+ * @usageNotes
1097
+ *
1098
+ * ### Multiple Tokens
1099
+ *
1100
+ * Tokens can be merged into a combined query selector string. For example:
1101
+ *
1102
+ * ```ts
1103
+ * query(':self, .record:enter, .record:leave, @subTrigger', [...])
1104
+ * ```
1105
+ *
1106
+ * The `query()` function collects multiple elements and works internally by using
1107
+ * `element.querySelectorAll`. Use the `limit` field of an options object to limit
1108
+ * the total number of items to be collected. For example:
1109
+ *
1110
+ * ```js
1111
+ * query('div', [
1112
+ * animate(...),
1113
+ * animate(...)
1114
+ * ], { limit: 1 })
1115
+ * ```
1116
+ *
1117
+ * By default, throws an error when zero items are found. Set the
1118
+ * `optional` flag to ignore this error. For example:
1119
+ *
1120
+ * ```js
1121
+ * query('.some-element-that-may-not-be-there', [
1122
+ * animate(...),
1123
+ * animate(...)
1124
+ * ], { optional: true })
1125
+ * ```
1126
+ *
1127
+ * ### Entering and Leaving Elements
1128
+ *
1129
+ * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones
1130
+ * that can are those that Angular assumes can enter/leave based on their own logic
1131
+ * (if their insertion/removal is simply a consequence of that of their parent they
1132
+ * should be queried via a different token in their parent's `:enter`/`:leave` transitions).
1133
+ *
1134
+ * The only elements Angular assumes can enter/leave based on their own logic (thus the only
1135
+ * ones that can be queried via the `:enter` and `:leave` tokens) are:
1136
+ * - Those inserted dynamically (via `ViewContainerRef`)
1137
+ * - Those that have a structural directive (which, under the hood, are a subset of the above ones)
1138
+ *
1139
+ * <div class="docs-alert docs-alert-helpful">
1419
1140
  *
1420
- * @param name An identifying string.
1421
- * @param definitions An animation definition object, containing an array of
1422
- * [`state()`](api/animations/state) and `transition()` declarations.
1141
+ * Note that elements will be successfully queried via `:enter`/`:leave` even if their
1142
+ * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural
1143
+ * directive (e.g. they enter/exit alongside their parent).
1423
1144
  *
1424
- * @return An object that encapsulates the trigger data.
1145
+ * </div>
1425
1146
  *
1426
- * @usageNotes
1427
- * Define an animation trigger in the `animations` section of `@Component` metadata.
1428
- * In the template, reference the trigger by name and bind it to a trigger expression that
1429
- * evaluates to a defined animation state, using the following format:
1147
+ * <div class="docs-alert docs-alert-important">
1430
1148
  *
1431
- * `[@triggerName]="expression"`
1149
+ * There is an exception to what previously mentioned, besides elements entering/leaving based on
1150
+ * their own logic, elements with an animation trigger can always be queried via `:leave` when
1151
+ * their parent is also leaving.
1432
1152
  *
1433
- * Animation trigger bindings convert all values to strings, and then match the
1434
- * previous and current values against any linked transitions.
1435
- * Booleans can be specified as `1` or `true` and `0` or `false`.
1153
+ * </div>
1436
1154
  *
1437
1155
  * ### Usage Example
1438
1156
  *
1439
- * The following example creates an animation trigger reference based on the provided
1440
- * name value.
1441
- * The provided animation value is expected to be an array consisting of state and
1442
- * transition declarations.
1157
+ * The following example queries for inner elements and animates them
1158
+ * individually using `animate()`.
1443
1159
  *
1444
- * ```ts
1160
+ * ```angular-ts
1445
1161
  * @Component({
1446
- * selector: "my-component",
1447
- * templateUrl: "my-component-tpl.html",
1162
+ * selector: 'inner',
1163
+ * template: `
1164
+ * <div [@queryAnimation]="exp">
1165
+ * <h1>Title</h1>
1166
+ * <div class="content">
1167
+ * Blah blah blah
1168
+ * </div>
1169
+ * </div>
1170
+ * `,
1448
1171
  * animations: [
1449
- * trigger("myAnimationTrigger", [
1450
- * state(...),
1451
- * state(...),
1452
- * transition(...),
1453
- * transition(...)
1454
- * ])
1455
- * ]
1172
+ * trigger('queryAnimation', [
1173
+ * transition('* => goAnimate', [
1174
+ * // hide the inner elements
1175
+ * query('h1', style({ opacity: 0 })),
1176
+ * query('.content', style({ opacity: 0 })),
1177
+ *
1178
+ * // animate the inner elements in, one by one
1179
+ * query('h1', animate(1000, style({ opacity: 1 }))),
1180
+ * query('.content', animate(1000, style({ opacity: 1 }))),
1181
+ * ])
1182
+ * ])
1183
+ * ]
1456
1184
  * })
1457
- * class MyComponent {
1458
- * myStatusExp = "something";
1185
+ * class Cmp {
1186
+ * exp = '';
1187
+ *
1188
+ * goAnimate() {
1189
+ * this.exp = 'goAnimate';
1190
+ * }
1459
1191
  * }
1460
1192
  * ```
1461
1193
  *
1462
- * The template associated with this component makes use of the defined trigger
1463
- * by binding to an element within its template code.
1194
+ * @publicApi
1195
+ */
1196
+ declare function query(selector: string, animation: AnimationMetadata | AnimationMetadata[], options?: AnimationQueryOptions | null): AnimationQueryMetadata;
1197
+ /**
1198
+ * Use within an animation `query()` call to issue a timing gap after
1199
+ * each queried item is animated.
1200
+ *
1201
+ * @param timings A delay value.
1202
+ * @param animation One ore more animation steps.
1203
+ * @returns An object that encapsulates the stagger data.
1204
+ *
1205
+ * @usageNotes
1206
+ * In the following example, a container element wraps a list of items stamped out
1207
+ * by an `ngFor`. The container element contains an animation trigger that will later be set
1208
+ * to query for each of the inner items.
1209
+ *
1210
+ * Each time items are added, the opacity fade-in animation runs,
1211
+ * and each removed item is faded out.
1212
+ * When either of these animations occur, the stagger effect is
1213
+ * applied after each item's animation is started.
1464
1214
  *
1465
1215
  * ```html
1466
- * <!-- somewhere inside of my-component-tpl.html -->
1467
- * <div [@myAnimationTrigger]="myStatusExp">...</div>
1216
+ * <!-- list.component.html -->
1217
+ * <button (click)="toggle()">Show / Hide Items</button>
1218
+ * <hr />
1219
+ * <div [@listAnimation]="items.length">
1220
+ * <div *ngFor="let item of items">
1221
+ * {{ item }}
1222
+ * </div>
1223
+ * </div>
1468
1224
  * ```
1469
1225
  *
1470
- * ### Using an inline function
1471
- * The `transition` animation method also supports reading an inline function which can decide
1472
- * if its associated animation should be run.
1226
+ * Here is the component code:
1473
1227
  *
1474
1228
  * ```ts
1475
- * // this method is run each time the `myAnimationTrigger` trigger value changes.
1476
- * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
1477
- string]: any}): boolean {
1478
- * // notice that `element` and `params` are also available here
1479
- * return toState == 'yes-please-animate';
1480
- * }
1481
- *
1229
+ * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';
1482
1230
  * @Component({
1483
- * selector: 'my-component',
1484
- * templateUrl: 'my-component-tpl.html',
1231
+ * templateUrl: 'list.component.html',
1485
1232
  * animations: [
1486
- * trigger('myAnimationTrigger', [
1487
- * transition(myInlineMatcherFn, [
1488
- * // the animation sequence code
1489
- * ]),
1233
+ * trigger('listAnimation', [
1234
+ * ...
1490
1235
  * ])
1491
1236
  * ]
1492
1237
  * })
1493
- * class MyComponent {
1494
- * myStatusExp = "yes-please-animate";
1495
- * }
1496
- * ```
1238
+ * class ListComponent {
1239
+ * items = [];
1497
1240
  *
1498
- * ### Disabling Animations
1499
- * When true, the special animation control binding `@.disabled` binding prevents
1500
- * all animations from rendering.
1501
- * Place the `@.disabled` binding on an element to disable
1502
- * animations on the element itself, as well as any inner animation triggers
1503
- * within the element.
1241
+ * showItems() {
1242
+ * this.items = [0,1,2,3,4];
1243
+ * }
1504
1244
  *
1505
- * The following example shows how to use this feature:
1245
+ * hideItems() {
1246
+ * this.items = [];
1247
+ * }
1506
1248
  *
1507
- * ```angular-ts
1508
- * @Component({
1509
- * selector: 'my-component',
1510
- * template: `
1511
- * <div [@.disabled]="isDisabled">
1512
- * <div [@childAnimation]="exp"></div>
1513
- * </div>
1514
- * `,
1515
- * animations: [
1516
- * trigger("childAnimation", [
1517
- * // ...
1518
- * ])
1519
- * ]
1520
- * })
1521
- * class MyComponent {
1522
- * isDisabled = true;
1523
- * exp = '...';
1524
- * }
1249
+ * toggle() {
1250
+ * this.items.length ? this.hideItems() : this.showItems();
1251
+ * }
1252
+ * }
1525
1253
  * ```
1526
1254
  *
1527
- * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,
1528
- * along with any inner animations.
1529
- *
1530
- * ### Disable animations application-wide
1531
- * When an area of the template is set to have animations disabled,
1532
- * **all** inner components have their animations disabled as well.
1533
- * This means that you can disable all animations for an app
1534
- * by placing a host binding set on `@.disabled` on the topmost Angular component.
1255
+ * Here is the animation trigger code:
1535
1256
  *
1536
1257
  * ```ts
1537
- * import {Component, HostBinding} from '@angular/core';
1538
- *
1539
- * @Component({
1540
- * selector: 'app-component',
1541
- * templateUrl: 'app.component.html',
1542
- * })
1543
- * class AppComponent {
1544
- * @HostBinding('@.disabled')
1545
- * public animationsDisabled = true;
1546
- * }
1258
+ * trigger('listAnimation', [
1259
+ * transition('* => *', [ // each time the binding value changes
1260
+ * query(':leave', [
1261
+ * stagger(100, [
1262
+ * animate('0.5s', style({ opacity: 0 }))
1263
+ * ])
1264
+ * ]),
1265
+ * query(':enter', [
1266
+ * style({ opacity: 0 }),
1267
+ * stagger(100, [
1268
+ * animate('0.5s', style({ opacity: 1 }))
1269
+ * ])
1270
+ * ])
1271
+ * ])
1272
+ * ])
1547
1273
  * ```
1548
1274
  *
1549
- * ### Overriding disablement of inner animations
1550
- * Despite inner animations being disabled, a parent animation can `query()`
1551
- * for inner elements located in disabled areas of the template and still animate
1552
- * them if needed. This is also the case for when a sub animation is
1553
- * queried by a parent and then later animated using `animateChild()`.
1554
- *
1555
- * ### Detecting when an animation is disabled
1556
- * If a region of the DOM (or the entire application) has its animations disabled, the animation
1557
- * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
1558
- * an instance of an `AnimationEvent`. If animations are disabled,
1559
- * the `.disabled` flag on the event is true.
1560
- *
1561
1275
  * @publicApi
1562
1276
  */
1563
- export declare function trigger(name: string, definitions: AnimationMetadata[]): AnimationTriggerMetadata;
1277
+ declare function stagger(timings: string | number, animation: AnimationMetadata | AnimationMetadata[]): AnimationStaggerMetadata;
1564
1278
 
1565
1279
  /**
1566
- * Starts a reusable animation that is created using the `animation()` function.
1280
+ * Provides programmatic control of a reusable animation sequence,
1281
+ * built using the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
1282
+ * method which returns an `AnimationFactory`, whose
1283
+ * <code>[create](api/animations/AnimationFactory#create)()</code> method instantiates and
1284
+ * initializes this interface.
1567
1285
  *
1568
- * @param animation The reusable animation to start.
1569
- * @param options An options object that can contain a delay value for the start of
1570
- * the animation, and additional override values for developer-defined parameters.
1571
- * @return An object that contains the animation parameters.
1286
+ * @see {@link AnimationBuilder}
1287
+ * @see {@link AnimationFactory}
1288
+ * @see {@link animate}
1572
1289
  *
1573
1290
  * @publicApi
1574
1291
  */
1575
- export declare function useAnimation(animation: AnimationReferenceMetadata, options?: AnimationOptions | null): AnimationAnimateRefMetadata;
1576
-
1292
+ interface AnimationPlayer {
1293
+ /**
1294
+ * Provides a callback to invoke when the animation finishes.
1295
+ * @param fn The callback function.
1296
+ * @see {@link #finish}
1297
+ */
1298
+ onDone(fn: () => void): void;
1299
+ /**
1300
+ * Provides a callback to invoke when the animation starts.
1301
+ * @param fn The callback function.
1302
+ * @see {@link #play}
1303
+ */
1304
+ onStart(fn: () => void): void;
1305
+ /**
1306
+ * Provides a callback to invoke after the animation is destroyed.
1307
+ * @param fn The callback function.
1308
+ * @see {@link #destroy}
1309
+ * @see {@link #beforeDestroy}
1310
+ */
1311
+ onDestroy(fn: () => void): void;
1312
+ /**
1313
+ * Initializes the animation.
1314
+ */
1315
+ init(): void;
1316
+ /**
1317
+ * Reports whether the animation has started.
1318
+ * @returns True if the animation has started, false otherwise.
1319
+ */
1320
+ hasStarted(): boolean;
1321
+ /**
1322
+ * Runs the animation, invoking the `onStart()` callback.
1323
+ */
1324
+ play(): void;
1325
+ /**
1326
+ * Pauses the animation.
1327
+ */
1328
+ pause(): void;
1329
+ /**
1330
+ * Restarts the paused animation.
1331
+ */
1332
+ restart(): void;
1333
+ /**
1334
+ * Ends the animation, invoking the `onDone()` callback.
1335
+ */
1336
+ finish(): void;
1337
+ /**
1338
+ * Destroys the animation, after invoking the `beforeDestroy()` callback.
1339
+ * Calls the `onDestroy()` callback when destruction is completed.
1340
+ */
1341
+ destroy(): void;
1342
+ /**
1343
+ * Resets the animation to its initial state.
1344
+ */
1345
+ reset(): void;
1346
+ /**
1347
+ * Sets the position of the animation.
1348
+ * @param position A fractional value, representing the progress through the animation.
1349
+ */
1350
+ setPosition(position: number): void;
1351
+ /**
1352
+ * Reports the current position of the animation.
1353
+ * @returns A fractional value, representing the progress through the animation.
1354
+ */
1355
+ getPosition(): number;
1356
+ /**
1357
+ * The parent of this player, if any.
1358
+ */
1359
+ parentPlayer: AnimationPlayer | null;
1360
+ /**
1361
+ * The total run time of the animation, in milliseconds.
1362
+ */
1363
+ readonly totalTime: number;
1364
+ /**
1365
+ * Provides a callback to invoke before the animation is destroyed.
1366
+ */
1367
+ beforeDestroy?: () => any;
1368
+ }
1577
1369
  /**
1578
- * A programmatic controller for a group of reusable animations.
1579
- * Used internally to control animations.
1370
+ * An empty programmatic controller for reusable animations.
1371
+ * Used internally when animations are disabled, to avoid
1372
+ * checking for the null case when an animation player is expected.
1580
1373
  *
1374
+ * @see {@link animate}
1581
1375
  * @see {@link AnimationPlayer}
1582
- * @see {@link animations/group group}
1583
1376
  *
1377
+ * @publicApi
1584
1378
  */
1585
- export declare class ɵAnimationGroupPlayer implements AnimationPlayer {
1379
+ declare class NoopAnimationPlayer implements AnimationPlayer {
1586
1380
  private _onDoneFns;
1587
1381
  private _onStartFns;
1588
- private _finished;
1382
+ private _onDestroyFns;
1383
+ private _originalOnDoneFns;
1384
+ private _originalOnStartFns;
1589
1385
  private _started;
1590
1386
  private _destroyed;
1591
- private _onDestroyFns;
1387
+ private _finished;
1388
+ private _position;
1592
1389
  parentPlayer: AnimationPlayer | null;
1593
- totalTime: number;
1594
- readonly players: AnimationPlayer[];
1595
- constructor(_players: AnimationPlayer[]);
1390
+ readonly totalTime: number;
1391
+ constructor(duration?: number, delay?: number);
1596
1392
  private _onFinish;
1597
- init(): void;
1598
1393
  onStart(fn: () => void): void;
1599
- private _onStart;
1600
1394
  onDone(fn: () => void): void;
1601
1395
  onDestroy(fn: () => void): void;
1602
1396
  hasStarted(): boolean;
1397
+ init(): void;
1603
1398
  play(): void;
1399
+ private _onStart;
1604
1400
  pause(): void;
1605
1401
  restart(): void;
1606
1402
  finish(): void;
1607
1403
  destroy(): void;
1608
- private _onDestroy;
1609
1404
  reset(): void;
1610
- setPosition(p: number): void;
1405
+ setPosition(position: number): void;
1611
1406
  getPosition(): number;
1612
- beforeDestroy(): void;
1613
1407
  }
1614
1408
 
1615
- export declare class ɵBrowserAnimationBuilder extends AnimationBuilder {
1409
+ /**
1410
+ * An injectable service that produces an animation sequence programmatically within an
1411
+ * Angular component or directive.
1412
+ * Provided by the `BrowserAnimationsModule` or `NoopAnimationsModule`.
1413
+ *
1414
+ * @usageNotes
1415
+ *
1416
+ * To use this service, add it to your component or directive as a dependency.
1417
+ * The service is instantiated along with your component.
1418
+ *
1419
+ * Apps do not typically need to create their own animation players, but if you
1420
+ * do need to, follow these steps:
1421
+ *
1422
+ * 1. Use the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code> method
1423
+ * to create a programmatic animation. The method returns an `AnimationFactory` instance.
1424
+ *
1425
+ * 2. Use the factory object to create an `AnimationPlayer` and attach it to a DOM element.
1426
+ *
1427
+ * 3. Use the player object to control the animation programmatically.
1428
+ *
1429
+ * For example:
1430
+ *
1431
+ * ```ts
1432
+ * // import the service from BrowserAnimationsModule
1433
+ * import {AnimationBuilder} from '@angular/animations';
1434
+ * // require the service as a dependency
1435
+ * class MyCmp {
1436
+ * constructor(private _builder: AnimationBuilder) {}
1437
+ *
1438
+ * makeAnimation(element: any) {
1439
+ * // first define a reusable animation
1440
+ * const myAnimation = this._builder.build([
1441
+ * style({ width: 0 }),
1442
+ * animate(1000, style({ width: '100px' }))
1443
+ * ]);
1444
+ *
1445
+ * // use the returned factory object to create a player
1446
+ * const player = myAnimation.create(element);
1447
+ *
1448
+ * player.play();
1449
+ * }
1450
+ * }
1451
+ * ```
1452
+ *
1453
+ * @publicApi
1454
+ */
1455
+ declare abstract class AnimationBuilder {
1456
+ /**
1457
+ * Builds a factory for producing a defined animation.
1458
+ * @param animation A reusable animation definition.
1459
+ * @returns A factory object that can create a player for the defined animation.
1460
+ * @see {@link animate}
1461
+ */
1462
+ abstract build(animation: AnimationMetadata | AnimationMetadata[]): AnimationFactory;
1463
+ static ɵfac: i0.ɵɵFactoryDeclaration<AnimationBuilder, never>;
1464
+ static ɵprov: i0.ɵɵInjectableDeclaration<AnimationBuilder>;
1465
+ }
1466
+ /**
1467
+ * A factory object returned from the
1468
+ * <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
1469
+ * method.
1470
+ *
1471
+ * @publicApi
1472
+ */
1473
+ declare abstract class AnimationFactory {
1474
+ /**
1475
+ * Creates an `AnimationPlayer` instance for the reusable animation defined by
1476
+ * the <code>[AnimationBuilder.build](api/animations/AnimationBuilder#build)()</code>
1477
+ * method that created this factory and attaches the new player a DOM element.
1478
+ *
1479
+ * @param element The DOM element to which to attach the player.
1480
+ * @param options A set of options that can include a time delay and
1481
+ * additional developer-defined parameters.
1482
+ */
1483
+ abstract create(element: any, options?: AnimationOptions): AnimationPlayer;
1484
+ }
1485
+ declare class BrowserAnimationBuilder extends AnimationBuilder {
1616
1486
  private animationModuleType;
1617
1487
  private _nextAnimationId;
1618
1488
  private _renderer;
1619
1489
  constructor(rootRenderer: RendererFactory2, doc: Document);
1620
1490
  build(animation: AnimationMetadata | AnimationMetadata[]): AnimationFactory;
1621
- static ɵfac: i0.ɵɵFactoryDeclarationBrowserAnimationBuilder, never>;
1622
- static ɵprov: i0.ɵɵInjectableDeclarationBrowserAnimationBuilder>;
1491
+ static ɵfac: i0.ɵɵFactoryDeclaration<BrowserAnimationBuilder, never>;
1492
+ static ɵprov: i0.ɵɵInjectableDeclaration<BrowserAnimationBuilder>;
1623
1493
  }
1624
1494
 
1625
- export declare const ɵPRE_STYLE = "!";
1626
-
1495
+ /**
1496
+ * An instance of this class is returned as an event parameter when an animation
1497
+ * callback is captured for an animation either during the start or done phase.
1498
+ *
1499
+ * ```ts
1500
+ * @Component({
1501
+ * host: {
1502
+ * '[@myAnimationTrigger]': 'someExpression',
1503
+ * '(@myAnimationTrigger.start)': 'captureStartEvent($event)',
1504
+ * '(@myAnimationTrigger.done)': 'captureDoneEvent($event)',
1505
+ * },
1506
+ * animations: [
1507
+ * trigger("myAnimationTrigger", [
1508
+ * // ...
1509
+ * ])
1510
+ * ]
1511
+ * })
1512
+ * class MyComponent {
1513
+ * someExpression: any = false;
1514
+ * captureStartEvent(event: AnimationEvent) {
1515
+ * // the toState, fromState and totalTime data is accessible from the event variable
1516
+ * }
1517
+ *
1518
+ * captureDoneEvent(event: AnimationEvent) {
1519
+ * // the toState, fromState and totalTime data is accessible from the event variable
1520
+ * }
1521
+ * }
1522
+ * ```
1523
+ *
1524
+ * @publicApi
1525
+ */
1526
+ interface AnimationEvent {
1527
+ /**
1528
+ * The name of the state from which the animation is triggered.
1529
+ */
1530
+ fromState: string;
1531
+ /**
1532
+ * The name of the state in which the animation completes.
1533
+ */
1534
+ toState: string;
1535
+ /**
1536
+ * The time it takes the animation to complete, in milliseconds.
1537
+ */
1538
+ totalTime: number;
1539
+ /**
1540
+ * The animation phase in which the callback was invoked, one of
1541
+ * "start" or "done".
1542
+ */
1543
+ phaseName: string;
1544
+ /**
1545
+ * The element to which the animation is attached.
1546
+ */
1547
+ element: any;
1548
+ /**
1549
+ * Internal.
1550
+ */
1551
+ triggerName: string;
1552
+ /**
1553
+ * Internal.
1554
+ */
1555
+ disabled: boolean;
1556
+ }
1627
1557
 
1628
1558
  /**
1629
1559
  * The list of error codes used in runtime code of the `animations` package.
1630
1560
  * Reserved error code range: 3000-3999.
1631
1561
  */
1632
- export declare const enum ɵRuntimeErrorCode {
1562
+ declare const enum RuntimeErrorCode {
1633
1563
  INVALID_TIMING_VALUE = 3000,
1634
1564
  INVALID_STYLE_PARAMS = 3001,
1635
1565
  INVALID_STYLE_VALUE = 3002,
@@ -1669,17 +1599,44 @@ export declare const enum ɵRuntimeErrorCode {
1669
1599
  BROWSER_ANIMATION_BUILDER_INJECTED_WITHOUT_ANIMATIONS = 3600
1670
1600
  }
1671
1601
 
1672
-
1673
1602
  /**
1674
- * Represents a set of CSS styles for use in an animation style as a generic.
1603
+ * A programmatic controller for a group of reusable animations.
1604
+ * Used internally to control animations.
1605
+ *
1606
+ * @see {@link AnimationPlayer}
1607
+ * @see {@link animations/group group}
1608
+ *
1675
1609
  */
1676
- export declare interface ɵStyleData {
1677
- [key: string]: string | number;
1610
+ declare class AnimationGroupPlayer implements AnimationPlayer {
1611
+ private _onDoneFns;
1612
+ private _onStartFns;
1613
+ private _finished;
1614
+ private _started;
1615
+ private _destroyed;
1616
+ private _onDestroyFns;
1617
+ parentPlayer: AnimationPlayer | null;
1618
+ totalTime: number;
1619
+ readonly players: AnimationPlayer[];
1620
+ constructor(_players: AnimationPlayer[]);
1621
+ private _onFinish;
1622
+ init(): void;
1623
+ onStart(fn: () => void): void;
1624
+ private _onStart;
1625
+ onDone(fn: () => void): void;
1626
+ onDestroy(fn: () => void): void;
1627
+ hasStarted(): boolean;
1628
+ play(): void;
1629
+ pause(): void;
1630
+ restart(): void;
1631
+ finish(): void;
1632
+ destroy(): void;
1633
+ private _onDestroy;
1634
+ reset(): void;
1635
+ setPosition(p: number): void;
1636
+ getPosition(): number;
1637
+ beforeDestroy(): void;
1678
1638
  }
1679
1639
 
1680
- /**
1681
- * Represents a set of CSS styles for use in an animation style as a Map.
1682
- */
1683
- export declare type ɵStyleDataMap = Map<string, string | number>;
1640
+ declare const ɵPRE_STYLE = "!";
1684
1641
 
1685
- export { }
1642
+ export { AUTO_STYLE, type AnimateChildOptions, type AnimateTimings, type AnimationAnimateChildMetadata, type AnimationAnimateMetadata, type AnimationAnimateRefMetadata, AnimationBuilder, type AnimationEvent, AnimationFactory, type AnimationGroupMetadata, type AnimationKeyframesSequenceMetadata, type AnimationMetadata, AnimationMetadataType, type AnimationOptions, type AnimationPlayer, type AnimationQueryMetadata, type AnimationQueryOptions, type AnimationReferenceMetadata, type AnimationSequenceMetadata, type AnimationStaggerMetadata, type AnimationStateMetadata, type AnimationStyleMetadata, type AnimationTransitionMetadata, type AnimationTriggerMetadata, NoopAnimationPlayer, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, AnimationGroupPlayer as ɵAnimationGroupPlayer, BrowserAnimationBuilder as ɵBrowserAnimationBuilder, ɵPRE_STYLE, RuntimeErrorCode as ɵRuntimeErrorCode, type ɵStyleData, type ɵStyleDataMap };