1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-06-28 12:27:47 +02:00

modal: use arrow function to avoid 'this' naming collision

This commit is contained in:
Harvey Tindall 2021-05-07 14:30:30 +01:00
parent 2816c6277d
commit 326c2cf70a
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -7,9 +7,9 @@ export class Modal implements Modal {
closeEvent: CustomEvent; closeEvent: CustomEvent;
constructor(modal: HTMLElement, important: boolean = false) { constructor(modal: HTMLElement, important: boolean = false) {
this.modal = modal; this.modal = modal;
this.openEvent = new CustomEvent("modal-open-" + modal.id) this.openEvent = new CustomEvent("modal-open-" + modal.id);
this.closeEvent = new CustomEvent("modal-close-" + modal.id) this.closeEvent = new CustomEvent("modal-close-" + modal.id);
const closeButton = this.modal.querySelector('span.modal-close') const closeButton = this.modal.querySelector('span.modal-close');
if (closeButton !== null) { if (closeButton !== null) {
this.closeButton = closeButton as HTMLSpanElement; this.closeButton = closeButton as HTMLSpanElement;
this.closeButton.onclick = this.close; this.closeButton.onclick = this.close;
@ -26,7 +26,7 @@ export class Modal implements Modal {
} }
this.modal.classList.add('modal-hiding'); this.modal.classList.add('modal-hiding');
const modal = this.modal; const modal = this.modal;
const listenerFunc = function () { const listenerFunc = () => {
modal.classList.remove('modal-shown'); modal.classList.remove('modal-shown');
modal.classList.remove('modal-hiding'); modal.classList.remove('modal-hiding');
modal.removeEventListener(window.animationEvent, listenerFunc); modal.removeEventListener(window.animationEvent, listenerFunc);