casino/frontend/src/app/shared/components/confirmation/confirmation.component.ts
Jan Klattenhoff 8c9d7c498b
All checks were successful
CI / prettier (pull_request) Successful in 22s
CI / Checkstyle Main (pull_request) Successful in 31s
CI / eslint (pull_request) Successful in 37s
CI / test-build (pull_request) Successful in 44s
style(home): format HTML and TypeScript code for clarity
2025-03-12 19:26:07 +01:00

49 lines
1.2 KiB
TypeScript

import {
Component,
ElementRef,
EventEmitter,
Input,
Output,
ViewChild,
AfterViewInit,
OnDestroy,
} from '@angular/core';
import { ModalAnimationService } from '../../services/modal-animation.service';
import gsap from 'gsap';
@Component({
selector: 'app-confirmation',
standalone: true,
imports: [],
templateUrl: './confirmation.component.html',
})
export class ConfirmationComponent implements AfterViewInit, OnDestroy {
@Input() successful = true;
@Output() closeConfirmation = new EventEmitter<void>();
@ViewChild('modalBg') modalBg!: ElementRef;
@ViewChild('modalCard') modalCard!: ElementRef;
constructor(private modalAnimationService: ModalAnimationService) {}
ngAfterViewInit() {
if (this.successful) {
this.openModal();
}
}
ngOnDestroy() {
gsap.killTweensOf([this.modalBg?.nativeElement, this.modalCard?.nativeElement]);
}
private openModal() {
this.modalAnimationService.openModal(this.modalCard.nativeElement, this.modalBg.nativeElement);
}
public closeModal() {
this.modalAnimationService.closeModal(
this.modalCard.nativeElement,
this.modalBg.nativeElement,
() => this.closeConfirmation.emit()
);
}
}