fix(animations): properly support boolean-based transitions and state changes (#19279)

Closes #9396
Closes #12337

PR Close #19279
This commit is contained in:
Matias Niemelä
2017-09-19 14:22:22 -07:00
committed by Chuck Jazdzewski
parent fdfa31798b
commit a8920eb774
4 changed files with 146 additions and 18 deletions

View File

@ -257,6 +257,11 @@ export interface AnimationStaggerMetadata extends AnimationMetadata {
the
* trigger is bound to (in the form of `[@triggerName]="expression"`.
*
* Animation trigger bindings strigify values and then match the previous and current values against
* any linked transitions. If a boolean value is provided into the trigger binding then it will both
* be represented as `1` or `true` and `0` or `false` for a true and false boolean values
* respectively.
*
* ### Usage
*
* `trigger` will create an animation trigger reference based on the provided `name` value. The
@ -734,6 +739,22 @@ export function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSe
* ])
* ```
*
* ### Boolean values
* if a trigger binding value is a boolean value then it can be matched using a transition
* expression that compares `true` and `false` or `1` and `0`.
*
* ```
* // 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))
* ])
* ```
*
* ### Using :increment and :decrement
* In addition to the :enter and :leave transition aliases, the :increment and :decrement aliases
* can be used to kick off a transition when a numeric value has increased or decreased in value.