From 2b6eaf4cb7e1c7881bdb8356a43b150fdca309f7 Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Thu, 20 Feb 2025 19:52:34 +0300 Subject: [PATCH] Update 1.js --- JAVASCRIPT/1.js | 86 ++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/JAVASCRIPT/1.js b/JAVASCRIPT/1.js index 4ade65f..e033925 100644 --- a/JAVASCRIPT/1.js +++ b/JAVASCRIPT/1.js @@ -1,43 +1,49 @@ -const themeMetaTag = document.querySelector('meta[name="theme-color"]'); - -function updateThemeColor() { - if (document.body.classList.contains("darkmode--activated")) { - themeMetaTag.setAttribute("content", "#fff"); // Karanlık Mod Rengi - } else { - themeMetaTag.setAttribute("content", "#fff"); // Açık Mod Rengi - } -} - - -// Dark mode değiştiğinde theme color'ı güncelle -document.addEventListener("DOMContentLoaded", updateThemeColor); -document.addEventListener("click", updateThemeColor); - -/*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 { - // Aksi halde kutuyu gizle - box.classList.remove('visible'); - box.classList.add('hidden'); - } - }); -} - -window.addEventListener('scroll', checkVisibility); -window.addEventListener('load', checkVisibility); - - +const themeMetaTag = document.querySelector('meta[name="theme-color"]'); + +function updateThemeColor() { + if (document.body.classList.contains("darkmode--activated")) { + themeMetaTag.setAttribute("content", "#100f2c"); // Karanlık Mod Rengi + } else { + themeMetaTag.setAttribute("content", "#ffffff"); // Açık Mod Rengi + } +} + +// Dark mode butonu oluştur ve çalıştır +const darkmode = new Darkmode(options); +darkmode.showWidget(); + +// Dark mode değiştiğinde theme color'ı güncelle +document.addEventListener("DOMContentLoaded", updateThemeColor); +document.addEventListener("click", () => { + setTimeout(updateThemeColor, 100); // Dark mode animasyonu için küçük gecikme +}); + + +/*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 { + // Aksi halde kutuyu gizle + box.classList.remove('visible'); + box.classList.add('hidden'); + } + }); +} + +window.addEventListener('scroll', checkVisibility); +window.addEventListener('load', checkVisibility); + + /*IMAGE CHANGER*/ let currentIndex = 0; const images = document.querySelectorAll('#photo img');