| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | import {AUTO_STYLE, Component, animate, state, style, transition, trigger} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-05-31 09:15:17 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   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: AUTO_STYLE, borderColor: 'green', color: 'green'})), | 
					
						
							|  |  |  |         transition('* => *', animate(500)) | 
					
						
							|  |  |  |       ])], | 
					
						
							| 
									
										
										
										
											2016-05-31 09:15:17 -07:00
										 |  |  |   template: `
 | 
					
						
							|  |  |  |     <button (click)="setAsOpen()">Open</button> | 
					
						
							|  |  |  |     <button (click)="setAsClosed()">Closed</button> | 
					
						
							| 
									
										
										
										
											2016-06-03 17:52:33 -07:00
										 |  |  |     <button (click)="setAsSomethingElse()">Something Else</button> | 
					
						
							| 
									
										
										
										
											2016-05-31 09:15:17 -07:00
										 |  |  |     <hr /> | 
					
						
							|  |  |  |     <div @openClose="stateExpression"> | 
					
						
							|  |  |  |       Look at this box | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class AnimateCmp { | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   stateExpression: string; | 
					
						
							|  |  |  |   constructor() { this.setAsClosed(); } | 
					
						
							|  |  |  |   setAsSomethingElse() { this.stateExpression = 'something'; } | 
					
						
							|  |  |  |   setAsOpen() { this.stateExpression = 'open'; } | 
					
						
							|  |  |  |   setAsClosed() { this.stateExpression = 'closed'; } | 
					
						
							| 
									
										
										
										
											2016-05-31 09:15:17 -07:00
										 |  |  | } |