@angular/animations 6.0.3 → 6.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/browser.metadata.json +1 -1
- package/browser/src/dsl/animation_transition_factory.d.ts +1 -1
- package/browser/src/render/animation_engine_next.d.ts +2 -1
- package/browser/src/render/shared.d.ts +2 -0
- package/browser/src/render/timeline_animation_engine.d.ts +2 -1
- package/browser/src/render/transition_animation_engine.d.ts +3 -3
- package/browser/testing.d.ts +0 -5
- package/browser/testing.metadata.json +1 -1
- package/browser.d.ts +0 -5
- package/browser.metadata.json +1 -1
- package/bundles/animations-browser-testing.umd.js +28 -10
- package/bundles/animations-browser-testing.umd.js.map +1 -1
- package/bundles/animations-browser-testing.umd.min.js +16 -2
- package/bundles/animations-browser-testing.umd.min.js.map +1 -1
- package/bundles/animations-browser.umd.js +200 -83
- package/bundles/animations-browser.umd.js.map +1 -1
- package/bundles/animations-browser.umd.min.js +55 -6
- package/bundles/animations-browser.umd.min.js.map +1 -1
- package/bundles/animations.umd.js +470 -577
- package/bundles/animations.umd.js.map +1 -1
- package/bundles/animations.umd.min.js +9 -2
- package/bundles/animations.umd.min.js.map +1 -1
- package/esm2015/animations.externs.js +1 -1
- package/esm2015/browser/browser.externs.js +3 -3
- package/esm2015/browser/src/dsl/animation_transition_factory.js +4 -3
- package/esm2015/browser/src/render/animation_driver.js +1 -12
- package/esm2015/browser/src/render/animation_engine_next.js +8 -4
- package/esm2015/browser/src/render/shared.js +18 -3
- package/esm2015/browser/src/render/timeline_animation_engine.js +6 -2
- package/esm2015/browser/src/render/transition_animation_engine.js +23 -19
- package/esm2015/browser/src/render/web_animations/web_animations_driver.js +3 -3
- package/esm2015/browser/src/util.js +57 -1
- package/esm2015/src/animation_metadata.js +626 -659
- package/esm2015/src/version.js +1 -1
- package/esm5/browser/index.js +5 -1
- package/esm5/browser/public_api.js +6 -1
- package/esm5/browser/src/browser.js +6 -1
- package/esm5/browser/src/dsl/animation.js +1 -1
- package/esm5/browser/src/dsl/animation_ast_builder.js +11 -4
- package/esm5/browser/src/dsl/animation_timeline_builder.js +27 -21
- package/esm5/browser/src/dsl/animation_timeline_instruction.js +1 -1
- package/esm5/browser/src/dsl/animation_transition_expr.js +1 -1
- package/esm5/browser/src/dsl/animation_transition_factory.js +3 -3
- package/esm5/browser/src/dsl/animation_transition_instruction.js +1 -1
- package/esm5/browser/src/dsl/animation_trigger.js +2 -8
- package/esm5/browser/src/dsl/element_instruction_map.js +1 -1
- package/esm5/browser/src/dsl/style_normalization/animation_style_normalizer.js +3 -15
- package/esm5/browser/src/dsl/style_normalization/web_animations_style_normalizer.js +8 -1
- package/esm5/browser/src/private_export.js +8 -1
- package/esm5/browser/src/render/animation_driver.js +8 -3
- package/esm5/browser/src/render/animation_engine_next.js +5 -4
- package/esm5/browser/src/render/css_keyframes/css_keyframes_driver.js +1 -1
- package/esm5/browser/src/render/css_keyframes/css_keyframes_player.js +2 -4
- package/esm5/browser/src/render/css_keyframes/direct_style_player.js +8 -1
- package/esm5/browser/src/render/css_keyframes/element_animation_style_handler.js +1 -1
- package/esm5/browser/src/render/shared.js +19 -3
- package/esm5/browser/src/render/timeline_animation_engine.js +10 -2
- package/esm5/browser/src/render/transition_animation_engine.js +36 -39
- package/esm5/browser/src/render/web_animations/dom_animation.js +1 -1
- package/esm5/browser/src/render/web_animations/web_animations_driver.js +3 -3
- package/esm5/browser/src/render/web_animations/web_animations_player.js +3 -7
- package/esm5/browser/src/util.js +51 -3
- package/esm5/browser/testing/index.js +5 -1
- package/esm5/browser/testing/public_api.js +6 -1
- package/esm5/browser/testing/src/mock_animation_driver.js +12 -17
- package/esm5/browser/testing/src/testing.js +8 -1
- package/esm5/index.js +5 -1
- package/esm5/public_api.js +6 -1
- package/esm5/src/animation_builder.js +3 -93
- package/esm5/src/animation_event.js +1 -1
- package/esm5/src/animation_metadata.js +439 -568
- package/esm5/src/animations.js +6 -1
- package/esm5/src/players/animation_group_player.js +2 -4
- package/esm5/src/players/animation_player.js +11 -14
- package/esm5/src/private_export.js +8 -1
- package/esm5/src/util.js +1 -1
- package/esm5/src/version.js +3 -23
- package/fesm2015/animations.js +446 -631
- package/fesm2015/animations.js.map +1 -1
- package/fesm2015/browser/testing.js +1 -1
- package/fesm2015/browser/testing.js.map +1 -1
- package/fesm2015/browser.js +104 -29
- package/fesm2015/browser.js.map +1 -1
- package/fesm5/animations.js +470 -577
- package/fesm5/animations.js.map +1 -1
- package/fesm5/browser/testing.js +28 -10
- package/fesm5/browser/testing.js.map +1 -1
- package/fesm5/browser.js +200 -83
- package/fesm5/browser.js.map +1 -1
- package/package.json +3 -3
- package/src/animation_metadata.d.ts +673 -650
package/fesm2015/animations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v6.0.
|
|
2
|
+
* @license Angular v6.0.7
|
|
3
3
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -70,147 +70,128 @@ class AnimationFactory {
|
|
|
70
70
|
*
|
|
71
71
|
* Use of this source code is governed by an MIT-style license that can be
|
|
72
72
|
* found in the LICENSE file at https://angular.io/license
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* Represents a set of CSS styles for use in an animation style.
|
|
73
76
|
* @record
|
|
74
77
|
*/
|
|
75
78
|
|
|
76
79
|
/**
|
|
77
|
-
*
|
|
80
|
+
* Specifies automatic styling.
|
|
78
81
|
*/
|
|
79
82
|
const AUTO_STYLE = '*';
|
|
80
83
|
/**
|
|
81
|
-
*
|
|
84
|
+
* Base for animation data structures.
|
|
82
85
|
* @record
|
|
83
86
|
*/
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* \@experimental Animation support is experimental.
|
|
89
|
+
* Contains an animation trigger. Instantiated and returned by the
|
|
90
|
+
* `trigger()` function.
|
|
90
91
|
* @record
|
|
91
92
|
*/
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* \@experimental Animation support is experimental.
|
|
95
|
+
* Encapsulates an animation state by associating a state name with a set of CSS styles.
|
|
96
|
+
* Instantiated and returned by the `state()` function.
|
|
98
97
|
* @record
|
|
99
98
|
*/
|
|
100
99
|
|
|
101
100
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* \@experimental Animation support is experimental.
|
|
101
|
+
* Encapsulates an animation transition. Instantiated and returned by the
|
|
102
|
+
* `transition()` function.
|
|
106
103
|
* @record
|
|
107
104
|
*/
|
|
108
105
|
|
|
109
106
|
/**
|
|
110
|
-
*
|
|
107
|
+
* Encapsulates a reusable animation, which is a collection of individual animation steps.
|
|
108
|
+
* Instantiated and returned by the `animation()` function, and
|
|
109
|
+
* passed to the `useAnimation()` function.
|
|
111
110
|
* @record
|
|
112
111
|
*/
|
|
113
112
|
|
|
114
113
|
/**
|
|
115
|
-
*
|
|
114
|
+
* Encapsulates an animation query. Instantiated and returned by
|
|
115
|
+
* the `query()` function.
|
|
116
116
|
* @record
|
|
117
117
|
*/
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* \@experimental Animation support is experimental.
|
|
120
|
+
* Encapsulates a keyframes sequence. Instantiated and returned by
|
|
121
|
+
* the `keyframes()` function.
|
|
124
122
|
* @record
|
|
125
123
|
*/
|
|
126
124
|
|
|
127
125
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* \@experimental Animation support is experimental.
|
|
126
|
+
* Encapsulates an animation style. Instantiated and returned by
|
|
127
|
+
* the `style()` function.
|
|
132
128
|
* @record
|
|
133
129
|
*/
|
|
134
130
|
|
|
135
131
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* \@experimental Animation support is experimental.
|
|
132
|
+
* Encapsulates an animation step. Instantiated and returned by
|
|
133
|
+
* the `animate()` function.
|
|
140
134
|
* @record
|
|
141
135
|
*/
|
|
142
136
|
|
|
143
137
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* \@experimental Animation support is experimental.
|
|
138
|
+
* Encapsulates a child animation, that can be run explicitly when the parent is run.
|
|
139
|
+
* Instantiated and returned by the `animateChild` function.
|
|
148
140
|
* @record
|
|
149
141
|
*/
|
|
150
142
|
|
|
151
143
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* \@experimental Animation support is experimental.
|
|
144
|
+
* Encapsulates a reusable animation.
|
|
145
|
+
* Instantiated and returned by the `useAnimation()` function.
|
|
156
146
|
* @record
|
|
157
147
|
*/
|
|
158
148
|
|
|
159
149
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* \@experimental Animation support is experimental.
|
|
150
|
+
* Encapsulates an animation sequence.
|
|
151
|
+
* Instantiated and returned by the `sequence()` function.
|
|
164
152
|
* @record
|
|
165
153
|
*/
|
|
166
154
|
|
|
167
155
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* \@experimental Animation support is experimental.
|
|
156
|
+
* Encapsulates an animation group.
|
|
157
|
+
* Instantiated and returned by the `{\@link animations/group group()}` function.
|
|
172
158
|
* @record
|
|
173
159
|
*/
|
|
174
160
|
|
|
175
161
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
162
|
+
* Encapsulates parameters for staggering the start times of a set of animation steps.
|
|
163
|
+
* Instantiated and returned by the `stagger()` function.
|
|
178
164
|
*
|
|
179
|
-
* \@experimental Animation support is experimental.
|
|
180
165
|
* @record
|
|
181
166
|
*/
|
|
182
167
|
|
|
183
168
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* {\@link Component#animations component animations metadata page} to gain a better
|
|
187
|
-
* understanding of how animations in Angular are used.
|
|
188
|
-
*
|
|
189
|
-
* `trigger` Creates an animation trigger which will a list of {\@link state state} and
|
|
190
|
-
* {\@link transition transition} entries that will be evaluated when the expression
|
|
169
|
+
* Creates a named animation trigger, containing a list of `state()`
|
|
170
|
+
* and `transition()` entries to be evaluated when the expression
|
|
191
171
|
* bound to the trigger changes.
|
|
192
172
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* the
|
|
197
|
-
* trigger is bound to (in the form of `[\@triggerName]="expression"`.
|
|
173
|
+
* \@usageNotes
|
|
174
|
+
* Define an animation trigger in the `animations` section of `\@Component` metadata.
|
|
175
|
+
* In the template, reference the trigger by name and bind it to a trigger expression that
|
|
176
|
+
* evaluates to a defined animation state, using the following format:
|
|
198
177
|
*
|
|
199
|
-
*
|
|
200
|
-
* any linked transitions. If a boolean value is provided into the trigger binding then it will both
|
|
201
|
-
* be represented as `1` or `true` and `0` or `false` for a true and false boolean values
|
|
202
|
-
* respectively.
|
|
178
|
+
* `[\@triggerName]="expression"`
|
|
203
179
|
*
|
|
204
|
-
*
|
|
180
|
+
* Animation trigger bindings convert all values to strings, and then match the
|
|
181
|
+
* previous and current values against any linked transitions.
|
|
182
|
+
* Booleans can be specified as `1` or `true` and `0` or `false`.
|
|
183
|
+
*
|
|
184
|
+
* ### Usage Example
|
|
205
185
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
186
|
+
* The following example creates an animation trigger reference based on the provided
|
|
187
|
+
* name value.
|
|
188
|
+
* The provided animation value is expected to be an array consisting of state and
|
|
189
|
+
* transition declarations.
|
|
209
190
|
*
|
|
210
191
|
* ```typescript
|
|
211
192
|
* \@Component({
|
|
212
|
-
* selector:
|
|
213
|
-
* templateUrl:
|
|
193
|
+
* selector: "my-component",
|
|
194
|
+
* templateUrl: "my-component-tpl.html",
|
|
214
195
|
* animations: [
|
|
215
196
|
* trigger("myAnimationTrigger", [
|
|
216
197
|
* state(...),
|
|
@@ -225,8 +206,8 @@ const AUTO_STYLE = '*';
|
|
|
225
206
|
* }
|
|
226
207
|
* ```
|
|
227
208
|
*
|
|
228
|
-
* The template associated with this component
|
|
229
|
-
*
|
|
209
|
+
* The template associated with this component makes use of the defined trigger
|
|
210
|
+
* by binding to an element within its template code.
|
|
230
211
|
*
|
|
231
212
|
* ```html
|
|
232
213
|
* <!-- somewhere inside of my-component-tpl.html -->
|
|
@@ -237,9 +218,8 @@ const AUTO_STYLE = '*';
|
|
|
237
218
|
* The `transition` animation method also supports reading an inline function which can decide
|
|
238
219
|
* if its associated animation should be run.
|
|
239
220
|
*
|
|
240
|
-
* ```
|
|
241
|
-
* // this method
|
|
242
|
-
* // trigger value changes...
|
|
221
|
+
* ```typescript
|
|
222
|
+
* // this method is run each time the `myAnimationTrigger` trigger value changes.
|
|
243
223
|
* function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
|
|
244
224
|
* string]: any}): boolean {
|
|
245
225
|
* // notice that `element` and `params` are also available here
|
|
@@ -262,18 +242,16 @@ const AUTO_STYLE = '*';
|
|
|
262
242
|
* }
|
|
263
243
|
* ```
|
|
264
244
|
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
245
|
+
* ### Disabling Animations
|
|
246
|
+
* When true, the special animation control binding `\@.disabled` binding prevents
|
|
247
|
+
* all animations from rendering.
|
|
248
|
+
* Place the `\@.disabled` binding on an element to disable
|
|
249
|
+
* animations on the element itself, as well as any inner animation triggers
|
|
250
|
+
* within the element.
|
|
267
251
|
*
|
|
268
|
-
*
|
|
269
|
-
* A special animation control binding called `\@.disabled` can be placed on an element which will
|
|
270
|
-
* then disable animations for any inner animation triggers situated within the element as well as
|
|
271
|
-
* any animations on the element itself.
|
|
252
|
+
* The following example shows how to use this feature:
|
|
272
253
|
*
|
|
273
|
-
*
|
|
274
|
-
* below shows how to use this feature:
|
|
275
|
-
*
|
|
276
|
-
* ```ts
|
|
254
|
+
* ```typescript
|
|
277
255
|
* \@Component({
|
|
278
256
|
* selector: 'my-component',
|
|
279
257
|
* template: `
|
|
@@ -293,19 +271,16 @@ const AUTO_STYLE = '*';
|
|
|
293
271
|
* }
|
|
294
272
|
* ```
|
|
295
273
|
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* Note that `\@.disabled` will only disable all animations (this means any animations running on
|
|
300
|
-
* the same element will also be disabled).
|
|
274
|
+
* When `\@.disabled` is true, it prevents the `\@childAnimation` trigger from animating,
|
|
275
|
+
* along with any inner animations.
|
|
301
276
|
*
|
|
302
|
-
* ###
|
|
303
|
-
* When an area of the template is set to have animations disabled,
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* component.
|
|
277
|
+
* ### Disable animations application-wide
|
|
278
|
+
* When an area of the template is set to have animations disabled,
|
|
279
|
+
* **all** inner components have their animations disabled as well.
|
|
280
|
+
* This means that you can disable all animations for an app
|
|
281
|
+
* by placing a host binding set on `\@.disabled` on the topmost Angular component.
|
|
307
282
|
*
|
|
308
|
-
* ```
|
|
283
|
+
* ```typescript
|
|
309
284
|
* import {Component, HostBinding} from '\@angular/core';
|
|
310
285
|
*
|
|
311
286
|
* \@Component({
|
|
@@ -313,102 +288,109 @@ const AUTO_STYLE = '*';
|
|
|
313
288
|
* templateUrl: 'app.component.html',
|
|
314
289
|
* })
|
|
315
290
|
* class AppComponent {
|
|
316
|
-
*
|
|
291
|
+
* \@HostBinding('@.disabled')
|
|
317
292
|
* public animationsDisabled = true;
|
|
318
293
|
* }
|
|
319
294
|
* ```
|
|
320
295
|
*
|
|
321
|
-
* ###
|
|
322
|
-
* Despite inner animations being disabled, a parent animation can
|
|
323
|
-
* elements located in disabled areas of the template and still animate
|
|
324
|
-
* also the case for when a sub animation is
|
|
325
|
-
*
|
|
326
|
-
* ### Detecting when an animation is disabled
|
|
327
|
-
* If a region of the DOM (or the entire application) has its animations disabled, then animation
|
|
328
|
-
* trigger callbacks will still fire just as normal (only for zero seconds).
|
|
296
|
+
* ### Overriding disablement of inner animations
|
|
297
|
+
* Despite inner animations being disabled, a parent animation can `query()`
|
|
298
|
+
* for inner elements located in disabled areas of the template and still animate
|
|
299
|
+
* them if needed. This is also the case for when a sub animation is
|
|
300
|
+
* queried by a parent and then later animated using `animateChild()`.
|
|
329
301
|
*
|
|
330
|
-
*
|
|
331
|
-
* animations
|
|
332
|
-
*
|
|
302
|
+
* ### Detecting when an animation is disabled
|
|
303
|
+
* If a region of the DOM (or the entire application) has its animations disabled, the animation
|
|
304
|
+
* trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
|
|
305
|
+
* an instance of an `AnimationEvent`. If animations are disabled,
|
|
306
|
+
* the `.disabled` flag on the event is true.
|
|
333
307
|
*
|
|
334
308
|
* \@experimental Animation support is experimental.
|
|
335
|
-
* @param {?} name
|
|
336
|
-
* @param {?} definitions
|
|
337
|
-
*
|
|
309
|
+
* @param {?} name An identifying string.
|
|
310
|
+
* @param {?} definitions An animation definition object, containing an array of `state()`
|
|
311
|
+
* and `transition()` declarations.
|
|
312
|
+
*
|
|
313
|
+
* @return {?} An object that encapsulates the trigger data.
|
|
314
|
+
*
|
|
338
315
|
*/
|
|
339
316
|
function trigger(name, definitions) {
|
|
340
317
|
return { type: 7 /* Trigger */, name, definitions, options: {} };
|
|
341
318
|
}
|
|
342
319
|
/**
|
|
343
|
-
*
|
|
344
|
-
* animation DSL language. If this information is new, please navigate to the {\@link
|
|
345
|
-
* Component#animations component animations metadata page} to gain a better understanding of
|
|
346
|
-
* how animations in Angular are used.
|
|
320
|
+
* Defines an animation step that combines styling information with timing information.
|
|
347
321
|
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
322
|
+
* \@usageNotes
|
|
323
|
+
* Call within an animation `sequence()`, `{\@link animations/group group()}`, or
|
|
324
|
+
* `transition()` call to specify an animation step
|
|
325
|
+
* that applies given style data to the parent animation for a given amount of time.
|
|
352
326
|
*
|
|
353
|
-
* ###
|
|
327
|
+
* ### Syntax Examples
|
|
328
|
+
* **Timing examples**
|
|
354
329
|
*
|
|
355
|
-
* The
|
|
330
|
+
* The following examples show various `timings` specifications.
|
|
331
|
+
* - `animate(500)` : Duration is 500 milliseconds.
|
|
332
|
+
* - `animate("1s")` : Duration is 1000 milliseconds.
|
|
333
|
+
* - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
|
|
334
|
+
* - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
|
|
335
|
+
* - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
|
|
336
|
+
* milliseconds, easing according to a bezier curve.
|
|
356
337
|
*
|
|
357
|
-
*
|
|
358
|
-
* and easing values. The format for the expression breaks down to `duration delay easing`
|
|
359
|
-
* (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
|
|
360
|
-
* delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
|
|
361
|
-
* `duration` value in millisecond form.
|
|
362
|
-
* - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
|
|
363
|
-
* keyframes keyframes}. If left empty then the styles from the destination state will be collected
|
|
364
|
-
* and used (this is useful when describing an animation step that will complete an animation by
|
|
365
|
-
* {\@link transition#the-final-animate-call animating to the final state}).
|
|
338
|
+
* **Style examples**
|
|
366
339
|
*
|
|
340
|
+
* The following example calls `style()` to set a single CSS style.
|
|
367
341
|
* ```typescript
|
|
368
|
-
* // various functions for specifying timing data
|
|
369
|
-
* animate(500, style(...))
|
|
370
|
-
* animate("1s", style(...))
|
|
371
|
-
* animate("100ms 0.5s", style(...))
|
|
372
|
-
* animate("5s ease", style(...))
|
|
373
|
-
* animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
|
|
374
|
-
*
|
|
375
|
-
* // either style() of keyframes() can be used
|
|
376
342
|
* animate(500, style({ background: "red" }))
|
|
377
|
-
*
|
|
343
|
+
* ```
|
|
344
|
+
* The following example calls `keyframes()` to set a CSS style
|
|
345
|
+
* to different values for successive keyframes.
|
|
346
|
+
* ```typescript
|
|
347
|
+
* animate(500, keyframes(
|
|
348
|
+
* [
|
|
378
349
|
* style({ background: "blue" })),
|
|
379
350
|
* style({ background: "red" }))
|
|
380
|
-
*
|
|
351
|
+
* ])
|
|
381
352
|
* ```
|
|
353
|
+
* @param {?} timings Sets `AnimateTimings` for the parent animation.
|
|
354
|
+
* A string in the format "duration [delay] [easing]".
|
|
355
|
+
* - Duration and delay are expressed as a number and optional time unit,
|
|
356
|
+
* such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
|
|
357
|
+
* The default unit is milliseconds.
|
|
358
|
+
* - The easing value controls how the animation accelerates and decelerates
|
|
359
|
+
* during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
|
|
360
|
+
* `ease-in-out`, or a `cubic-bezier()` function call.
|
|
361
|
+
* If not supplied, no easing is applied.
|
|
362
|
+
*
|
|
363
|
+
* For example, the string "1s 100ms ease-out" specifies a duration of
|
|
364
|
+
* 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
|
|
365
|
+
* which decelerates near the end of the duration.
|
|
366
|
+
* @param {?=} styles Sets AnimationStyles for the parent animation.
|
|
367
|
+
* A function call to either `style()` or `keyframes()`
|
|
368
|
+
* that returns a collection of CSS style entries to be applied to the parent animation.
|
|
369
|
+
* When null, uses the styles from the destination state.
|
|
370
|
+
* This is useful when describing an animation step that will complete an animation;
|
|
371
|
+
* see "Animating to the final state" in `transitions()`.
|
|
372
|
+
* @return {?} An object that encapsulates the animation step.
|
|
382
373
|
*
|
|
383
|
-
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
|
384
|
-
*
|
|
385
|
-
* \@experimental Animation support is experimental.
|
|
386
|
-
* @param {?} timings
|
|
387
|
-
* @param {?=} styles
|
|
388
|
-
* @return {?}
|
|
389
374
|
*/
|
|
390
375
|
function animate(timings, styles = null) {
|
|
391
376
|
return { type: 4 /* Animate */, styles, timings };
|
|
392
377
|
}
|
|
393
378
|
/**
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* steps
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
|
|
410
|
-
* within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
|
|
411
|
-
* animate#usage animate() with a delay value} to offset styles to be applied at a later time).
|
|
379
|
+
* \@description Defines a list of animation steps to be run in parallel.
|
|
380
|
+
*
|
|
381
|
+
* \@usageNotes
|
|
382
|
+
* Grouped animations are useful when a series of styles must be
|
|
383
|
+
* animated at different starting times and closed off at different ending times.
|
|
384
|
+
*
|
|
385
|
+
* When called within a `sequence()` or a
|
|
386
|
+
* `transition()` call, does not continue to the next
|
|
387
|
+
* instruction until all of the inner animation steps have completed.
|
|
388
|
+
* @param {?} steps An array of animation step objects.
|
|
389
|
+
* - When steps are defined by `style()` or `animate()`
|
|
390
|
+
* function calls, each call within the group is executed instantly.
|
|
391
|
+
* - To specify offset styles to be applied at a later time, define steps with
|
|
392
|
+
* `keyframes()`, or use `animate()` calls with a delay value.
|
|
393
|
+
* For example:
|
|
412
394
|
*
|
|
413
395
|
* ```typescript
|
|
414
396
|
* group([
|
|
@@ -417,38 +399,33 @@ function animate(timings, styles = null) {
|
|
|
417
399
|
* ])
|
|
418
400
|
* ```
|
|
419
401
|
*
|
|
420
|
-
* {
|
|
402
|
+
* @param {?=} options An options object containing a delay and
|
|
403
|
+
* developer-defined parameters that provide styling defaults and
|
|
404
|
+
* can be overridden on invocation.
|
|
405
|
+
*
|
|
406
|
+
* @return {?} An object that encapsulates the group data.
|
|
421
407
|
*
|
|
422
|
-
* \@experimental Animation support is experimental.
|
|
423
|
-
* @param {?} steps
|
|
424
|
-
* @param {?=} options
|
|
425
|
-
* @return {?}
|
|
426
408
|
*/
|
|
427
409
|
function group(steps, options = null) {
|
|
428
410
|
return { type: 3 /* Group */, steps, options };
|
|
429
411
|
}
|
|
430
412
|
/**
|
|
431
|
-
*
|
|
432
|
-
* animation DSL language. If this information is new, please navigate to the {\@link
|
|
433
|
-
* Component#animations component animations metadata page} to gain a better understanding of
|
|
434
|
-
* how animations in Angular are used.
|
|
413
|
+
* Defines a list of animation steps to be run sequentially, one by one.
|
|
435
414
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
415
|
+
* \@usageNotes
|
|
416
|
+
* When you pass an array of steps to a
|
|
417
|
+
* `transition()` call, the steps run sequentially by default.
|
|
418
|
+
* Compare this to the `{\@link animations/group group()}` call, which runs animation steps in parallel.
|
|
438
419
|
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
420
|
+
* When a sequence is used within a `{\@link animations/group group()}` or a `transition()` call,
|
|
421
|
+
* execution continues to the next instruction only after each of the inner animation
|
|
441
422
|
* steps have completed.
|
|
442
423
|
*
|
|
443
|
-
* To perform animation styling in parallel with other animation steps then have a look at the
|
|
444
|
-
* {\@link group group} animation function.
|
|
445
|
-
*
|
|
446
|
-
* ### Usage
|
|
447
424
|
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
425
|
+
* @param {?} steps An array of animation step objects.
|
|
426
|
+
* - Steps defined by `style()` calls apply the styling data immediately.
|
|
427
|
+
* - Steps defined by `animate()` calls apply the styling data over time
|
|
428
|
+
* as specified by the timing data.
|
|
452
429
|
*
|
|
453
430
|
* ```typescript
|
|
454
431
|
* sequence([
|
|
@@ -457,139 +434,107 @@ function group(steps, options = null) {
|
|
|
457
434
|
* ])
|
|
458
435
|
* ```
|
|
459
436
|
*
|
|
460
|
-
* {
|
|
437
|
+
* @param {?=} options An options object containing a delay and
|
|
438
|
+
* developer-defined parameters that provide styling defaults and
|
|
439
|
+
* can be overridden on invocation.
|
|
440
|
+
*
|
|
441
|
+
* @return {?} An object that encapsulates the sequence data.
|
|
461
442
|
*
|
|
462
|
-
* \@experimental Animation support is experimental.
|
|
463
|
-
* @param {?} steps
|
|
464
|
-
* @param {?=} options
|
|
465
|
-
* @return {?}
|
|
466
443
|
*/
|
|
467
444
|
function sequence(steps, options = null) {
|
|
468
445
|
return { type: 2 /* Sequence */, steps, options };
|
|
469
446
|
}
|
|
470
447
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
* how animations in Angular are used.
|
|
448
|
+
* Declares a key/value object containing CSS properties/styles that
|
|
449
|
+
* can then be used for an animation `state`, within an animation `sequence`,
|
|
450
|
+
* or as styling data for calls to `animate()` and `keyframes()`.
|
|
475
451
|
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
* ### Usage
|
|
481
|
-
*
|
|
482
|
-
* `style` takes in a key/value string map as data and expects one or more CSS property/value pairs
|
|
483
|
-
* to be defined.
|
|
452
|
+
* \@usageNotes
|
|
453
|
+
* The following examples create animation styles that collect a set of
|
|
454
|
+
* CSS property values:
|
|
484
455
|
*
|
|
485
456
|
* ```typescript
|
|
486
|
-
* // string values
|
|
457
|
+
* // string values for CSS properties
|
|
487
458
|
* style({ background: "red", color: "blue" })
|
|
488
459
|
*
|
|
489
|
-
* // numerical
|
|
460
|
+
* // numerical pixel values
|
|
490
461
|
* style({ width: 100, height: 0 })
|
|
491
462
|
* ```
|
|
492
463
|
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* When an asterix (`*`) character is used as a value then it will be detected from the element
|
|
496
|
-
* being animated and applied as animation data when the animation starts.
|
|
464
|
+
* The following example uses auto-styling to allow a component to animate from
|
|
465
|
+
* a height of 0 up to the height of the parent element:
|
|
497
466
|
*
|
|
498
|
-
*
|
|
499
|
-
* cases the styles are calculated just before the animation starts.
|
|
500
|
-
*
|
|
501
|
-
* ```typescript
|
|
502
|
-
* // the steps below will animate from 0 to the
|
|
503
|
-
* // actual height of the element
|
|
467
|
+
* ```
|
|
504
468
|
* style({ height: 0 }),
|
|
505
469
|
* animate("1s", style({ height: "*" }))
|
|
506
470
|
* ```
|
|
507
471
|
*
|
|
508
|
-
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
|
509
472
|
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
473
|
+
* @param {?} tokens A set of CSS styles or HTML styles associated with an animation state.
|
|
474
|
+
* The value can be any of the following:
|
|
475
|
+
* - A key-value style pair associating a CSS property with a value.
|
|
476
|
+
* - An array of key-value style pairs.
|
|
477
|
+
* - An asterisk (*), to use auto-styling, where styles are derived from the element
|
|
478
|
+
* being animated and applied to the animation when it starts.
|
|
479
|
+
*
|
|
480
|
+
* Auto-styling can be used to define a state that depends on layout or other
|
|
481
|
+
* environmental factors.
|
|
482
|
+
*
|
|
483
|
+
* @return {?} An object that encapsulates the style data.
|
|
484
|
+
*
|
|
513
485
|
*/
|
|
514
486
|
function style(tokens) {
|
|
515
487
|
return { type: 6 /* Style */, styles: tokens, offset: null };
|
|
516
488
|
}
|
|
517
489
|
/**
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
* `state` will declare an animation state with its associated styles
|
|
545
|
-
* within the given trigger.
|
|
546
|
-
*
|
|
547
|
-
* - `stateNameExpr` can be one or more state names separated by commas.
|
|
548
|
-
* - `styles` refers to the {\@link style styling data} that will be persisted on the element once
|
|
549
|
-
* the state has been reached.
|
|
550
|
-
*
|
|
551
|
-
* ```typescript
|
|
552
|
-
* // "void" is a reserved name for a state and is used to represent
|
|
553
|
-
* // the state in which an element is detached from from the application.
|
|
554
|
-
* state("void", style({ height: 0 }))
|
|
490
|
+
* Declares an animation state within a trigger attached to an element.
|
|
491
|
+
*
|
|
492
|
+
* \@usageNotes
|
|
493
|
+
* Use the `trigger()` function to register states to an animation trigger.
|
|
494
|
+
* Use the `transition()` function to animate between states.
|
|
495
|
+
* When a state is active within a component, its associated styles persist on the element,
|
|
496
|
+
* even when the animation ends.
|
|
497
|
+
*
|
|
498
|
+
* @param {?} name One or more names for the defined state in a comma-separated string.
|
|
499
|
+
* The following reserved state names can be supplied to define a style for specific use
|
|
500
|
+
* cases:
|
|
501
|
+
*
|
|
502
|
+
* - `void` You can associate styles with this name to be used when
|
|
503
|
+
* the element is detached from the application. For example, when an `ngIf` evaluates
|
|
504
|
+
* to false, the state of the associated element is void.
|
|
505
|
+
* - `*` (asterisk) Indicates the default state. You can associate styles with this name
|
|
506
|
+
* to be used as the fallback when the state that is being animated is not declared
|
|
507
|
+
* within the trigger.
|
|
508
|
+
*
|
|
509
|
+
* @param {?} styles A set of CSS styles associated with this state, created using the
|
|
510
|
+
* `style()` function.
|
|
511
|
+
* This set of styles persists on the element once the state has been reached.
|
|
512
|
+
* @param {?=} options Parameters that can be passed to the state when it is invoked.
|
|
513
|
+
* 0 or more key-value pairs.
|
|
514
|
+
* @return {?} An object that encapsulates the new state data.
|
|
555
515
|
*
|
|
556
|
-
* // user-defined states
|
|
557
|
-
* state("closed", style({ height: 0 }))
|
|
558
|
-
* state("open, visible", style({ height: "*" }))
|
|
559
|
-
* ```
|
|
560
|
-
*
|
|
561
|
-
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
|
562
|
-
*
|
|
563
|
-
* \@experimental Animation support is experimental.
|
|
564
|
-
* @param {?} name
|
|
565
|
-
* @param {?} styles
|
|
566
|
-
* @param {?=} options
|
|
567
|
-
* @return {?}
|
|
568
516
|
*/
|
|
569
517
|
function state(name, styles, options) {
|
|
570
518
|
return { type: 0 /* State */, name, styles, options };
|
|
571
519
|
}
|
|
572
520
|
/**
|
|
573
|
-
*
|
|
574
|
-
* animation DSL language. If this information is new, please navigate to the {\@link
|
|
575
|
-
* Component#animations component animations metadata page} to gain a better understanding of
|
|
576
|
-
* how animations in Angular are used.
|
|
521
|
+
* Defines a set of animation styles, associating each style with an optional `offset` value.
|
|
577
522
|
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
523
|
+
* \@usageNotes
|
|
524
|
+
* Use with the `animate()` call. Instead of applying animations
|
|
525
|
+
* from the current state
|
|
526
|
+
* to the destination state, keyframes describe how each style entry is applied and at what point
|
|
527
|
+
* within the animation arc.
|
|
528
|
+
* Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
|
|
580
529
|
*
|
|
581
530
|
* ### Usage
|
|
582
531
|
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* animation arc (much like CSS Keyframe Animations do).
|
|
587
|
-
*
|
|
588
|
-
* For each `style()` entry an `offset` value can be set. Doing so allows to specify at what
|
|
589
|
-
* percentage of the animate time the styles will be applied.
|
|
532
|
+
* In the following example, the offset values describe
|
|
533
|
+
* when each `backgroundColor` value is applied. The color is red at the start, and changes to
|
|
534
|
+
* blue when 20% of the total time has elapsed.
|
|
590
535
|
*
|
|
591
536
|
* ```typescript
|
|
592
|
-
* // the provided offset values
|
|
537
|
+
* // the provided offset values
|
|
593
538
|
* animate("5s", keyframes([
|
|
594
539
|
* style({ backgroundColor: "red", offset: 0 }),
|
|
595
540
|
* style({ backgroundColor: "blue", offset: 0.2 }),
|
|
@@ -598,8 +543,8 @@ function state(name, styles, options) {
|
|
|
598
543
|
* ]))
|
|
599
544
|
* ```
|
|
600
545
|
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
546
|
+
* If there are no `offset` values specified in the style entries, the offsets
|
|
547
|
+
* are calculated automatically.
|
|
603
548
|
*
|
|
604
549
|
* ```typescript
|
|
605
550
|
* animate("5s", keyframes([
|
|
@@ -609,244 +554,206 @@ function state(name, styles, options) {
|
|
|
609
554
|
* style({ backgroundColor: "black" }) // offset = 1
|
|
610
555
|
* ]))
|
|
611
556
|
* ```
|
|
557
|
+
* @param {?} steps A set of animation styles with optional offset data.
|
|
558
|
+
* The optional `offset` value for a style specifies a percentage of the total animation
|
|
559
|
+
* time at which that style is applied.
|
|
560
|
+
* @return {?} An object that encapsulates the keyframes data.
|
|
612
561
|
*
|
|
613
|
-
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
|
614
|
-
*
|
|
615
|
-
* \@experimental Animation support is experimental.
|
|
616
|
-
* @param {?} steps
|
|
617
|
-
* @return {?}
|
|
618
562
|
*/
|
|
619
563
|
function keyframes(steps) {
|
|
620
564
|
return { type: 5 /* Keyframes */, steps };
|
|
621
565
|
}
|
|
622
566
|
/**
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
* `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
|
|
629
|
-
* provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
|
|
630
|
-
* state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
|
|
631
|
-
* and/or ending state).
|
|
632
|
-
*
|
|
633
|
-
* A function can also be provided as the `stateChangeExpr` argument for a transition and this
|
|
634
|
-
* function will be executed each time a state change occurs. If the value returned within the
|
|
635
|
-
* function is true then the associated animation will be run.
|
|
567
|
+
* Declares an animation transition as a sequence of animation steps to run when a given
|
|
568
|
+
* condition is satisfied. The condition is a Boolean expression or function that compares
|
|
569
|
+
* the previous and current animation states, and returns true if this transition should occur.
|
|
570
|
+
* When the state criteria of a defined transition are met, the associated animation is
|
|
571
|
+
* triggered.
|
|
636
572
|
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
* states} is expected to be defined.
|
|
573
|
+
* \@usageNotes
|
|
574
|
+
* The template associated with a component binds an animation trigger to an element.
|
|
640
575
|
*
|
|
641
|
-
*
|
|
576
|
+
* ```HTML
|
|
577
|
+
* <!-- somewhere inside of my-component-tpl.html -->
|
|
578
|
+
* <div [\@myAnimationTrigger]="myStatusExp">...</div>
|
|
579
|
+
* ```
|
|
642
580
|
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* is defined that matches the old/current state criteria then the associated animation will be
|
|
646
|
-
* triggered.
|
|
581
|
+
* All transitions are defined within an animation trigger,
|
|
582
|
+
* along with named states that the transitions change to and from.
|
|
647
583
|
*
|
|
648
584
|
* ```typescript
|
|
649
|
-
* // all transition/state changes are defined within an animation trigger
|
|
650
585
|
* trigger("myAnimationTrigger", [
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
* // a transition animation that will be kicked off when the state value
|
|
657
|
-
* // bound to "myAnimationTrigger" changes from "on" to "off"
|
|
658
|
-
* transition("on => off", animate(500)),
|
|
659
|
-
*
|
|
660
|
-
* // it is also possible to do run the same animation for both directions
|
|
661
|
-
* transition("on <=> off", animate(500)),
|
|
662
|
-
*
|
|
663
|
-
* // or to define multiple states pairs separated by commas
|
|
664
|
-
* transition("on => off, off => void", animate(500)),
|
|
665
|
-
*
|
|
666
|
-
* // this is a catch-all state change for when an element is inserted into
|
|
667
|
-
* // the page and the destination state is unknown
|
|
668
|
-
* transition("void => *", [
|
|
669
|
-
* style({ opacity: 0 }),
|
|
670
|
-
* animate(500)
|
|
671
|
-
* ]),
|
|
586
|
+
* // define states
|
|
587
|
+
* state("on", style({ background: "green" })),
|
|
588
|
+
* state("off", style({ background: "grey" })),
|
|
589
|
+
* ...]
|
|
590
|
+
* ```
|
|
672
591
|
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
592
|
+
* Note that when you call the `sequence()` function within a `{\@link animations/group group()}`
|
|
593
|
+
* or a `transition()` call, execution does not continue to the next instruction
|
|
594
|
+
* until each of the inner animation steps have completed.
|
|
675
595
|
*
|
|
676
|
-
*
|
|
677
|
-
* transition((fromState, toState) => {
|
|
678
|
-
* // when `true` then it will allow the animation below to be invoked
|
|
679
|
-
* return fromState == "off" && toState == "on";
|
|
680
|
-
* }, animate("1s 0s"))
|
|
681
|
-
* ])
|
|
682
|
-
* ```
|
|
596
|
+
* ### Syntax examples
|
|
683
597
|
*
|
|
684
|
-
* The
|
|
685
|
-
*
|
|
598
|
+
* The following examples define transitions between the two defined states (and default states),
|
|
599
|
+
* using various options:
|
|
686
600
|
*
|
|
687
|
-
* ```
|
|
688
|
-
*
|
|
689
|
-
*
|
|
601
|
+
* ```typescript
|
|
602
|
+
* // Transition occurs when the state value
|
|
603
|
+
* // bound to "myAnimationTrigger" changes from "on" to "off"
|
|
604
|
+
* transition("on => off", animate(500))
|
|
605
|
+
* // Run the same animation for both directions
|
|
606
|
+
* transition("on <=> off", animate(500))
|
|
607
|
+
* // Define multiple state-change pairs separated by commas
|
|
608
|
+
* transition("on => off, off => void", animate(500))
|
|
690
609
|
* ```
|
|
691
610
|
*
|
|
692
|
-
*
|
|
611
|
+
* ### Special values for state-change expressions
|
|
693
612
|
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* for the element to animate itself to the final state. This involves an automatic mix of
|
|
697
|
-
* adding/removing CSS styles so that the element will be in the exact state it should be for the
|
|
698
|
-
* applied state to be presented correctly.
|
|
613
|
+
* - Catch-all state change for when an element is inserted into the page and the
|
|
614
|
+
* destination state is unknown:
|
|
699
615
|
*
|
|
700
|
-
* ```
|
|
701
|
-
* // start off by hiding the element, but make sure that it animates properly to whatever state
|
|
702
|
-
* // is currently active for "myAnimationTrigger"
|
|
616
|
+
* ```typescript
|
|
703
617
|
* transition("void => *", [
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
618
|
+
* style({ opacity: 0 }),
|
|
619
|
+
* animate(500)
|
|
620
|
+
* ])
|
|
707
621
|
* ```
|
|
708
622
|
*
|
|
709
|
-
*
|
|
623
|
+
* - Capture a state change between any states:
|
|
710
624
|
*
|
|
711
|
-
*
|
|
712
|
-
* function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
|
|
713
|
-
* => void` state changes.
|
|
625
|
+
* `transition("* => *", animate("1s 0s"))`
|
|
714
626
|
*
|
|
715
|
-
*
|
|
627
|
+
* - Entry and exit transitions:
|
|
628
|
+
*
|
|
629
|
+
* ```typescript
|
|
716
630
|
* transition(":enter", [
|
|
717
631
|
* style({ opacity: 0 }),
|
|
718
632
|
* animate(500, style({ opacity: 1 }))
|
|
719
|
-
*
|
|
633
|
+
* ]),
|
|
720
634
|
* transition(":leave", [
|
|
721
635
|
* animate(500, style({ opacity: 0 }))
|
|
722
|
-
*
|
|
636
|
+
* ])
|
|
723
637
|
* ```
|
|
724
638
|
*
|
|
725
|
-
*
|
|
726
|
-
* if a trigger binding value is a boolean value then it can be matched using a transition
|
|
727
|
-
* expression that compares `true` and `false` or `1` and `0`.
|
|
639
|
+
* - Use `:increment` and `:decrement` to initiate transitions:
|
|
728
640
|
*
|
|
729
|
-
* ```
|
|
730
|
-
*
|
|
731
|
-
*
|
|
641
|
+
* ```typescript
|
|
642
|
+
* transition(":increment", group([
|
|
643
|
+
* query(':enter', [
|
|
644
|
+
* style({ left: '100%' }),
|
|
645
|
+
* animate('0.5s ease-out', style('*'))
|
|
646
|
+
* ]),
|
|
647
|
+
* query(':leave', [
|
|
648
|
+
* animate('0.5s ease-out', style({ left: '-100%' }))
|
|
649
|
+
* ])
|
|
650
|
+
* ]))
|
|
732
651
|
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
652
|
+
* transition(":decrement", group([
|
|
653
|
+
* query(':enter', [
|
|
654
|
+
* style({ left: '100%' }),
|
|
655
|
+
* animate('0.5s ease-out', style('*'))
|
|
656
|
+
* ]),
|
|
657
|
+
* query(':leave', [
|
|
658
|
+
* animate('0.5s ease-out', style({ left: '-100%' }))
|
|
659
|
+
* ])
|
|
660
|
+
* ]))
|
|
739
661
|
* ```
|
|
740
662
|
*
|
|
741
|
-
* ###
|
|
742
|
-
*
|
|
743
|
-
*
|
|
663
|
+
* ### State-change functions
|
|
664
|
+
*
|
|
665
|
+
* Here is an example of a `fromState` specified as a state-change function that invokes an
|
|
666
|
+
* animation when true:
|
|
744
667
|
*
|
|
668
|
+
* ```typescript
|
|
669
|
+
* transition((fromState, toState) =>
|
|
670
|
+
* {
|
|
671
|
+
* return fromState == "off" && toState == "on";
|
|
672
|
+
* },
|
|
673
|
+
* animate("1s 0s"))
|
|
745
674
|
* ```
|
|
746
|
-
* import {group, animate, query, transition, style, trigger} from '\@angular/animations';
|
|
747
|
-
* import {Component} from '\@angular/core';
|
|
748
675
|
*
|
|
749
|
-
*
|
|
750
|
-
* selector: 'banner-carousel-component',
|
|
751
|
-
* styles: [`
|
|
752
|
-
* .banner-container {
|
|
753
|
-
* position:relative;
|
|
754
|
-
* height:500px;
|
|
755
|
-
* overflow:hidden;
|
|
756
|
-
* }
|
|
757
|
-
* .banner-container > .banner {
|
|
758
|
-
* position:absolute;
|
|
759
|
-
* left:0;
|
|
760
|
-
* top:0;
|
|
761
|
-
* font-size:200px;
|
|
762
|
-
* line-height:500px;
|
|
763
|
-
* font-weight:bold;
|
|
764
|
-
* text-align:center;
|
|
765
|
-
* width:100%;
|
|
766
|
-
* }
|
|
767
|
-
* `],
|
|
768
|
-
* template: `
|
|
769
|
-
* <button (click)="previous()">Previous</button>
|
|
770
|
-
* <button (click)="next()">Next</button>
|
|
771
|
-
* <hr>
|
|
772
|
-
* <div [\@bannerAnimation]="selectedIndex" class="banner-container">
|
|
773
|
-
* <div class="banner" *ngFor="let banner of banners"> {{ banner }} </div>
|
|
774
|
-
* </div>
|
|
775
|
-
* `,
|
|
776
|
-
* animations: [
|
|
777
|
-
* trigger('bannerAnimation', [
|
|
778
|
-
* transition(":increment", group([
|
|
779
|
-
* query(':enter', [
|
|
780
|
-
* style({ left: '100%' }),
|
|
781
|
-
* animate('0.5s ease-out', style('*'))
|
|
782
|
-
* ]),
|
|
783
|
-
* query(':leave', [
|
|
784
|
-
* animate('0.5s ease-out', style({ left: '-100%' }))
|
|
785
|
-
* ])
|
|
786
|
-
* ])),
|
|
787
|
-
* transition(":decrement", group([
|
|
788
|
-
* query(':enter', [
|
|
789
|
-
* style({ left: '-100%' }),
|
|
790
|
-
* animate('0.5s ease-out', style('*'))
|
|
791
|
-
* ]),
|
|
792
|
-
* query(':leave', [
|
|
793
|
-
* animate('0.5s ease-out', style({ left: '100%' }))
|
|
794
|
-
* ])
|
|
795
|
-
* ]))
|
|
796
|
-
* ])
|
|
797
|
-
* ]
|
|
798
|
-
* })
|
|
799
|
-
* class BannerCarouselComponent {
|
|
800
|
-
* allBanners: string[] = ['1', '2', '3', '4'];
|
|
801
|
-
* selectedIndex: number = 0;
|
|
676
|
+
* ### Animating to the final state
|
|
802
677
|
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
678
|
+
* If the final step in a transition is a call to `animate()` that uses a timing value
|
|
679
|
+
* with no style data, that step is automatically considered the final animation arc,
|
|
680
|
+
* for the element to reach the final state. Angular automatically adds or removes
|
|
681
|
+
* CSS styles to ensure that the element is in the correct final state.
|
|
806
682
|
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
* }
|
|
683
|
+
* The following example defines a transition that starts by hiding the element,
|
|
684
|
+
* then makes sure that it animates properly to whatever state is currently active for trigger:
|
|
810
685
|
*
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
* }
|
|
814
|
-
*
|
|
686
|
+
* ```typescript
|
|
687
|
+
* transition("void => *", [
|
|
688
|
+
* style({ opacity: 0 }),
|
|
689
|
+
* animate(500)
|
|
690
|
+
* ])
|
|
691
|
+
* ```
|
|
692
|
+
* ### Boolean value matching
|
|
693
|
+
* If a trigger binding value is a Boolean, it can be matched using a transition expression
|
|
694
|
+
* that compares true and false or 1 and 0. For example:
|
|
695
|
+
*
|
|
696
|
+
* ```
|
|
697
|
+
* // in the template
|
|
698
|
+
* <div [\@openClose]="open ? true : false">...</div>
|
|
699
|
+
* // in the component metadata
|
|
700
|
+
* trigger('openClose', [
|
|
701
|
+
* state('true', style({ height: '*' })),
|
|
702
|
+
* state('false', style({ height: '0px' })),
|
|
703
|
+
* transition('false <=> true', animate(500))
|
|
704
|
+
* ])
|
|
815
705
|
* ```
|
|
816
706
|
*
|
|
817
|
-
* {
|
|
707
|
+
* @param {?} stateChangeExpr A Boolean expression or function that compares the previous and current
|
|
708
|
+
* animation states, and returns true if this transition should occur. Note that "true" and "false"
|
|
709
|
+
* match 1 and 0, respectively. An expression is evaluated each time a state change occurs in the
|
|
710
|
+
* animation trigger element.
|
|
711
|
+
* The animation steps run when the expression evaluates to true.
|
|
712
|
+
*
|
|
713
|
+
* - A state-change string takes the form "state1 => state2", where each side is a defined animation
|
|
714
|
+
* state, or an asterix (*) to refer to a dynamic start or end state.
|
|
715
|
+
* - The expression string can contain multiple comma-separated statements;
|
|
716
|
+
* for example "state1 => state2, state3 => state4".
|
|
717
|
+
* - Special values `:enter` and `:leave` initiate a transition on the entry and exit states,
|
|
718
|
+
* equivalent to "void => *" and "* => void".
|
|
719
|
+
* - Special values `:increment` and `:decrement` initiate a transition when a numeric value has
|
|
720
|
+
* increased or decreased in value.
|
|
721
|
+
* - A function is executed each time a state change occurs in the animation trigger element.
|
|
722
|
+
* The animation steps run when the function returns true.
|
|
723
|
+
*
|
|
724
|
+
* @param {?} steps One or more animation objects, as returned by the `animate()` or
|
|
725
|
+
* `sequence()` function, that form a transformation from one state to another.
|
|
726
|
+
* A sequence is used by default when you pass an array.
|
|
727
|
+
* @param {?=} options An options object that can contain a delay value for the start of the animation,
|
|
728
|
+
* and additional developer-defined parameters. Provided values for additional parameters are used
|
|
729
|
+
* as defaults, and override values can be passed to the caller on invocation.
|
|
730
|
+
* @return {?} An object that encapsulates the transition data.
|
|
818
731
|
*
|
|
819
|
-
* \@experimental Animation support is experimental.
|
|
820
|
-
* @param {?} stateChangeExpr
|
|
821
|
-
* @param {?} steps
|
|
822
|
-
* @param {?=} options
|
|
823
|
-
* @return {?}
|
|
824
732
|
*/
|
|
825
733
|
function transition(stateChangeExpr, steps, options = null) {
|
|
826
734
|
return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps, options };
|
|
827
735
|
}
|
|
828
736
|
/**
|
|
829
|
-
*
|
|
830
|
-
*
|
|
737
|
+
* Produces a reusable animation that can be invoked in another animation or sequence,
|
|
738
|
+
* by calling the `useAnimation()` function.
|
|
831
739
|
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
740
|
+
* \@usageNotes
|
|
741
|
+
* The following example defines a reusable animation, providing some default parameter
|
|
742
|
+
* values.
|
|
835
743
|
*
|
|
836
|
-
* ```
|
|
744
|
+
* ```typescript
|
|
837
745
|
* var fadeAnimation = animation([
|
|
838
746
|
* style({ opacity: '{{ start }}' }),
|
|
839
747
|
* animate('{{ time }}',
|
|
840
|
-
*
|
|
841
|
-
*
|
|
748
|
+
* style({ opacity: '{{ end }}'}))
|
|
749
|
+
* ],
|
|
750
|
+
* { params: { time: '1000ms', start: 0, end: 1 }});
|
|
842
751
|
* ```
|
|
843
752
|
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
* directly. If any of the passed in parameter values are missing then the default values will be
|
|
847
|
-
* used.
|
|
753
|
+
* The following invokes the defined animation with a call to `useAnimation()`,
|
|
754
|
+
* passing in override parameter values.
|
|
848
755
|
*
|
|
849
|
-
* ```
|
|
756
|
+
* ```js
|
|
850
757
|
* useAnimation(fadeAnimation, {
|
|
851
758
|
* params: {
|
|
852
759
|
* time: '2s',
|
|
@@ -856,145 +763,67 @@ function transition(stateChangeExpr, steps, options = null) {
|
|
|
856
763
|
* })
|
|
857
764
|
* ```
|
|
858
765
|
*
|
|
859
|
-
* If
|
|
766
|
+
* If any of the passed-in parameter values are missing from this call,
|
|
767
|
+
* the default values are used. If one or more parameter values are missing before a step is
|
|
768
|
+
* animated, `useAnimation()` throws an error.
|
|
769
|
+
* @param {?} steps One or more animation objects, as returned by the `animate()`
|
|
770
|
+
* or `sequence()` function, that form a transformation from one state to another.
|
|
771
|
+
* A sequence is used by default when you pass an array.
|
|
772
|
+
* @param {?=} options An options object that can contain a delay value for the start of the
|
|
773
|
+
* animation, and additional developer-defined parameters.
|
|
774
|
+
* Provided values for additional parameters are used as defaults,
|
|
775
|
+
* and override values can be passed to the caller on invocation.
|
|
776
|
+
* @return {?} An object that encapsulates the animation data.
|
|
860
777
|
*
|
|
861
|
-
* \@experimental Animation support is experimental.
|
|
862
|
-
* @param {?} steps
|
|
863
|
-
* @param {?=} options
|
|
864
|
-
* @return {?}
|
|
865
778
|
*/
|
|
866
779
|
function animation(steps, options = null) {
|
|
867
780
|
return { type: 8 /* Reference */, animation: steps, options };
|
|
868
781
|
}
|
|
869
782
|
/**
|
|
870
|
-
*
|
|
871
|
-
* animation DSL language. It works by allowing a queried element to execute its own
|
|
872
|
-
* animation within the animation sequence.
|
|
783
|
+
* Executes a queried inner animation element within an animation sequence.
|
|
873
784
|
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
785
|
+
* \@usageNotes
|
|
786
|
+
* Each time an animation is triggered in Angular, the parent animation
|
|
787
|
+
* has priority and any child animations are blocked. In order
|
|
876
788
|
* for a child animation to run, the parent animation must query each of the elements
|
|
877
|
-
* containing child animations and
|
|
878
|
-
*
|
|
879
|
-
* The example HTML code below shows both parent and child elements that have animation
|
|
880
|
-
* triggers that will execute at the same time.
|
|
881
|
-
*
|
|
882
|
-
* ```html
|
|
883
|
-
* <!-- parent-child.component.html -->
|
|
884
|
-
* <button (click)="exp =! exp">Toggle</button>
|
|
885
|
-
* <hr>
|
|
886
|
-
*
|
|
887
|
-
* <div [\@parentAnimation]="exp">
|
|
888
|
-
* <header>Hello</header>
|
|
889
|
-
* <div [\@childAnimation]="exp">
|
|
890
|
-
* one
|
|
891
|
-
* </div>
|
|
892
|
-
* <div [\@childAnimation]="exp">
|
|
893
|
-
* two
|
|
894
|
-
* </div>
|
|
895
|
-
* <div [\@childAnimation]="exp">
|
|
896
|
-
* three
|
|
897
|
-
* </div>
|
|
898
|
-
* </div>
|
|
899
|
-
* ```
|
|
900
|
-
*
|
|
901
|
-
* Now when the `exp` value changes to true, only the `parentAnimation` animation will animate
|
|
902
|
-
* because it has priority. However, using `query` and `animateChild` each of the inner animations
|
|
903
|
-
* can also fire:
|
|
904
|
-
*
|
|
905
|
-
* ```ts
|
|
906
|
-
* // parent-child.component.ts
|
|
907
|
-
* import {trigger, transition, animate, style, query, animateChild} from '\@angular/animations';
|
|
908
|
-
* \@Component({
|
|
909
|
-
* selector: 'parent-child-component',
|
|
910
|
-
* animations: [
|
|
911
|
-
* trigger('parentAnimation', [
|
|
912
|
-
* transition('false => true', [
|
|
913
|
-
* query('header', [
|
|
914
|
-
* style({ opacity: 0 }),
|
|
915
|
-
* animate(500, style({ opacity: 1 }))
|
|
916
|
-
* ]),
|
|
917
|
-
* query('\@childAnimation', [
|
|
918
|
-
* animateChild()
|
|
919
|
-
* ])
|
|
920
|
-
* ])
|
|
921
|
-
* ]),
|
|
922
|
-
* trigger('childAnimation', [
|
|
923
|
-
* transition('false => true', [
|
|
924
|
-
* style({ opacity: 0 }),
|
|
925
|
-
* animate(500, style({ opacity: 1 }))
|
|
926
|
-
* ])
|
|
927
|
-
* ])
|
|
928
|
-
* ]
|
|
929
|
-
* })
|
|
930
|
-
* class ParentChildCmp {
|
|
931
|
-
* exp: boolean = false;
|
|
932
|
-
* }
|
|
933
|
-
* ```
|
|
934
|
-
*
|
|
935
|
-
* In the animation code above, when the `parentAnimation` transition kicks off it first queries to
|
|
936
|
-
* find the header element and fades it in. It then finds each of the sub elements that contain the
|
|
937
|
-
* `\@childAnimation` trigger and then allows for their animations to fire.
|
|
789
|
+
* containing child animations, and run them using this function.
|
|
938
790
|
*
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
944
|
-
*
|
|
945
|
-
* ```
|
|
791
|
+
* Note that this feature designed to be used with `query()` and it will only work
|
|
792
|
+
* with animations that are assigned using the Angular animation library. CSS keyframes
|
|
793
|
+
* and transitions are not handled by this API.
|
|
794
|
+
* @param {?=} options An options object that can contain a delay value for the start of the
|
|
795
|
+
* animation, and additional override values for developer-defined parameters.
|
|
796
|
+
* @return {?} An object that encapsulates the child animation data.
|
|
946
797
|
*
|
|
947
|
-
* Now each of the sub animations start off with respect to the `100ms` staggering step.
|
|
948
|
-
*
|
|
949
|
-
* ## The first frame of child animations
|
|
950
|
-
* When sub animations are executed using `animateChild` the animation engine will always apply the
|
|
951
|
-
* first frame of every sub animation immediately at the start of the animation sequence. This way
|
|
952
|
-
* the parent animation does not need to set any initial styling data on the sub elements before the
|
|
953
|
-
* sub animations kick off.
|
|
954
|
-
*
|
|
955
|
-
* In the example above the first frame of the `childAnimation`'s `false => true` transition
|
|
956
|
-
* consists of a style of `opacity: 0`. This is applied immediately when the `parentAnimation`
|
|
957
|
-
* animation transition sequence starts. Only then when the `\@childAnimation` is queried and called
|
|
958
|
-
* with `animateChild` will it then animate to its destination of `opacity: 1`.
|
|
959
|
-
*
|
|
960
|
-
* Note that this feature designed to be used alongside {\@link query query()} and it will only work
|
|
961
|
-
* with animations that are assigned using the Angular animation DSL (this means that CSS keyframes
|
|
962
|
-
* and transitions are not handled by this API).
|
|
963
|
-
*
|
|
964
|
-
* \@experimental Animation support is experimental.
|
|
965
|
-
* @param {?=} options
|
|
966
|
-
* @return {?}
|
|
967
798
|
*/
|
|
968
799
|
function animateChild(options = null) {
|
|
969
800
|
return { type: 9 /* AnimateChild */, options };
|
|
970
801
|
}
|
|
971
802
|
/**
|
|
972
|
-
*
|
|
973
|
-
* animation DSL language. It is used to kick off a reusable animation that is created using {\@link
|
|
974
|
-
* animation animation()}.
|
|
803
|
+
* Starts a reusable animation that is created using the `animation()` function.
|
|
975
804
|
*
|
|
976
|
-
*
|
|
977
|
-
* @param {
|
|
978
|
-
*
|
|
979
|
-
* @return {?}
|
|
805
|
+
* @param {?} animation The reusable animation to start.
|
|
806
|
+
* @param {?=} options An options object that can contain a delay value for the start of
|
|
807
|
+
* the animation, and additional override values for developer-defined parameters.
|
|
808
|
+
* @return {?} An object that contains the animation parameters.
|
|
980
809
|
*/
|
|
981
810
|
function useAnimation(animation, options = null) {
|
|
982
811
|
return { type: 10 /* AnimateRef */, animation, options };
|
|
983
812
|
}
|
|
984
813
|
/**
|
|
985
|
-
*
|
|
986
|
-
*
|
|
814
|
+
* Finds one or more inner elements within the current element that is
|
|
815
|
+
* being animated within a sequence. Use with `animateChild()`.
|
|
987
816
|
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
* to the queried element (by default, an array is provided, then this will be
|
|
991
|
-
* treated as an animation sequence).
|
|
817
|
+
* \@usageNotes
|
|
818
|
+
* Tokens can be merged into a combined query selector string. For example:
|
|
992
819
|
*
|
|
993
|
-
*
|
|
820
|
+
* ```typescript
|
|
821
|
+
* query(':self, .record:enter, .record:leave, \@subTrigger', [...])
|
|
822
|
+
* ```
|
|
994
823
|
*
|
|
995
|
-
* query()
|
|
996
|
-
* `element.querySelectorAll`.
|
|
997
|
-
*
|
|
824
|
+
* The `query()` function collects multiple elements and works internally by using
|
|
825
|
+
* `element.querySelectorAll`. Use the `limit` field of an options object to limit
|
|
826
|
+
* the total number of items to be collected. For example:
|
|
998
827
|
*
|
|
999
828
|
* ```js
|
|
1000
829
|
* query('div', [
|
|
@@ -1003,8 +832,8 @@ function useAnimation(animation, options = null) {
|
|
|
1003
832
|
* ], { limit: 1 })
|
|
1004
833
|
* ```
|
|
1005
834
|
*
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
835
|
+
* By default, throws an error when zero items are found. Set the
|
|
836
|
+
* `optional` flag to ignore this error. For example:
|
|
1008
837
|
*
|
|
1009
838
|
* ```js
|
|
1010
839
|
* query('.some-element-that-may-not-be-there', [
|
|
@@ -1013,31 +842,12 @@ function useAnimation(animation, options = null) {
|
|
|
1013
842
|
* ], { optional: true })
|
|
1014
843
|
* ```
|
|
1015
844
|
*
|
|
1016
|
-
* ###
|
|
1017
|
-
*
|
|
1018
|
-
* The selector value within a query can collect elements that contain angular-specific
|
|
1019
|
-
* characteristics
|
|
1020
|
-
* using special pseudo-selectors tokens.
|
|
1021
|
-
*
|
|
1022
|
-
* These include:
|
|
1023
|
-
*
|
|
1024
|
-
* - Querying for newly inserted/removed elements using `query(":enter")`/`query(":leave")`
|
|
1025
|
-
* - Querying all currently animating elements using `query(":animating")`
|
|
1026
|
-
* - Querying elements that contain an animation trigger using `query("\@triggerName")`
|
|
1027
|
-
* - Querying all elements that contain an animation triggers using `query("\@*")`
|
|
1028
|
-
* - Including the current element into the animation sequence using `query(":self")`
|
|
845
|
+
* ### Usage Example
|
|
1029
846
|
*
|
|
847
|
+
* The following example queries for inner elements and animates them
|
|
848
|
+
* individually using `animateChild()`.
|
|
1030
849
|
*
|
|
1031
|
-
*
|
|
1032
|
-
* string:
|
|
1033
|
-
*
|
|
1034
|
-
* ```
|
|
1035
|
-
* query(':self, .record:enter, .record:leave, \@subTrigger', [...])
|
|
1036
|
-
* ```
|
|
1037
|
-
*
|
|
1038
|
-
* ### Demo
|
|
1039
|
-
*
|
|
1040
|
-
* ```
|
|
850
|
+
* ```typescript
|
|
1041
851
|
* \@Component({
|
|
1042
852
|
* selector: 'inner',
|
|
1043
853
|
* template: `
|
|
@@ -1070,27 +880,38 @@ function useAnimation(animation, options = null) {
|
|
|
1070
880
|
* }
|
|
1071
881
|
* }
|
|
1072
882
|
* ```
|
|
883
|
+
* @param {?} selector The element to query, or a set of elements that contain Angular-specific
|
|
884
|
+
* characteristics, specified with one or more of the following tokens.
|
|
885
|
+
* - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements.
|
|
886
|
+
* - `query(":animating")` : Query all currently animating elements.
|
|
887
|
+
* - `query("\@triggerName")` : Query elements that contain an animation trigger.
|
|
888
|
+
* - `query("\@*")` : Query all elements that contain an animation triggers.
|
|
889
|
+
* - `query(":self")` : Include the current element into the animation sequence.
|
|
890
|
+
*
|
|
891
|
+
* @param {?} animation One or more animation steps to apply to the queried element or elements.
|
|
892
|
+
* An array is treated as an animation sequence.
|
|
893
|
+
* @param {?=} options An options object. Use the 'limit' field to limit the total number of
|
|
894
|
+
* items to collect.
|
|
895
|
+
* @return {?} An object that encapsulates the query data.
|
|
1073
896
|
*
|
|
1074
|
-
* \@experimental Animation support is experimental.
|
|
1075
|
-
* @param {?} selector
|
|
1076
|
-
* @param {?} animation
|
|
1077
|
-
* @param {?=} options
|
|
1078
|
-
* @return {?}
|
|
1079
897
|
*/
|
|
1080
898
|
function query(selector, animation, options = null) {
|
|
1081
899
|
return { type: 11 /* Query */, selector, animation, options };
|
|
1082
900
|
}
|
|
1083
901
|
/**
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
* and works by issuing a timing gap between after each queried item is animated.
|
|
1087
|
-
*
|
|
1088
|
-
* ### Usage
|
|
902
|
+
* Use within an animation `query()` call to issue a timing gap after
|
|
903
|
+
* each queried item is animated.
|
|
1089
904
|
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
905
|
+
* \@usageNotes
|
|
906
|
+
* In the following example, a container element wraps a list of items stamped out
|
|
907
|
+
* by an `ngFor`. The container element contains an animation trigger that will later be set
|
|
1092
908
|
* to query for each of the inner items.
|
|
1093
909
|
*
|
|
910
|
+
* Each time items are added, the opacity fade-in animation runs,
|
|
911
|
+
* and each removed item is faded out.
|
|
912
|
+
* When either of these animations occur, the stagger effect is
|
|
913
|
+
* applied after each item's animation is started.
|
|
914
|
+
*
|
|
1094
915
|
* ```html
|
|
1095
916
|
* <!-- list.component.html -->
|
|
1096
917
|
* <button (click)="toggle()">Show / Hide Items</button>
|
|
@@ -1102,15 +923,15 @@ function query(selector, animation, options = null) {
|
|
|
1102
923
|
* </div>
|
|
1103
924
|
* ```
|
|
1104
925
|
*
|
|
1105
|
-
*
|
|
926
|
+
* Here is the component code:
|
|
1106
927
|
*
|
|
1107
|
-
* ```
|
|
928
|
+
* ```typescript
|
|
1108
929
|
* import {trigger, transition, style, animate, query, stagger} from '\@angular/animations';
|
|
1109
930
|
* \@Component({
|
|
1110
931
|
* templateUrl: 'list.component.html',
|
|
1111
932
|
* animations: [
|
|
1112
933
|
* trigger('listAnimation', [
|
|
1113
|
-
*
|
|
934
|
+
* ...
|
|
1114
935
|
* ])
|
|
1115
936
|
* ]
|
|
1116
937
|
* })
|
|
@@ -1127,13 +948,13 @@ function query(selector, animation, options = null) {
|
|
|
1127
948
|
*
|
|
1128
949
|
* toggle() {
|
|
1129
950
|
* this.items.length ? this.hideItems() : this.showItems();
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
951
|
+
* }
|
|
952
|
+
* }
|
|
1132
953
|
* ```
|
|
1133
954
|
*
|
|
1134
|
-
*
|
|
955
|
+
* Here is the animation trigger code:
|
|
1135
956
|
*
|
|
1136
|
-
* ```
|
|
957
|
+
* ```typescript
|
|
1137
958
|
* trigger('listAnimation', [
|
|
1138
959
|
* transition('* => *', [ // each time the binding value changes
|
|
1139
960
|
* query(':leave', [
|
|
@@ -1150,16 +971,10 @@ function query(selector, animation, options = null) {
|
|
|
1150
971
|
* ])
|
|
1151
972
|
* ])
|
|
1152
973
|
* ```
|
|
974
|
+
* @param {?} timings A delay value.
|
|
975
|
+
* @param {?} animation One ore more animation steps.
|
|
976
|
+
* @return {?} An object that encapsulates the stagger data.
|
|
1153
977
|
*
|
|
1154
|
-
* Now each time the items are added/removed then either the opacity
|
|
1155
|
-
* fade-in animation will run or each removed item will be faded out.
|
|
1156
|
-
* When either of these animations occur then a stagger effect will be
|
|
1157
|
-
* applied after each item's animation is started.
|
|
1158
|
-
*
|
|
1159
|
-
* \@experimental Animation support is experimental.
|
|
1160
|
-
* @param {?} timings
|
|
1161
|
-
* @param {?} animation
|
|
1162
|
-
* @return {?}
|
|
1163
978
|
*/
|
|
1164
979
|
function stagger(timings, animation) {
|
|
1165
980
|
return { type: 12 /* Stagger */, timings, animation };
|