Last active
July 2, 2020 04:51
-
-
Save allenhwkim/686481268ca76c311f44cbd8ecce3a43 to your computer and use it in GitHub Desktop.
Collection of Angular animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { trigger, transition, style, animate, query, stagger } from '@angular/animations'; | |
| export const fadeAnimation = trigger('fadeAnimation', [ | |
| transition(':enter', [ | |
| style({ opacity: 0 }), animate('300ms', style({ opacity: 1 }))] | |
| ), | |
| transition(':leave', | |
| [style({ opacity: 1 }), animate('300ms', style({ opacity: 0 }))] | |
| ) | |
| ]); | |
| export const listAnimation = trigger('listAnimation', [ | |
| transition('* <=> *', [ | |
| query(':enter', | |
| [style({ opacity: 0 }), stagger('60ms', animate('600ms ease-out', style({ opacity: 1 })))], | |
| { optional: true } | |
| ), | |
| query(':leave', | |
| animate('300ms', style({ opacity: 0 })), | |
| { optional: true} | |
| ) | |
| ]) | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <b @fadeAnimation *ngIf="show">fade animation</b> | |
| <ul [@listAnimation]="items.length" class="items"> | |
| <li *ngFor="let item of items" class="item">{{item}}</li> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| import { fadeAnimation, listAnimation} from './app.animations'; | |
| @Component({ | |
| selector: 'my-app', | |
| templateUrl: './app.component.html', | |
| styleUrls: [ './app.component.css' ], | |
| animations: [fadeAnimation, listAnimation] | |
| }) | |
| export class AppComponent { | |
| items = [...this.itemsOrg, ...this.itemsOrg]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @NgModule({ | |
| imports: [ BrowserModule, FormsModule, BrowserAnimationsModule ], | |
| declarations: [ AppComponent, HelloComponent ], | |
| bootstrap: [ AppComponent ] | |
| }) | |
| export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment