feat(deposit): implement modal animations with GSAP

This commit is contained in:
Jan-Marlon Leibl 2025-03-06 11:52:31 +01:00
parent c651337d30
commit 08a1a5e877
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
9 changed files with 177 additions and 17 deletions

View file

@ -1,4 +1,6 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
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',
@ -6,11 +8,36 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
imports: [],
templateUrl: './confirmation.component.html',
})
export class ConfirmationComponent {
export class ConfirmationComponent implements AfterViewInit, OnDestroy {
@Input() successful = true;
@Output() close = 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.close.emit();
this.modalAnimationService.closeModal(
this.modalCard.nativeElement,
this.modalBg.nativeElement,
() => this.close.emit()
);
}
}