feat(deposit): implement modal animations with GSAP
This commit is contained in:
parent
c651337d30
commit
08a1a5e877
9 changed files with 177 additions and 17 deletions
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue