Loading...
Loading...
ALWAYS use when working with Angular Animations, UI transitions, enter/leave animations, or animation triggers in Angular applications.
npx skill4agent add oguzhan18/angular-ecosystem-skills angular-animationsanimateEnteranimateLeave:enter:leave:enter:leaveanimateEnteranimateLeaveimport { provideAnimations } from '@angular/platform-browser/animations';
export const appConfig: ApplicationConfig = {
providers: [
provideAnimations()
]
};import { trigger, state, style, transition, animate } from '@angular/animations';
@Component({
animations: [
trigger('fadeInOut', [
state('hidden', style({ opacity: 0 })),
state('visible', style({ opacity: 1 })),
transition('hidden <=> visible', animate(500))
])
]
})
export class FadeComponent {
isVisible = signal(false);
}@Component({
animations: [
trigger('slideIn', [
transition(':enter', [
style({ transform: 'translateX(-100%)' }),
animate('300ms ease-in', style({ transform: 'translateX(0%)' }))
]),
transition(':leave', [
animate('300ms ease-out', style({ transform: 'translateX(-100%)' }))
])
])
]
})
export class SlideComponent {}trigger('expand', [
transition('* => expanded', [
style({ height: '*' }),
animate('300ms ease-out', style({ height: '200px' }))
]),
transition('expanded => *', [
animate('300ms ease-in', style({ height: '*' }))
])
])trigger('listAnimation', [
transition('* => *', [
query(':enter', [
style({ opacity: 0 }),
stagger(100, [
animate('300ms', style({ opacity: 1 }))
])
], { optional: true })
])
])@Component({
template: `
<div [@fade]="state"
(@fade.start)="onAnimationStart()"
(@fade.done)="onAnimationDone()">
</div>
`
})
export class AnimComponent {
onAnimationStart() { console.log('Start'); }
onAnimationDone() { console.log('Done'); }
}// animations.ts
export const fadeAnimation = trigger('fade', [
transition(':enter', [
style({ opacity: 0 }),
animate('300ms', style({ opacity: 1 }))
]),
transition(':leave', [
animate('300ms', style({ opacity: 0 }))
])
]);@Component({
animations: [
trigger('expanded', [
transition(':expanded', [
animate('300ms cubic-bezier(0.4, 0, 0.2, 1)')
])
])
]
})
export class ExpandComponent {}// Prefer transform and opacity
transition('* => *', [
animate('200ms', style({
transform: 'translateX(10px)',
opacity: 0.5
}))
])
// Avoid expensive properties
// ❌ Don't animate: width, height, margin, top
// ✅ Do animate: transform, opacity@Component({
animations: [
trigger('slide', [
transition('* => *', [
style({ '@.disabled': '' }), // Disable for reduced motion
animate('300ms')
])
])
]
})