This commit is contained in:
Robert Jagtiani
2025-04-02 14:33:36 +02:00
parent e1a83aed77
commit 15b818acdb
8 changed files with 146 additions and 84 deletions

View File

@@ -17,7 +17,7 @@ export interface Props {
const { title } = Astro.props;
---
<script>
<script>
import { H } from "highlight.run";
if (import.meta.env.PROD) {
@@ -29,76 +29,77 @@ const { title } = Astro.props;
enabled: true,
recordHeadersAndBody: true
}
})
});
}
window.addEventListener("scroll", (event) => {
const skala = document.getElementById("skala");
window.addEventListener("scroll", () => {
const skala = document.getElementById("skala");
if (skala?.classList.contains("no-scroll")) {
if (skala) {
skala.classList.remove(
"2xl:fixed",
"2xl:py-4",
"2xl:top-0",
"2xl:z-20"
);
skala.classList.add("w-full");
skala.style.borderBottom = "none";
}
if (!skala) return;
document
.getElementById("formInput-1")
?.classList.remove("2xl:mt-[370px]");
return;
}
// Wenn skala "no-scroll" hat, alles zurücksetzen
if (skala.classList.contains("no-scroll")) {
skala.classList.remove(
"2xl:fixed",
"2xl:py-4",
"2xl:top-0",
"2xl:z-20"
);
skala.classList.add("w-full");
skala.style.borderBottom = "none";
skala.style.width = ""; // zurücksetzen
let scroll = window.scrollY;
if (scroll >= 400) {
if (skala) {
skala.classList.add(
"2xl:fixed",
"2xl:py-4",
"2xl:top-0",
"2xl:z-20"
);
skala.classList.remove("w-full");
skala.style.borderBottom = "3px solid #e6e6e6";
}
document.getElementById("formInput-1")?.classList.remove("2xl:mt-[370px]");
return;
}
const performanceBox =
document.getElementById("performance-box");
if (performanceBox) {
performanceBox.style.maxWidth = "688.5px";
}
const progressBox = document.getElementById("progress-box");
let scroll = window.scrollY;
if (scroll >= 400) {
// Breite einmal auslesen und festsetzen
const skalaWidth = skala.offsetWidth + "px";
skala.style.width = skalaWidth;
if (progressBox) {
progressBox.style.maxWidth = "688.5px";
}
skala.classList.add(
"2xl:fixed",
"2xl:py-4",
"2xl:top-0",
"2xl:z-20"
);
skala.classList.remove("w-full");
skala.style.borderBottom = "3px solid #e6e6e6";
document
.getElementById("formInput-1")
?.classList.add("2xl:mt-[370px]");
} else {
if (skala) {
skala.classList.remove(
"2xl:fixed",
"2xl:py-4",
"2xl:top-0",
"2xl:z-20"
);
skala.classList.add("w-full");
skala.style.borderBottom = "none";
}
document.getElementById("formInput-1")?.classList.add("2xl:mt-[370px]");
} else {
skala.classList.remove(
"2xl:fixed",
"2xl:py-4",
"2xl:top-0",
"2xl:z-20"
);
skala.classList.add("w-full");
skala.style.borderBottom = "none";
skala.style.width = ""; // zurücksetzen
document.getElementById("formInput-1")?.classList.remove("2xl:mt-[370px]");
}
});
window.addEventListener("resize", () => {
const skala = document.getElementById("skala");
if (!skala) return;
// Nur aktualisieren, wenn gerade "fixed" ist
if (skala.classList.contains("2xl:fixed")) {
// Temporär zurücksetzen, um echte Breite zu bekommen
skala.style.width = "";
const skalaWidth = skala.offsetWidth + "px";
skala.style.width = skalaWidth;
}
});
document
.getElementById("formInput-1")
?.classList.remove("2xl:mt-[370px]");
}
});
</script>
<html lang="de">
<head>
<meta charset="UTF-8" />