| 
									
										
										
										
											2016-11-10 11:53:50 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2016-11-10 11:53:50 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-09 15:54:59 -08:00
										 |  |  | import {animate, state, style, transition, trigger} from '@angular/animations'; | 
					
						
							|  |  |  | import {Component} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-11-10 11:53:50 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'animation-app', | 
					
						
							|  |  |  |   styles: [`
 | 
					
						
							|  |  |  |     .box { | 
					
						
							|  |  |  |       border:10px solid black; | 
					
						
							|  |  |  |       text-align:center; | 
					
						
							|  |  |  |       overflow:hidden; | 
					
						
							|  |  |  |       background:red; | 
					
						
							|  |  |  |       color:white; | 
					
						
							|  |  |  |       font-size:100px; | 
					
						
							|  |  |  |       line-height:200px; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   `],
 | 
					
						
							|  |  |  |   animations: [trigger( | 
					
						
							|  |  |  |       'animate', | 
					
						
							|  |  |  |       [ | 
					
						
							|  |  |  |         state('off', style({width: '0px'})), state('on', style({width: '750px'})), | 
					
						
							|  |  |  |         transition('off <=> on', animate(500)) | 
					
						
							|  |  |  |       ])], | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <button (click)="animate=!animate"> | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |       Start Animation | 
					
						
							| 
									
										
										
										
											2016-11-10 11:53:50 -08:00
										 |  |  |     </button> | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-10 11:53:50 -08:00
										 |  |  |     <div class="box" [@animate]="animate ? 'on' : 'off'"> | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |       ... | 
					
						
							| 
									
										
										
										
											2016-11-10 11:53:50 -08:00
										 |  |  |     </div> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class AnimationCmp { | 
					
						
							|  |  |  |   animate = false; | 
					
						
							|  |  |  | } |