Skip to content

Commit

Permalink
fix(alerts): not being able to claim rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Mar 1, 2024
1 parent 03311d8 commit d0fe0f5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
47 changes: 28 additions & 19 deletions frontend/src/ts/elements/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,27 +422,36 @@ NotificationEvent.subscribe((message, level, customTitle) => {
}
});

const modal = new AnimatedModal("alertsPopup", {
show: {
modal: {
from: {
marginRight: "-10rem",
const modal = new AnimatedModal(
"alertsPopup",
{
show: {
modal: {
from: {
marginRight: "-10rem",
},
to: {
marginRight: "0",
},
easing: "easeOutCirc",
},
to: {
marginRight: "0",
},
easing: "easeOutCirc",
},
},
hide: {
modal: {
from: {
marginRight: "0",
hide: {
modal: {
from: {
marginRight: "0",
},
to: {
marginRight: "-10rem",
},
easing: "easeInCirc",
},
to: {
marginRight: "-10rem",
},
easing: "easeInCirc",
},
},
});
() => {
hide();
},
() => {
hide();
}
);
16 changes: 13 additions & 3 deletions frontend/src/ts/popups/animated-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default class AnimatedModal {

constructor(
wrapperId: string,
customAnimations?: ConstructorCustomAnimations
customAnimations?: ConstructorCustomAnimations,
customEscapeHandler?: (e: KeyboardEvent) => void,
customWrapperClickHandler?: (e: MouseEvent) => void
) {
if (wrapperId.startsWith("#")) {
wrapperId = wrapperId.slice(1);
Expand Down Expand Up @@ -74,13 +76,21 @@ export default class AnimatedModal {

this.wrapperEl.addEventListener("keydown", (e) => {
if (e.key === "Escape" && isPopupVisible(this.wrapperId)) {
void this.hide();
if (customEscapeHandler) {
customEscapeHandler(e);
} else {
void this.hide();
}
}
});

this.wrapperEl.addEventListener("mousedown", (e) => {
if (e.target === this.wrapperEl) {
void this.hide();
if (customWrapperClickHandler) {
customWrapperClickHandler(e);
} else {
void this.hide();
}
}
});

Expand Down

0 comments on commit d0fe0f5

Please sign in to comment.