From f212d0426102e8cec646bd381bc058864184e611 Mon Sep 17 00:00:00 2001
From: nullptr <62841684+not-nullptr@users.noreply.github.com>
Date: Sun, 3 Nov 2024 16:35:24 +0000
Subject: [PATCH] feat(servers): allow scrolling faq into view via hashes
(#2893)
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
---
apps/frontend/src/pages/servers/index.vue | 26 ++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/apps/frontend/src/pages/servers/index.vue b/apps/frontend/src/pages/servers/index.vue
index 207fc3230..522a326c8 100644
--- a/apps/frontend/src/pages/servers/index.vue
+++ b/apps/frontend/src/pages/servers/index.vue
@@ -403,7 +403,7 @@
Frequently Asked Questions
-
+
@@ -416,7 +416,7 @@
-
+
@@ -430,7 +430,7 @@
-
+
@@ -444,7 +444,7 @@
-
+
@@ -457,7 +457,7 @@
-
+
@@ -890,6 +890,22 @@ const isAtCapacity = computed(
() => isSmallAtCapacity.value && isMediumAtCapacity.value && isLargeAtCapacity.value,
);
+const scrollToFaq = () => {
+ if (route.hash) {
+ // where pyro-hash === route.hash
+ const faq = document.querySelector(`[pyro-hash="${route.hash.slice(1)}"]`);
+ if (faq) {
+ const top = faq.getBoundingClientRect().top;
+ const offset = window.innerHeight / 2 - faq.clientHeight / 2;
+ window.scrollTo({ top: window.scrollY + top - offset, behavior: "smooth" });
+ }
+ }
+};
+
+onMounted(scrollToFaq);
+
+watch(() => route.hash, scrollToFaq);
+
const selectProduct = async (product, custom) => {
if (isAtCapacity.value) {
addNotification({