Update 1.js
This commit is contained in:
+19
-28
@@ -1,36 +1,27 @@
|
|||||||
function setThemeColor() {
|
function updateThemeColor() {
|
||||||
const metaThemeColor = document.querySelector('meta[name="theme-color"]');
|
let themeColorMeta = document.querySelector('meta[name="theme-color"]');
|
||||||
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
if (!themeColorMeta) {
|
||||||
metaThemeColor.setAttribute('content', isDarkMode ? '#100f2c' : '#100f2c');
|
themeColorMeta = document.createElement('meta');
|
||||||
|
themeColorMeta.setAttribute('name', 'theme-color');
|
||||||
|
document.head.appendChild(themeColorMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
setThemeColor();
|
if (document.body.classList.contains("darkmode--activated")) {
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setThemeColor);
|
themeColorMeta.setAttribute("content", "#100f2c"); // Karanlık mod rengi
|
||||||
|
|
||||||
/*SERVICES VISIBILITY*/
|
|
||||||
const boxes = document.querySelectorAll('.services_id');
|
|
||||||
|
|
||||||
// Görünürlük kontrol fonksiyonu
|
|
||||||
function checkVisibility() {
|
|
||||||
const triggerBottom = window.innerHeight * 0.8;
|
|
||||||
|
|
||||||
boxes.forEach((box) => {
|
|
||||||
const boxTop = box.getBoundingClientRect().top;
|
|
||||||
|
|
||||||
if (boxTop < triggerBottom) {
|
|
||||||
box.classList.add('visible');
|
|
||||||
box.classList.remove('hidden');
|
|
||||||
} else {
|
} else {
|
||||||
// Aksi halde kutuyu gizle
|
themeColorMeta.setAttribute("content", "#F8F6E3"); // Açık mod rengi
|
||||||
box.classList.remove('visible');
|
}
|
||||||
box.classList.add('hidden');
|
}
|
||||||
|
|
||||||
|
// Sayfa yüklendiğinde kontrol et
|
||||||
|
updateThemeColor();
|
||||||
|
|
||||||
|
// Karanlık mod açıldığında veya kapandığında güncelle
|
||||||
|
document.addEventListener("click", function(event) {
|
||||||
|
if (event.target.classList.contains("darkmode-toggle")) {
|
||||||
|
setTimeout(updateThemeColor, 300); // Animasyon süresi kadar gecikmeli çalıştır
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('scroll', checkVisibility);
|
|
||||||
window.addEventListener('load', checkVisibility);
|
|
||||||
|
|
||||||
|
|
||||||
/*IMAGE CHANGER*/
|
/*IMAGE CHANGER*/
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user