Update 1.js
This commit is contained in:
+12
-5
@@ -1,17 +1,24 @@
|
|||||||
/*CHANGE THEME*/
|
/*CHANGE THEME*/
|
||||||
document.getElementById("darkmode-toggle").addEventListener("click", function () {
|
document.getElementById("darkmode-toggle").addEventListener("click", function () {
|
||||||
const darkmode = new Darkmode(options);
|
let darkmode = new Darkmode();
|
||||||
darkmode.showWidget();
|
darkmode.toggle();
|
||||||
|
|
||||||
let metaTheme = document.getElementById("themeMeta");
|
let metaTheme = document.getElementById("themeMeta");
|
||||||
|
|
||||||
// Biraz gecikme ekleyerek class değişiminin algılanmasını sağlıyoruz
|
// MutationObserver ile class değişimini takip et
|
||||||
setTimeout(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (document.body.classList.contains("darkmode--activated")) {
|
if (document.body.classList.contains("darkmode--activated")) {
|
||||||
metaTheme.setAttribute("content", "#100f2c"); // Dark mode theme rengi
|
metaTheme.setAttribute("content", "#100f2c"); // Dark mode theme rengi
|
||||||
} else {
|
} else {
|
||||||
metaTheme.setAttribute("content", "#F8F6E3"); // Light mode theme rengi
|
metaTheme.setAttribute("content", "#F8F6E3"); // Light mode theme rengi
|
||||||
}
|
}
|
||||||
}, 300); // 300ms gecikme, gerekirse artırabilirsin
|
});
|
||||||
|
|
||||||
|
// 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*/
|
||||||
|
|||||||
Reference in New Issue
Block a user