feat(animations): support styling of the default animation state

It is now possible to set a fallback state that will apply its
styling when the destination state is not detected.

```ts
state("*", style({ ... }))
```

Closes #9013
This commit is contained in:
Matias Niemelä
2016-06-03 17:52:33 -07:00
parent c3d2459a4e
commit 36d25f2a07
9 changed files with 121 additions and 11 deletions

View File

@ -1,19 +1,21 @@
import {Component, trigger, state, animate, transition, style} from '@angular/core';
import {AUTO_STYLE, Component, trigger, state, animate, transition, style} from '@angular/core';
@Component({
selector: "animate-cmp",
animations: [
trigger('openClose', [
state("*", style({ height: AUTO_STYLE, color: 'black', borderColor: 'black' })),
state('closed, void',
style({ height:"0px", color: "maroon", borderColor: "maroon" })),
state('open',
style({ height:"*", borderColor:"green", color:"green" })),
style({ height: AUTO_STYLE, borderColor:"green", color:"green" })),
transition("* => *", animate(500))
])
],
template: `
<button (click)="setAsOpen()">Open</button>
<button (click)="setAsClosed()">Closed</button>
<button (click)="setAsSomethingElse()">Something Else</button>
<hr />
<div @openClose="stateExpression">
Look at this box
@ -25,6 +27,9 @@ export class AnimateCmp {
constructor() {
this.setAsClosed();
}
setAsSomethingElse() {
this.stateExpression = 'something';
}
setAsOpen() {
this.stateExpression = 'open';
}