Last active
September 21, 2018 20:58
-
-
Save McQuinTrix/3bd041a4ffefc53633d38d927c782db7 to your computer and use it in GitHub Desktop.
Making Animations in Angular Reusable
This file contains 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 {animate, animateChild, query, stagger, style, transition, trigger} from "@angular/animations"; | |
export class Animations { | |
public static fadeIn = trigger('fadeIn', [ | |
transition(':enter', [ | |
style({ opacity: '0', marginTop: '10px'}), | |
animate('.2s ease-in', style({ opacity: '1', marginTop: '0px' })), | |
]), | |
]); | |
public static stagger = trigger('stagger', [ | |
transition(':enter', [ | |
query(':enter', stagger('.2s', [animateChild()]),{ optional: true }) | |
]) | |
]) | |
} | |
//Using in Component File | |
// | |
//import {Animations} from "../../../../shared/animations/basic-animations"; | |
// | |
//@Component({ | |
// selector: 'app-component', | |
// providers: [], | |
// templateUrl: './app.component.html', | |
// animations: [ | |
// Animations.fadeIn, | |
// Animations.stagger | |
// ], | |
//}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment