@@ -115,7 +115,9 @@ export interface AnimationStateMetadata extends AnimationMetadata {
115
115
* @experimental Animation support is experimental.
116
116
*/
117
117
export interface AnimationTransitionMetadata extends AnimationMetadata {
118
- expr : string | ( ( fromState : string , toState : string ) => boolean ) ;
118
+ expr : string |
119
+ ( ( fromState : string , toState : string , element ?: any ,
120
+ params ?: { [ key : string ] : any } ) => boolean ) ;
119
121
animation : AnimationMetadata | AnimationMetadata [ ] ;
120
122
options : AnimationOptions | null ;
121
123
}
@@ -294,6 +296,38 @@ export interface AnimationStaggerMetadata extends AnimationMetadata {
294
296
* <div [@myAnimationTrigger]="myStatusExp">...</div>
295
297
* ```
296
298
*
299
+ * ### Using an inline function
300
+ * The `transition` animation method also supports reading an inline function which can decide
301
+ * if its associated animation should be run.
302
+ *
303
+ * ```
304
+ * // this method will be run each time the `myAnimationTrigger`
305
+ * // trigger value changes...
306
+ * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
307
+ string]: any}): boolean {
308
+ * // notice that `element` and `params` are also available here
309
+ * return toState == 'yes-please-animate';
310
+ * }
311
+ *
312
+ * @Component ({
313
+ * selector: 'my-component',
314
+ * templateUrl: 'my-component-tpl.html',
315
+ * animations: [
316
+ * trigger('myAnimationTrigger', [
317
+ * transition(myInlineMatcherFn, [
318
+ * // the animation sequence code
319
+ * ]),
320
+ * ])
321
+ * ]
322
+ * })
323
+ * class MyComponent {
324
+ * myStatusExp = "yes-please-animate";
325
+ * }
326
+ * ```
327
+ *
328
+ * The inline method will be run each time the trigger
329
+ * value changes
330
+ *
297
331
* ## Disable Animations
298
332
* A special animation control binding called `@.disabled` can be placed on an element which will
299
333
then disable animations for any inner animation triggers situated within the element as well as
@@ -844,7 +878,8 @@ export function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSe
844
878
* @experimental Animation support is experimental.
845
879
*/
846
880
export function transition (
847
- stateChangeExpr : string | ( ( fromState : string , toState : string ) => boolean ) ,
881
+ stateChangeExpr : string | ( ( fromState : string , toState : string , element ?: any ,
882
+ params ?: { [ key : string ] : any } ) => boolean ) ,
848
883
steps : AnimationMetadata | AnimationMetadata [ ] ,
849
884
options : AnimationOptions | null = null ) : AnimationTransitionMetadata {
850
885
return { type : AnimationMetadataType . Transition , expr : stateChangeExpr , animation : steps , options} ;
0 commit comments