Update 1.js

This commit is contained in:
FURK4NGG
2024-11-27 00:22:56 +03:00
committed by GitHub
parent c6e69f9cc0
commit a06ccc74ae
+3 -12
View File
@@ -1,30 +1,21 @@
// Kutucukları seç // Sorun çözümü için görünürlük kontrolü
const boxes = document.querySelectorAll('.services_id');
// Görünürlük kontrol fonksiyonu
function checkVisibility() { function checkVisibility() {
const triggerTop = window.innerHeight * 0.2; // Ekranın altına daha yakın bir tetik noktası const triggerBottom = window.innerHeight * 0.8;
boxes.forEach((box) => { boxes.forEach((box) => {
const boxTop = box.getBoundingClientRect().top; const boxTop = box.getBoundingClientRect().top;
const boxBottom = box.getBoundingClientRect().bottom; const boxBottom = box.getBoundingClientRect().bottom;
if (boxTop < window.innerHeight && boxBottom > triggerTop) { if (boxTop < triggerBottom) {
// Kutucuk ekranın alt kısmında ise görünür yap
box.classList.add('visible'); box.classList.add('visible');
box.classList.remove('hidden'); box.classList.remove('hidden');
} else { } else {
// Kutucuk ekranın dışında ise gizle
box.classList.remove('visible'); box.classList.remove('visible');
box.classList.add('hidden'); box.classList.add('hidden');
} }
}); });
} }
// Scroll ve yükleme olaylarını dinle
window.addEventListener('scroll', checkVisibility);
window.addEventListener('load', checkVisibility);
/*IMAGE CHANGER*/ /*IMAGE CHANGER*/