| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Represents a set of CSS styles for use in an animation style. | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  | export interface ɵStyleData { [key: string]: string|number; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * Represents animation-step timing parameters for an animation step. | 
					
						
							|  |  |  |  * @see `animate()` | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | export declare type AnimateTimings = { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * The full duration of an animation step. A number and optional time unit, | 
					
						
							|  |  |  |    * such as "1s" or "10ms" for one second and 10 milliseconds, respectively. | 
					
						
							|  |  |  |    * The default unit is milliseconds. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |   duration: number, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * The delay in applying an animation step. A number and optional time unit. | 
					
						
							|  |  |  |    * The default unit is milliseconds. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |   delay: number, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An easing style that controls how an animations step accelerates | 
					
						
							|  |  |  |    * and decelerates during its run time. An easing function such as `cubic-bezier()`, | 
					
						
							|  |  |  |    * or one of the following constants: | 
					
						
							|  |  |  |    * - `ease-in` | 
					
						
							|  |  |  |    * - `ease-out` | 
					
						
							|  |  |  |    * - `ease-in-and-out` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-03-24 09:56:34 -07:00
										 |  |  |   easing: string | null | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @description Options that control animation styling and timing. | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following animation functions accept `AnimationOptions` data: | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * - `transition()` | 
					
						
							|  |  |  |  * - `sequence()` | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * - `{@link animations/group group()}` | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * - `query()` | 
					
						
							|  |  |  |  * - `animation()` | 
					
						
							|  |  |  |  * - `useAnimation()` | 
					
						
							|  |  |  |  * - `animateChild()` | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Programmatic animations built using the `AnimationBuilder` service also | 
					
						
							|  |  |  |  * make use of `AnimationOptions`. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export declare interface AnimationOptions { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Sets a time-delay for initiating an animation action. | 
					
						
							|  |  |  |    * A number and optional time unit, such as "1s" or "10ms" for one second | 
					
						
							|  |  |  |    * and 10 milliseconds, respectively.The default unit is milliseconds. | 
					
						
							|  |  |  |    * Default value is 0, meaning no delay. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   delay?: number|string; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |   * A set of developer-defined parameters that modify styling and timing | 
					
						
							|  |  |  |   * when an animation action starts. An array of key-value pairs, where the provided value | 
					
						
							|  |  |  |   * is used as a default. | 
					
						
							|  |  |  |   */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   params?: {[name: string]: any}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-02 15:45:48 -07:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Adds duration options to control animation styling and timing for a child animation. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @see `animateChild()` | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-05-02 15:45:48 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export declare interface AnimateChildOptions extends AnimationOptions { duration?: number|string; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @description Constants for the categories of parameters that can be defined for animations. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * A corresponding function defines a set of parameters for each category, and | 
					
						
							|  |  |  |  * collects them into a corresponding `AnimationMetadata` object. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | export const enum AnimationMetadataType { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Associates a named animation state with a set of CSS styles. | 
					
						
							|  |  |  |    * See `state()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   State = 0, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Data for a transition from one animation state to another. | 
					
						
							|  |  |  |    * See `transition()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Transition = 1, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains a set of animation steps. | 
					
						
							|  |  |  |    * See `sequence()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Sequence = 2, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains a set of animation steps. | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |    * See `{@link animations/group group()}` | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Group = 3, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains an animation step. | 
					
						
							|  |  |  |    * See `animate()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Animate = 4, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains a set of animation steps. | 
					
						
							|  |  |  |    * See `keyframes()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Keyframes = 5, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains a set of CSS property-value pairs into a named style. | 
					
						
							|  |  |  |    * See `style()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Style = 6, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Associates an animation with an entry trigger that can be attached to an element. | 
					
						
							|  |  |  |    * See `trigger()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Trigger = 7, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains a re-usable animation. | 
					
						
							|  |  |  |    * See `animation()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Reference = 8, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains data to use in executing child animations returned by a query. | 
					
						
							|  |  |  |    * See `animateChild()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   AnimateChild = 9, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains animation parameters for a re-usable animation. | 
					
						
							|  |  |  |    * See `useAnimation()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   AnimateRef = 10, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains child-animation query data. | 
					
						
							|  |  |  |    * See `query()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Query = 11, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Contains data for staggering an animation sequence. | 
					
						
							|  |  |  |    * See `stagger()` | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   Stagger = 12 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Specifies automatic styling. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export const AUTO_STYLE = '*'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Base for animation data structures. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationMetadata { type: AnimationMetadataType; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Contains an animation trigger. Instantiated and returned by the | 
					
						
							|  |  |  |  * `trigger()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | export interface AnimationTriggerMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |     * The trigger name, used to associate it with an element. Unique within the component. | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |   name: string; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An animation definition object, containing an array of state and transition declarations. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |   definitions: AnimationMetadata[]; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: {params?: {[name: string]: any}}|null; | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation state by associating a state name with a set of CSS styles. | 
					
						
							|  |  |  |  * Instantiated and returned by the `state()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationStateMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * The state name, unique within the component. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |   name: string; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    *  The CSS styles associated with this state. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |   styles: AnimationStyleMetadata; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-08-07 11:40:04 -07:00
										 |  |  |   options?: {params: {[name: string]: any}}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation transition. Instantiated and returned by the | 
					
						
							|  |  |  |  * `transition()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationTransitionMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An expression that describes a state change. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2018-03-12 17:21:02 -07:00
										 |  |  |   expr: string| | 
					
						
							|  |  |  |       ((fromState: string, toState: string, element?: any, | 
					
						
							|  |  |  |         params?: {[key: string]: any}) => boolean); | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * One or more animation objects to which this transition applies. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   animation: AnimationMetadata|AnimationMetadata[]; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationOptions|null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates a reusable animation, which is a collection of individual animation steps. | 
					
						
							|  |  |  |  * Instantiated and returned by the `animation()` function, and | 
					
						
							|  |  |  |  * passed to the `useAnimation()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationReferenceMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    *  One or more animation step objects. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   animation: AnimationMetadata|AnimationMetadata[]; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationOptions|null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation query. Instantiated and returned by | 
					
						
							|  |  |  |  * the `query()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationQueryMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    *  The CSS selector for this query. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   selector: string; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * One or more animation step objects. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-03-01 17:13:06 -08:00
										 |  |  |   animation: AnimationMetadata|AnimationMetadata[]; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * A query options object. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationQueryOptions|null; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates a keyframes sequence. Instantiated and returned by | 
					
						
							|  |  |  |  * the `keyframes()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationKeyframesSequenceMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An array of animation styles. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |   steps: AnimationStyleMetadata[]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation style. Instantiated and returned by | 
					
						
							|  |  |  |  * the `style()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationStyleMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * A set of CSS style properties. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   styles: '*'|{[key: string]: string | number}|Array<{[key: string]: string | number}|'*'>; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * A percentage of the total animate time at which the style is to be applied. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   offset: number|null; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation step. Instantiated and returned by | 
					
						
							|  |  |  |  * the `animate()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationAnimateMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * The timing data for the step. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |   timings: string|number|AnimateTimings; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * A set of styles used in the step. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-03-29 09:34:45 -07:00
										 |  |  |   styles: AnimationStyleMetadata|AnimationKeyframesSequenceMetadata|null; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates a child animation, that can be run explicitly when the parent is run. | 
					
						
							|  |  |  |  * Instantiated and returned by the `animateChild` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationAnimateChildMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationOptions|null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates a reusable animation. | 
					
						
							|  |  |  |  * Instantiated and returned by the `useAnimation()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export interface AnimationAnimateRefMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An animation reference object. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   animation: AnimationReferenceMetadata; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationOptions|null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation sequence. | 
					
						
							|  |  |  |  * Instantiated and returned by the `sequence()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | export interface AnimationSequenceMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    *  An array of animation step objects. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   steps: AnimationMetadata[]; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationOptions|null; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates an animation group. | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * Instantiated and returned by the `{@link animations/group group()}` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | export interface AnimationGroupMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * One or more animation or style steps that form this group. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   steps: AnimationMetadata[]; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * An options object containing a delay and | 
					
						
							|  |  |  |    * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |    * can be overridden on invocation. Default delay is 0. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   options: AnimationOptions|null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates animation query options. | 
					
						
							|  |  |  |  * Passed to the `query()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export declare interface AnimationQueryOptions extends AnimationOptions { | 
					
						
							| 
									
										
										
										
											2017-09-28 09:34:36 -07:00
										 |  |  |   /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |    * True if this query is optional, false if it is required. Default is false. | 
					
						
							|  |  |  |    * A required query throws an error if no elements are retrieved when | 
					
						
							|  |  |  |    * the query is executed. An optional query does not. | 
					
						
							| 
									
										
										
										
											2017-09-28 09:34:36 -07:00
										 |  |  |    * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |    */ | 
					
						
							|  |  |  |   optional?: boolean; | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * A maximum total number of results to return from the query. | 
					
						
							|  |  |  |    * If negative, results are limited from the end of the query list towards the beginning. | 
					
						
							|  |  |  |    * By default, results are not limited. | 
					
						
							| 
									
										
										
										
											2017-09-28 09:34:36 -07:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |   limit?: number; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Encapsulates parameters for staggering the start times of a set of animation steps. | 
					
						
							|  |  |  |  * Instantiated and returned by the `stagger()` function. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | export interface AnimationStaggerMetadata extends AnimationMetadata { | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * The timing data for the steps. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   timings: string|number; | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * One or more animation steps. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   animation: AnimationMetadata|AnimationMetadata[]; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Creates a named animation trigger, containing a  list of `state()` | 
					
						
							|  |  |  |  * and `transition()` entries to be evaluated when the expression | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * bound to the trigger changes. | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param name An identifying string. | 
					
						
							|  |  |  |  * @param definitions  An animation definition object, containing an array of `state()` | 
					
						
							|  |  |  |  * and `transition()` declarations. | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @return An object that encapsulates the trigger data. | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * Define an animation trigger in the `animations` section of `@Component` metadata. | 
					
						
							|  |  |  |  * In the template, reference the trigger by name and bind it to a trigger expression that | 
					
						
							|  |  |  |  * evaluates to a defined animation state, using the following format: | 
					
						
							| 
									
										
										
										
											2017-09-19 14:22:22 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * `[@triggerName]="expression"` | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * Animation trigger bindings convert all values to strings, and then match the | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * previous and current values against any linked transitions. | 
					
						
							|  |  |  |  * Booleans can be specified as `1` or `true` and `0` or `false`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Usage Example | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following example creates an animation trigger reference based on the provided | 
					
						
							|  |  |  |  * name value. | 
					
						
							|  |  |  |  * The provided animation value is expected to be an array consisting of state and | 
					
						
							|  |  |  |  * transition declarations. | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *   selector: "my-component", | 
					
						
							|  |  |  |  *   templateUrl: "my-component-tpl.html", | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  *   animations: [ | 
					
						
							|  |  |  |  *     trigger("myAnimationTrigger", [ | 
					
						
							|  |  |  |  *       state(...), | 
					
						
							|  |  |  |  *       state(...), | 
					
						
							|  |  |  |  *       transition(...), | 
					
						
							|  |  |  |  *       transition(...) | 
					
						
							|  |  |  |  *     ]) | 
					
						
							|  |  |  |  *   ] | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class MyComponent { | 
					
						
							|  |  |  |  *   myStatusExp = "something"; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The template associated with this component makes use of the defined trigger | 
					
						
							|  |  |  |  * by binding to an element within its template code. | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <!-- somewhere inside of my-component-tpl.html --> | 
					
						
							|  |  |  |  * <div [@myAnimationTrigger]="myStatusExp">...</div> | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-05 08:34:25 -07:00
										 |  |  |  * ### Using an inline function | 
					
						
							| 
									
										
										
										
											2018-03-12 17:21:02 -07:00
										 |  |  |  * The `transition` animation method also supports reading an inline function which can decide | 
					
						
							|  |  |  |  * if its associated animation should be run. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * // this method is run each time the `myAnimationTrigger` trigger value changes.
 | 
					
						
							| 
									
										
										
										
											2018-05-05 08:34:25 -07:00
										 |  |  |  * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key: | 
					
						
							|  |  |  |  string]: any}): boolean { | 
					
						
							| 
									
										
										
										
											2018-03-12 17:21:02 -07:00
										 |  |  |  *   // notice that `element` and `params` are also available here
 | 
					
						
							|  |  |  |  *   return toState == 'yes-please-animate'; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							|  |  |  |  *   selector: 'my-component', | 
					
						
							|  |  |  |  *   templateUrl: 'my-component-tpl.html', | 
					
						
							|  |  |  |  *   animations: [ | 
					
						
							|  |  |  |  *     trigger('myAnimationTrigger', [ | 
					
						
							|  |  |  |  *       transition(myInlineMatcherFn, [ | 
					
						
							|  |  |  |  *         // the animation sequence code
 | 
					
						
							|  |  |  |  *       ]), | 
					
						
							|  |  |  |  *     ]) | 
					
						
							|  |  |  |  *   ] | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class MyComponent { | 
					
						
							|  |  |  |  *   myStatusExp = "yes-please-animate"; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Disabling Animations | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * When true, the special animation control binding `@.disabled` binding prevents | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * all animations from rendering. | 
					
						
							|  |  |  |  * Place the  `@.disabled` binding on an element to disable | 
					
						
							|  |  |  |  * animations on the element itself, as well as any inner animation triggers | 
					
						
							|  |  |  |  * within the element. | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following example shows how to use this feature: | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * @Component({ | 
					
						
							|  |  |  |  *   selector: 'my-component', | 
					
						
							|  |  |  |  *   template: `
 | 
					
						
							|  |  |  |  *     <div [@.disabled]="isDisabled"> | 
					
						
							|  |  |  |  *       <div [@childAnimation]="exp"></div> | 
					
						
							|  |  |  |  *     </div> | 
					
						
							|  |  |  |  *   `,
 | 
					
						
							|  |  |  |  *   animations: [ | 
					
						
							|  |  |  |  *     trigger("childAnimation", [ | 
					
						
							|  |  |  |  *       // ...
 | 
					
						
							|  |  |  |  *     ]) | 
					
						
							|  |  |  |  *   ] | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class MyComponent { | 
					
						
							|  |  |  |  *   isDisabled = true; | 
					
						
							|  |  |  |  *   exp = '...'; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating, | 
					
						
							|  |  |  |  * along with any inner animations. | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Disable animations application-wide | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * When an area of the template is set to have animations disabled, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * **all** inner components have their animations disabled as well. | 
					
						
							|  |  |  |  * This means that you can disable all animations for an app | 
					
						
							|  |  |  |  * by placing a host binding set on `@.disabled` on the topmost Angular component. | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-07-06 10:32:32 -07:00
										 |  |  |  * import {Component, HostBinding} from '@angular/core'; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							|  |  |  |  *   selector: 'app-component', | 
					
						
							|  |  |  |  *   templateUrl: 'app.component.html', | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class AppComponent { | 
					
						
							|  |  |  |  *   @HostBinding('@.disabled') | 
					
						
							|  |  |  |  *   public animationsDisabled = true; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Overriding disablement of inner animations | 
					
						
							|  |  |  |  * Despite inner animations being disabled, a parent animation can `query()` | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * for inner elements located in disabled areas of the template and still animate | 
					
						
							|  |  |  |  * them if needed. This is also the case for when a sub animation is | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * queried by a parent and then later animated using `animateChild()`. | 
					
						
							| 
									
										
										
										
											2018-02-14 10:12:10 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Detecting when an animation is disabled | 
					
						
							|  |  |  |  * If a region of the DOM (or the entire application) has its animations disabled, the animation | 
					
						
							|  |  |  |  * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides | 
					
						
							|  |  |  |  * an instance of an `AnimationEvent`. If animations are disabled, | 
					
						
							|  |  |  |  * the `.disabled` flag on the event is true. | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function trigger(name: string, definitions: AnimationMetadata[]): AnimationTriggerMetadata { | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   return {type: AnimationMetadataType.Trigger, name, definitions, options: {}}; | 
					
						
							| 
									
										
										
										
											2017-02-22 15:14:49 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Defines an animation step that combines styling information with timing information. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param timings Sets `AnimateTimings` for the parent animation. | 
					
						
							|  |  |  |  * A string in the format "duration [delay] [easing]". | 
					
						
							|  |  |  |  *  - Duration and delay are expressed as a number and optional time unit, | 
					
						
							|  |  |  |  * such as "1s" or "10ms" for one second and 10 milliseconds, respectively. | 
					
						
							|  |  |  |  * The default unit is milliseconds. | 
					
						
							|  |  |  |  *  - The easing value controls how the animation accelerates and decelerates | 
					
						
							|  |  |  |  * during its runtime. Value is one of  `ease`, `ease-in`, `ease-out`, | 
					
						
							|  |  |  |  * `ease-in-out`, or a `cubic-bezier()` function call. | 
					
						
							|  |  |  |  * If not supplied, no easing is applied. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * For example, the string "1s 100ms ease-out" specifies a duration of | 
					
						
							|  |  |  |  * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style, | 
					
						
							|  |  |  |  * which decelerates near the end of the duration. | 
					
						
							|  |  |  |  * @param styles Sets AnimationStyles for the parent animation. | 
					
						
							|  |  |  |  * A function call to either `style()` or `keyframes()` | 
					
						
							|  |  |  |  * that returns a collection of CSS style entries to be applied to the parent animation. | 
					
						
							|  |  |  |  * When null, uses the styles from the destination state. | 
					
						
							|  |  |  |  * This is useful when describing an animation step that will complete an animation; | 
					
						
							|  |  |  |  * see "Animating to the final state" in `transitions()`. | 
					
						
							|  |  |  |  * @returns An object that encapsulates the animation step. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * Call within an animation `sequence()`, `{@link animations/group group()}`, or | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * `transition()` call to specify an animation step | 
					
						
							|  |  |  |  * that applies given style data to the parent animation for a given amount of time. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Syntax Examples | 
					
						
							|  |  |  |  * **Timing examples** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The following examples show various `timings` specifications. | 
					
						
							|  |  |  |  * - `animate(500)` : Duration is 500 milliseconds. | 
					
						
							|  |  |  |  * - `animate("1s")` : Duration is 1000 milliseconds. | 
					
						
							|  |  |  |  * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds. | 
					
						
							|  |  |  |  * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in. | 
					
						
							|  |  |  |  * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10 | 
					
						
							|  |  |  |  * milliseconds, easing according to a bezier curve. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * **Style examples** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The following example calls `style()` to set a single CSS style. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * animate(500, style({ background: "red" })) | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * The following example calls `keyframes()` to set a CSS style | 
					
						
							|  |  |  |  * to different values for successive keyframes. | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * animate(500, keyframes( | 
					
						
							|  |  |  |  *  [ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  *   style({ background: "blue" })), | 
					
						
							|  |  |  |  *   style({ background: "red" })) | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *  ]) | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function animate( | 
					
						
							| 
									
										
										
										
											2017-03-29 09:34:45 -07:00
										 |  |  |     timings: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | | 
					
						
							|  |  |  |         null = null): AnimationAnimateMetadata { | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   return {type: AnimationMetadataType.Animate, styles, timings}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @description Defines a list of animation steps to be run in parallel. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param steps An array of animation step objects. | 
					
						
							|  |  |  |  * - When steps are defined by `style()` or `animate()` | 
					
						
							|  |  |  |  * function calls, each call within the group is executed instantly. | 
					
						
							|  |  |  |  * - To specify offset styles to be applied at a later time, define steps with | 
					
						
							|  |  |  |  * `keyframes()`, or use `animate()` calls with a delay value. | 
					
						
							|  |  |  |  * For example: | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * group([ | 
					
						
							| 
									
										
										
										
											2019-01-23 00:02:43 +01:00
										 |  |  |  *   animate("1s", style({ background: "black" })), | 
					
						
							|  |  |  |  *   animate("2s", style({ color: "white" })) | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ]) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param options An options object containing a delay and | 
					
						
							|  |  |  |  * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |  * can be overridden on invocation. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @return An object that encapsulates the group data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * Grouped animations are useful when a series of styles must be | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * animated at different starting times and closed off at different ending times. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * When called within a `sequence()` or a | 
					
						
							|  |  |  |  * `transition()` call, does not continue to the next | 
					
						
							|  |  |  |  * instruction until all of the inner animation steps have completed. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | export function group( | 
					
						
							|  |  |  |     steps: AnimationMetadata[], options: AnimationOptions | null = null): AnimationGroupMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Group, steps, options}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Defines a list of animation steps to be run sequentially, one by one. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param steps An array of animation step objects. | 
					
						
							|  |  |  |  * - Steps defined by `style()` calls apply the styling data immediately. | 
					
						
							|  |  |  |  * - Steps defined by `animate()` calls apply the styling data over time | 
					
						
							|  |  |  |  *   as specified by the timing data. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * sequence([ | 
					
						
							|  |  |  |  *   style({ opacity: 0 })), | 
					
						
							| 
									
										
										
										
											2019-01-23 00:02:43 +01:00
										 |  |  |  *   animate("1s", style({ opacity: 1 })) | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ]) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param options An options object containing a delay and | 
					
						
							|  |  |  |  * developer-defined parameters that provide styling defaults and | 
					
						
							|  |  |  |  * can be overridden on invocation. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @return An object that encapsulates the sequence data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * When you pass an array of steps to a | 
					
						
							|  |  |  |  * `transition()` call, the steps run sequentially by default. | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * Compare this to the `{@link animations/group group()}` call, which runs animation steps in parallel. | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * When a sequence is used within a `{@link animations/group group()}` or a `transition()` call, | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * execution continues to the next instruction only after each of the inner animation | 
					
						
							|  |  |  |  * steps have completed. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  | export function sequence(steps: AnimationMetadata[], options: AnimationOptions | null = null): | 
					
						
							|  |  |  |     AnimationSequenceMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Sequence, steps, options}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Declares a key/value object containing CSS properties/styles that | 
					
						
							|  |  |  |  * can then be used for an animation `state`, within an animation `sequence`, | 
					
						
							|  |  |  |  * or as styling data for calls to `animate()` and `keyframes()`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param tokens A set of CSS styles or HTML styles associated with an animation state. | 
					
						
							|  |  |  |  * The value can be any of the following: | 
					
						
							|  |  |  |  * - A key-value style pair associating a CSS property with a value. | 
					
						
							|  |  |  |  * - An array of key-value style pairs. | 
					
						
							|  |  |  |  * - An asterisk (*), to use auto-styling, where styles are derived from the element | 
					
						
							|  |  |  |  * being animated and applied to the animation when it starts. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * Auto-styling can be used to define a state that depends on layout or other | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * environmental factors. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @return An object that encapsulates the style data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * The following examples create animation styles that collect a set of | 
					
						
							|  |  |  |  * CSS property values: | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * // string values for CSS properties
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * style({ background: "red", color: "blue" }) | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * // numerical pixel values
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * style({ width: 100, height: 0 }) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following example uses auto-styling to allow a component to animate from | 
					
						
							|  |  |  |  * a height of 0 up to the height of the parent element: | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * style({ height: 0 }), | 
					
						
							|  |  |  |  * animate("1s", style({ height: "*" })) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | export function style( | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |     tokens: '*' | {[key: string]: string | number} | | 
					
						
							|  |  |  |     Array<'*'|{[key: string]: string | number}>): AnimationStyleMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Style, styles: tokens, offset: null}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Declares an animation state within a trigger attached to an element. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param name One or more names for the defined state in a comma-separated string. | 
					
						
							|  |  |  |  * The following reserved state names can be supplied to define a style for specific use | 
					
						
							|  |  |  |  * cases: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * - `void` You can associate styles with this name to be used when | 
					
						
							|  |  |  |  * the element is detached from the application. For example, when an `ngIf` evaluates | 
					
						
							|  |  |  |  * to false, the state of the associated element is void. | 
					
						
							|  |  |  |  *  - `*` (asterisk) Indicates the default state. You can associate styles with this name | 
					
						
							|  |  |  |  * to be used as the fallback when the state that is being animated is not declared | 
					
						
							|  |  |  |  * within the trigger. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param styles A set of CSS styles associated with this state, created using the | 
					
						
							|  |  |  |  * `style()` function. | 
					
						
							|  |  |  |  * This set of styles persists on the element once the state has been reached. | 
					
						
							|  |  |  |  * @param options Parameters that can be passed to the state when it is invoked. | 
					
						
							|  |  |  |  * 0 or more key-value pairs. | 
					
						
							|  |  |  |  * @return An object that encapsulates the new state data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * Use the `trigger()` function to register states to an animation trigger. | 
					
						
							|  |  |  |  * Use the `transition()` function to animate between states. | 
					
						
							|  |  |  |  * When a state is active within a component, its associated styles persist on the element, | 
					
						
							|  |  |  |  * even when the animation ends. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2017-08-07 11:40:04 -07:00
										 |  |  | export function state( | 
					
						
							|  |  |  |     name: string, styles: AnimationStyleMetadata, | 
					
						
							|  |  |  |     options?: {params: {[name: string]: any}}): AnimationStateMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.State, name, styles, options}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Defines a set of animation styles, associating each style with an optional `offset` value. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param steps A set of animation styles with optional offset data. | 
					
						
							|  |  |  |  * The optional `offset` value for a style specifies a percentage of the total animation | 
					
						
							|  |  |  |  * time at which that style is applied. | 
					
						
							|  |  |  |  * @returns An object that encapsulates the keyframes data. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * Use with the `animate()` call. Instead of applying animations | 
					
						
							|  |  |  |  * from the current state | 
					
						
							|  |  |  |  * to the destination state, keyframes describe how each style entry is applied and at what point | 
					
						
							|  |  |  |  * within the animation arc. | 
					
						
							|  |  |  |  * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Usage | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * In the following example, the offset values describe | 
					
						
							|  |  |  |  * when each `backgroundColor` value is applied. The color is red at the start, and changes to | 
					
						
							|  |  |  |  * blue when 20% of the total time has elapsed. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * // the provided offset values
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * animate("5s", keyframes([ | 
					
						
							|  |  |  |  *   style({ backgroundColor: "red", offset: 0 }), | 
					
						
							|  |  |  |  *   style({ backgroundColor: "blue", offset: 0.2 }), | 
					
						
							|  |  |  |  *   style({ backgroundColor: "orange", offset: 0.3 }), | 
					
						
							|  |  |  |  *   style({ backgroundColor: "black", offset: 1 }) | 
					
						
							|  |  |  |  * ])) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * If there are no `offset` values specified in the style entries, the offsets | 
					
						
							|  |  |  |  * are calculated automatically. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * animate("5s", keyframes([ | 
					
						
							|  |  |  |  *   style({ backgroundColor: "red" }) // offset = 0
 | 
					
						
							|  |  |  |  *   style({ backgroundColor: "blue" }) // offset = 0.33
 | 
					
						
							|  |  |  |  *   style({ backgroundColor: "orange" }) // offset = 0.66
 | 
					
						
							|  |  |  |  *   style({ backgroundColor: "black" }) // offset = 1
 | 
					
						
							|  |  |  |  * ])) | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *```
 | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSequenceMetadata { | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |   return {type: AnimationMetadataType.Keyframes, steps}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Declares an animation transition as a sequence of animation steps to run when a given | 
					
						
							|  |  |  |  * condition is satisfied. The condition is a Boolean expression or function that compares | 
					
						
							|  |  |  |  * the previous and current animation states, and returns true if this transition should occur. | 
					
						
							|  |  |  |  * When the state criteria of a defined transition are met, the associated animation is | 
					
						
							|  |  |  |  * triggered. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param stateChangeExpr A Boolean expression or function that compares the previous and current | 
					
						
							|  |  |  |  * animation states, and returns true if this transition should occur. Note that  "true" and "false" | 
					
						
							|  |  |  |  * match 1 and 0, respectively. An expression is evaluated each time a state change occurs in the | 
					
						
							|  |  |  |  * animation trigger element. | 
					
						
							|  |  |  |  * The animation steps run when the expression evaluates to true. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * - A state-change string takes the form "state1 => state2", where each side is a defined animation | 
					
						
							|  |  |  |  * state, or an asterix (*) to refer to a dynamic start or end state. | 
					
						
							|  |  |  |  *   - The expression string can contain multiple comma-separated statements; | 
					
						
							|  |  |  |  * for example "state1 => state2, state3 => state4". | 
					
						
							|  |  |  |  *   - Special values `:enter` and `:leave` initiate a transition on the entry and exit states, | 
					
						
							|  |  |  |  * equivalent to  "void => *"  and "* => void". | 
					
						
							|  |  |  |  *   - Special values `:increment` and `:decrement` initiate a transition when a numeric value has | 
					
						
							|  |  |  |  * increased or decreased in value. | 
					
						
							|  |  |  |  * - A function is executed each time a state change occurs in the animation trigger element. | 
					
						
							|  |  |  |  * The animation steps run when the function returns true. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param steps One or more animation objects, as returned by the `animate()` or | 
					
						
							|  |  |  |  * `sequence()` function, that form a transformation from one state to another. | 
					
						
							|  |  |  |  * A sequence is used by default when you pass an array. | 
					
						
							|  |  |  |  * @param options An options object that can contain a delay value for the start of the animation, | 
					
						
							|  |  |  |  * and additional developer-defined parameters. Provided values for additional parameters are used | 
					
						
							|  |  |  |  * as defaults, and override values can be passed to the caller on invocation. | 
					
						
							|  |  |  |  * @returns An object that encapsulates the transition data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * The template associated with a component binds an animation trigger to an element. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```HTML
 | 
					
						
							|  |  |  |  * <!-- somewhere inside of my-component-tpl.html --> | 
					
						
							|  |  |  |  * <div [@myAnimationTrigger]="myStatusExp">...</div> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * All transitions are defined within an animation trigger, | 
					
						
							|  |  |  |  * along with named states that the transitions change to and from. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * trigger("myAnimationTrigger", [ | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *  // define states
 | 
					
						
							|  |  |  |  *  state("on", style({ background: "green" })), | 
					
						
							|  |  |  |  *  state("off", style({ background: "grey" })), | 
					
						
							|  |  |  |  *  ...] | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-06-18 14:58:30 -07:00
										 |  |  |  * Note that when you call the `sequence()` function within a `{@link animations/group group()}` | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * or a `transition()` call, execution does not continue to the next instruction | 
					
						
							|  |  |  |  * until each of the inner animation steps have completed. | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Syntax examples | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following examples define transitions between the two defined states (and default states), | 
					
						
							|  |  |  |  * using various options: | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * // Transition occurs when the state value
 | 
					
						
							|  |  |  |  * // bound to "myAnimationTrigger" changes from "on" to "off"
 | 
					
						
							|  |  |  |  * transition("on => off", animate(500)) | 
					
						
							|  |  |  |  * // Run the same animation for both directions
 | 
					
						
							|  |  |  |  * transition("on <=> off", animate(500)) | 
					
						
							|  |  |  |  * // Define multiple state-change pairs separated by commas
 | 
					
						
							|  |  |  |  * transition("on => off, off => void", animate(500)) | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Special values for state-change expressions | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * - Catch-all state change for when an element is inserted into the page and the | 
					
						
							|  |  |  |  * destination state is unknown: | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * transition("void => *", [ | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *  style({ opacity: 0 }), | 
					
						
							|  |  |  |  *  animate(500) | 
					
						
							|  |  |  |  *  ]) | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * - Capture a state change between any states: | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *  `transition("* => *", animate("1s 0s"))` | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * - Entry and exit transitions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * transition(":enter", [ | 
					
						
							|  |  |  |  *   style({ opacity: 0 }), | 
					
						
							|  |  |  |  *   animate(500, style({ opacity: 1 })) | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *   ]), | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * transition(":leave", [ | 
					
						
							|  |  |  |  *   animate(500, style({ opacity: 0 })) | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *   ]) | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * - Use `:increment` and `:decrement` to initiate transitions: | 
					
						
							| 
									
										
										
										
											2017-09-19 14:22:22 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * transition(":increment", group([ | 
					
						
							|  |  |  |  *  query(':enter', [ | 
					
						
							|  |  |  |  *     style({ left: '100%' }), | 
					
						
							|  |  |  |  *     animate('0.5s ease-out', style('*')) | 
					
						
							|  |  |  |  *   ]), | 
					
						
							|  |  |  |  *  query(':leave', [ | 
					
						
							|  |  |  |  *     animate('0.5s ease-out', style({ left: '-100%' })) | 
					
						
							|  |  |  |  *  ]) | 
					
						
							|  |  |  |  * ])) | 
					
						
							| 
									
										
										
										
											2017-09-19 14:22:22 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * transition(":decrement", group([ | 
					
						
							|  |  |  |  *  query(':enter', [ | 
					
						
							|  |  |  |  *     style({ left: '100%' }), | 
					
						
							|  |  |  |  *     animate('0.5s ease-out', style('*')) | 
					
						
							|  |  |  |  *   ]), | 
					
						
							|  |  |  |  *  query(':leave', [ | 
					
						
							|  |  |  |  *     animate('0.5s ease-out', style({ left: '-100%' })) | 
					
						
							|  |  |  |  *  ]) | 
					
						
							|  |  |  |  * ])) | 
					
						
							| 
									
										
										
										
											2017-09-19 14:22:22 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### State-change functions | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Here is an example of a `fromState` specified as a state-change function that invokes an | 
					
						
							|  |  |  |  * animation when true: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * transition((fromState, toState) => | 
					
						
							|  |  |  |  *  { | 
					
						
							|  |  |  |  *   return fromState == "off" && toState == "on"; | 
					
						
							|  |  |  |  *  }, | 
					
						
							|  |  |  |  *  animate("1s 0s")) | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Animating to the final state | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * If the final step in a transition is a call to `animate()` that uses a timing value | 
					
						
							|  |  |  |  * with no style data, that step is automatically considered the final animation arc, | 
					
						
							|  |  |  |  * for the element to reach the final state. Angular automatically adds or removes | 
					
						
							|  |  |  |  * CSS styles to ensure that the element is in the correct final state. | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following example defines a transition that starts by hiding the element, | 
					
						
							|  |  |  |  * then makes sure that it animates properly to whatever state is currently active for trigger: | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  * transition("void => *", [ | 
					
						
							|  |  |  |  *   style({ opacity: 0 }), | 
					
						
							|  |  |  |  *   animate(500) | 
					
						
							|  |  |  |  *  ]) | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Boolean value matching | 
					
						
							|  |  |  |  * If a trigger binding value is a Boolean, it can be matched using a transition expression | 
					
						
							|  |  |  |  * that compares true and false or 1 and 0. For example: | 
					
						
							| 
									
										
										
										
											2017-07-07 09:10:10 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * // in the template
 | 
					
						
							|  |  |  |  * <div [@openClose]="open ? true : false">...</div> | 
					
						
							|  |  |  |  * // in the component metadata
 | 
					
						
							|  |  |  |  * trigger('openClose', [ | 
					
						
							|  |  |  |  *   state('true', style({ height: '*' })), | 
					
						
							|  |  |  |  *   state('false', style({ height: '0px' })), | 
					
						
							|  |  |  |  *   transition('false <=> true', animate(500)) | 
					
						
							|  |  |  |  * ]) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | export function transition( | 
					
						
							| 
									
										
										
										
											2018-03-12 17:21:02 -07:00
										 |  |  |     stateChangeExpr: string | ((fromState: string, toState: string, element?: any, | 
					
						
							|  |  |  |                                 params?: {[key: string]: any}) => boolean), | 
					
						
							| 
									
										
										
										
											2017-11-30 16:15:48 -08:00
										 |  |  |     steps: AnimationMetadata | AnimationMetadata[], | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |     options: AnimationOptions | null = null): AnimationTransitionMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Transition, expr: stateChangeExpr, animation: steps, options}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Produces a reusable animation that can be invoked in another animation or sequence, | 
					
						
							|  |  |  |  * by calling the `useAnimation()` function. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param steps One or more animation objects, as returned by the `animate()` | 
					
						
							|  |  |  |  * or `sequence()` function, that form a transformation from one state to another. | 
					
						
							|  |  |  |  * A sequence is used by default when you pass an array. | 
					
						
							|  |  |  |  * @param options An options object that can contain a delay value for the start of the | 
					
						
							|  |  |  |  * animation, and additional developer-defined parameters. | 
					
						
							|  |  |  |  * Provided values for additional parameters are used as defaults, | 
					
						
							|  |  |  |  * and override values can be passed to the caller on invocation. | 
					
						
							|  |  |  |  * @returns An object that encapsulates the animation data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * The following example defines a reusable animation, providing some default parameter | 
					
						
							|  |  |  |  * values. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * var fadeAnimation = animation([ | 
					
						
							|  |  |  |  *   style({ opacity: '{{ start }}' }), | 
					
						
							|  |  |  |  *   animate('{{ time }}', | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *   style({ opacity: '{{ end }}'})) | 
					
						
							|  |  |  |  *   ], | 
					
						
							|  |  |  |  *   { params: { time: '1000ms', start: 0, end: 1 }}); | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following invokes the defined animation with a call to `useAnimation()`, | 
					
						
							|  |  |  |  * passing in override parameter values. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```js
 | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * useAnimation(fadeAnimation, { | 
					
						
							|  |  |  |  *   params: { | 
					
						
							|  |  |  |  *     time: '2s', | 
					
						
							|  |  |  |  *     start: 1, | 
					
						
							|  |  |  |  *     end: 0 | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * If any of the passed-in parameter values are missing from this call, | 
					
						
							|  |  |  |  * the default values are used. If one or more parameter values are missing before a step is | 
					
						
							|  |  |  |  * animated, `useAnimation()` throws an error. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function animation( | 
					
						
							|  |  |  |     steps: AnimationMetadata | AnimationMetadata[], | 
					
						
							|  |  |  |     options: AnimationOptions | null = null): AnimationReferenceMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Reference, animation: steps, options}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Executes a queried inner animation element within an animation sequence. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param options An options object that can contain a delay value for the start of the | 
					
						
							|  |  |  |  * animation, and additional override values for developer-defined parameters. | 
					
						
							|  |  |  |  * @return An object that encapsulates the child animation data. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * Each time an animation is triggered in Angular, the parent animation | 
					
						
							|  |  |  |  * has priority and any child animations are blocked. In order | 
					
						
							|  |  |  |  * for a child animation to run, the parent animation must query each of the elements | 
					
						
							|  |  |  |  * containing child animations, and run them using this function. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Note that this feature designed to be used with `query()` and it will only work | 
					
						
							|  |  |  |  * with animations that are assigned using the Angular animation library. CSS keyframes | 
					
						
							|  |  |  |  * and transitions are not handled by this API. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-05-02 15:45:48 -07:00
										 |  |  | export function animateChild(options: AnimateChildOptions | null = null): | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |     AnimationAnimateChildMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.AnimateChild, options}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Starts a reusable animation that is created using the `animation()` function. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param animation The reusable animation to start. | 
					
						
							| 
									
										
										
										
											2018-10-19 12:12:20 +01:00
										 |  |  |  * @param options An options object that can contain a delay value for the start of | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * the animation, and additional override values for developer-defined parameters. | 
					
						
							|  |  |  |  * @return An object that contains the animation parameters. | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function useAnimation( | 
					
						
							|  |  |  |     animation: AnimationReferenceMetadata, | 
					
						
							|  |  |  |     options: AnimationOptions | null = null): AnimationAnimateRefMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.AnimateRef, animation, options}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Finds one or more inner elements within the current element that is | 
					
						
							| 
									
										
										
										
											2018-09-29 22:01:57 -05:00
										 |  |  |  * being animated within a sequence. Use with `animate()`. | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @param selector The element to query, or a set of elements that contain Angular-specific | 
					
						
							|  |  |  |  * characteristics, specified with one or more of the following tokens. | 
					
						
							|  |  |  |  *  - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements. | 
					
						
							|  |  |  |  *  - `query(":animating")` : Query all currently animating elements. | 
					
						
							|  |  |  |  *  - `query("@triggerName")` : Query elements that contain an animation trigger. | 
					
						
							|  |  |  |  *  - `query("@*")` : Query all elements that contain an animation triggers. | 
					
						
							|  |  |  |  *  - `query(":self")` : Include the current element into the animation sequence. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param animation One or more animation steps to apply to the queried element or elements. | 
					
						
							|  |  |  |  * An array is treated as an animation sequence. | 
					
						
							|  |  |  |  * @param options An options object. Use the 'limit' field to limit the total number of | 
					
						
							|  |  |  |  * items to collect. | 
					
						
							|  |  |  |  * @return An object that encapsulates the query data. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * Tokens can be merged into a combined query selector string. For example: | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							|  |  |  |  *  query(':self, .record:enter, .record:leave, @subTrigger', [...]) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The `query()` function collects multiple elements and works internally by using | 
					
						
							|  |  |  |  * `element.querySelectorAll`. Use the `limit` field of an options object to limit | 
					
						
							|  |  |  |  * the total number of items to be collected. For example: | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```js
 | 
					
						
							|  |  |  |  * query('div', [ | 
					
						
							|  |  |  |  *   animate(...), | 
					
						
							|  |  |  |  *   animate(...) | 
					
						
							|  |  |  |  * ], { limit: 1 }) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * By default, throws an error when zero items are found. Set the | 
					
						
							|  |  |  |  * `optional` flag to ignore this error. For example: | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```js
 | 
					
						
							|  |  |  |  * query('.some-element-that-may-not-be-there', [ | 
					
						
							|  |  |  |  *   animate(...), | 
					
						
							|  |  |  |  *   animate(...) | 
					
						
							|  |  |  |  * ], { optional: true }) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ### Usage Example | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * The following example queries for inner elements and animates them | 
					
						
							| 
									
										
										
										
											2018-09-29 22:01:57 -05:00
										 |  |  |  * individually using `animate()`.  | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * @Component({ | 
					
						
							|  |  |  |  *   selector: 'inner', | 
					
						
							|  |  |  |  *   template: `
 | 
					
						
							|  |  |  |  *     <div [@queryAnimation]="exp"> | 
					
						
							|  |  |  |  *       <h1>Title</h1> | 
					
						
							|  |  |  |  *       <div class="content"> | 
					
						
							|  |  |  |  *         Blah blah blah | 
					
						
							|  |  |  |  *       </div> | 
					
						
							|  |  |  |  *     </div> | 
					
						
							|  |  |  |  *   `,
 | 
					
						
							|  |  |  |  *   animations: [ | 
					
						
							|  |  |  |  *    trigger('queryAnimation', [ | 
					
						
							|  |  |  |  *      transition('* => goAnimate', [ | 
					
						
							|  |  |  |  *        // hide the inner elements
 | 
					
						
							|  |  |  |  *        query('h1', style({ opacity: 0 })), | 
					
						
							|  |  |  |  *        query('.content', style({ opacity: 0 })), | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *        // animate the inner elements in, one by one
 | 
					
						
							|  |  |  |  *        query('h1', animate(1000, style({ opacity: 1 })), | 
					
						
							|  |  |  |  *        query('.content', animate(1000, style({ opacity: 1 })), | 
					
						
							|  |  |  |  *      ]) | 
					
						
							|  |  |  |  *    ]) | 
					
						
							|  |  |  |  *  ] | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class Cmp { | 
					
						
							|  |  |  |  *   exp = ''; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   goAnimate() { | 
					
						
							|  |  |  |  *     this.exp = 'goAnimate'; | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function query( | 
					
						
							|  |  |  |     selector: string, animation: AnimationMetadata | AnimationMetadata[], | 
					
						
							|  |  |  |     options: AnimationQueryOptions | null = null): AnimationQueryMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Query, selector, animation, options}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Use within an animation `query()` call to issue a timing gap after | 
					
						
							|  |  |  |  * each queried item is animated. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @param timings A delay value. | 
					
						
							|  |  |  |  * @param animation One ore more animation steps. | 
					
						
							|  |  |  |  * @returns An object that encapsulates the stagger data. | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * @usageNotes | 
					
						
							|  |  |  |  * In the following example, a container element wraps a list of items stamped out | 
					
						
							|  |  |  |  * by an `ngFor`. The container element contains an animation trigger that will later be set | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * to query for each of the inner items. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Each time items are added, the opacity fade-in animation runs, | 
					
						
							|  |  |  |  * and each removed item is faded out. | 
					
						
							|  |  |  |  * When either of these animations occur, the stagger effect is | 
					
						
							|  |  |  |  * applied after each item's animation is started. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <!-- list.component.html --> | 
					
						
							|  |  |  |  * <button (click)="toggle()">Show / Hide Items</button> | 
					
						
							|  |  |  |  * <hr /> | 
					
						
							|  |  |  |  * <div [@listAnimation]="items.length"> | 
					
						
							|  |  |  |  *   <div *ngFor="let item of items"> | 
					
						
							|  |  |  |  *     {{ item }} | 
					
						
							|  |  |  |  *   </div> | 
					
						
							|  |  |  |  * </div> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Here is the component code: | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * import {trigger, transition, style, animate, query, stagger} from '@angular/animations'; | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							|  |  |  |  *   templateUrl: 'list.component.html', | 
					
						
							|  |  |  |  *   animations: [ | 
					
						
							|  |  |  |  *     trigger('listAnimation', [ | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *     ... | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  *     ]) | 
					
						
							|  |  |  |  *   ] | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class ListComponent { | 
					
						
							|  |  |  |  *   items = []; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   showItems() { | 
					
						
							|  |  |  |  *     this.items = [0,1,2,3,4]; | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   hideItems() { | 
					
						
							|  |  |  |  *     this.items = []; | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   toggle() { | 
					
						
							|  |  |  |  *     this.items.length ? this.hideItems() : this.showItems(); | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  *    } | 
					
						
							|  |  |  |  *  } | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * Here is the animation trigger code: | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-03 10:54:51 -07:00
										 |  |  |  * ```typescript
 | 
					
						
							| 
									
										
										
										
											2017-04-25 15:06:31 -07:00
										 |  |  |  * trigger('listAnimation', [ | 
					
						
							|  |  |  |  *   transition('* => *', [ // each time the binding value changes
 | 
					
						
							|  |  |  |  *     query(':leave', [ | 
					
						
							|  |  |  |  *       stagger(100, [ | 
					
						
							|  |  |  |  *         animate('0.5s', style({ opacity: 0 })) | 
					
						
							|  |  |  |  *       ]) | 
					
						
							|  |  |  |  *     ]), | 
					
						
							|  |  |  |  *     query(':enter', [ | 
					
						
							|  |  |  |  *       style({ opacity: 0 }), | 
					
						
							|  |  |  |  *       stagger(100, [ | 
					
						
							|  |  |  |  *         animate('0.5s', style({ opacity: 1 })) | 
					
						
							|  |  |  |  *       ]) | 
					
						
							|  |  |  |  *     ]) | 
					
						
							|  |  |  |  *   ]) | 
					
						
							|  |  |  |  * ]) | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2018-10-19 14:42:30 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @publicApi | 
					
						
							| 
									
										
										
										
											2017-04-26 10:44:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | export function stagger( | 
					
						
							|  |  |  |     timings: string | number, | 
					
						
							|  |  |  |     animation: AnimationMetadata | AnimationMetadata[]): AnimationStaggerMetadata { | 
					
						
							|  |  |  |   return {type: AnimationMetadataType.Stagger, timings, animation}; | 
					
						
							| 
									
										
										
										
											2017-01-26 11:16:51 -08:00
										 |  |  | } |