export const backgroundFix = (body: HTMLBodyElement | null) => {
if (body?.classList.contains("dark")) {
document.documentElement.style.backgroundColor =
window.scrollY > 70 ? "#0e1825" : "#2a3746";
} else {
document.documentElement.style.backgroundColor =
window.scrollY > 70 ? "var(--bs-primary)" : "white";
}
};
window.addEventListener("load", () => {
const body = document.querySelector("body");
let ticking = false;
const tickBackgroundFix = () => {
if (!ticking) {
ticking = true;
window.requestAnimationFrame(() => {
backgroundFix(body);
ticking = false;
});
}
};
window.addEventListener("scroll", tickBackgroundFix, false);
tickBackgroundFix();
});