Update 1.js

This commit is contained in:
FURK4NGG
2025-02-24 20:56:52 +03:00
committed by GitHub
parent 9bfd885184
commit 38db9cd9cf
+6 -13
View File
@@ -1,4 +1,5 @@
/*CHANGE THEME*/ /*CHANGE THEME*/
// Darkmode instance'ını oluştur
const darkmode = new Darkmode(); const darkmode = new Darkmode();
document.getElementById("darkmode-toggle").addEventListener("click", function () { document.getElementById("darkmode-toggle").addEventListener("click", function () {
@@ -6,21 +7,13 @@ document.getElementById("darkmode-toggle").addEventListener("click", function ()
let metaTheme = document.getElementById("themeMeta"); let metaTheme = document.getElementById("themeMeta");
// MutationObserver ile class değişimini takip et // Karanlık modun aktif olup olmadığını localStorage'dan al
const observer = new MutationObserver(() => { const isDarkMode = darkmode.isActivated();
if (document.body.classList.contains("darkmode--activated")) {
metaTheme.setAttribute("content", "#100f2c"); // Dark mode theme rengi // Doğrudan theme color'ı değiştir
} else { metaTheme.setAttribute("content", isDarkMode ? "#100f2c" : "#F8F6E3");
metaTheme.setAttribute("content", "#F8F6E3"); // Light mode theme rengi
}
}); });
// Sadece class değişikliklerini izle
observer.observe(document.body, { attributes: true, attributeFilter: ["class"] });
// 1 saniye sonra observer'ı kapat (gereksiz yükü engellemek için)
setTimeout(() => observer.disconnect(), 1000);
});
/*SERVICES VISIBILITY*/ /*SERVICES VISIBILITY*/
const boxes = document.querySelectorAll('.services_id'); const boxes = document.querySelectorAll('.services_id');