From 70f1f5462db67ec3b7609507f099c4750c11c570 Mon Sep 17 00:00:00 2001 From: Vedal Date: Mon, 10 Jun 2024 21:23:36 +0100 Subject: [PATCH] Scroll to top of modal on open --- frontend/www/css/base.css | 1 + frontend/www/src/modules/modal.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/frontend/www/css/base.css b/frontend/www/css/base.css index 45bdeb8..90b4ad6 100644 --- a/frontend/www/css/base.css +++ b/frontend/www/css/base.css @@ -8,6 +8,7 @@ body { background-color: #111; color: #fff; + overscroll-behavior: contain; } main { diff --git a/frontend/www/src/modules/modal.ts b/frontend/www/src/modules/modal.ts index ff6abc2..4baa5cb 100644 --- a/frontend/www/src/modules/modal.ts +++ b/frontend/www/src/modules/modal.ts @@ -21,6 +21,7 @@ document.addEventListener("auxclick", (e) => { /* Containers */ const $modalWrapper = document.getElementById("modal-wrapper")!; const $modal = document.getElementById("modal-wrapper")!.getElementsByClassName("modal")[0]!; +const $modalInsideWrapper = $modal.getElementsByClassName("modal-inside-wrapper")[0]!; /* Descriptors */ const $modalTitle = document.getElementById("modal-title")!; @@ -109,6 +110,9 @@ export async function openModal(redeem: Redeem | null) { $modalPrice.textContent = redeem.price.toString(); $modalImage.src = redeem.image; + // scroll to top of modal + $modalInsideWrapper.scrollTop = 0; + setTimeout(() => $modal.classList.add("active-modal"), 10); hideProcessingModal();