import { Component, ElementRef, ViewChild } from '@angular/core'; import { CommonModule } from '@angular/common'; import { UiAnimationsService, AnimateDirective } from 'ui-animations'; @Component({ selector: 'app-animations-demo', standalone: true, imports: [CommonModule, AnimateDirective], template: `

UI Animations Demo

Entrance Animations

Fade In

Basic fade in animation

Fade In Up

Fade in with upward movement

Slide In Up

Slide in from bottom

Zoom In

Scale up animation

Emphasis Animations

Click buttons above to animate me!

Animation Directive Examples

Hover to Animate

Uses directive with hover trigger

Click to Animate

Uses directive with click trigger

Animation Service Examples

Animation Service Target
`, styles: [` .animations-demo { padding: 2rem; max-width: 1200px; margin: 0 auto; } .demo-section { margin-bottom: 3rem; h3 { margin-bottom: 1.5rem; color: #333; border-bottom: 2px solid #007bff; padding-bottom: 0.5rem; } } .animation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; } .demo-card { padding: 1.5rem; border: 1px solid #ddd; border-radius: 8px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); transition: transform 0.2s ease; h4 { margin: 0 0 0.5rem 0; font-size: 1.2rem; } p { margin: 0; opacity: 0.9; } &:hover { transform: translateY(-2px); } } .demo-button { padding: 0.75rem 1.5rem; border: none; border-radius: 6px; background: #007bff; color: white; cursor: pointer; font-size: 1rem; transition: background-color 0.2s ease; &:hover { background: #0056b3; } } .demo-target { padding: 2rem; border: 2px dashed #007bff; border-radius: 8px; text-align: center; font-size: 1.2rem; font-weight: bold; background: #f8f9fa; margin-top: 1rem; } .service-target { background: linear-gradient(45deg, #ff6b6b, #4ecdc4); color: white; border: none; } .service-controls { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; } /* Responsive */ @media (max-width: 768px) { .animation-grid { grid-template-columns: 1fr; } .service-controls { justify-content: center; } } `] }) export class AnimationsDemoComponent { @ViewChild('animationTarget', { static: true }) animationTarget!: ElementRef; @ViewChild('serviceTarget', { static: true }) serviceTarget!: ElementRef; constructor(private animationService: UiAnimationsService) {} animateElement(animationType: string) { const element = this.animationTarget.nativeElement; const animationClass = `animate-${animationType}`; // Remove any existing animation classes first element.className = element.className.replace(/animate-\w+/g, ''); // Add animation class this.animationService.animateOnce(element, animationClass); } serviceAnimate(animationClass: string) { const element = this.serviceTarget.nativeElement; // Remove any existing animation classes first element.className = element.className.replace(/animate-\w+/g, ''); // Add animation class with service this.animationService.animateOnce(element, animationClass); } }