Update 1.js

This commit is contained in:
FURK4NGG
2024-11-26 23:32:43 +03:00
committed by GitHub
parent bca1871abc
commit 9d60214b10
+6 -8
View File
@@ -1,26 +1,24 @@
// Kutucukları seç
const boxes = document.querySelectorAll('.services_id'); const boxes = document.querySelectorAll('.services_id');
let lastScrollY = 0; // Son kaydırma pozisyonunu tutar
// Görünürlük kontrol fonksiyonu // Görünürlük kontrol fonksiyonu
function checkVisibility() { function checkVisibility() {
const triggerBottom = window.innerHeight * 0.8; // Tetikleme noktası const triggerBottom = window.innerHeight * 0.8; // Ekranın %80'i tetik noktası
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 < triggerBottom && boxBottom > 0 && window.scrollY > lastScrollY) { if (boxTop < triggerBottom && boxBottom > 0) {
// Sadece aşağıya kayarken kutucuk ekranın içinde ise animasyonu tetikle // Kutucuk ekranın içinde ise görünür yap
box.classList.add('visible'); box.classList.add('visible');
box.classList.remove('hidden'); box.classList.remove('hidden');
} else if (window.scrollY < lastScrollY && boxBottom < window.innerHeight) { } else {
// Yukarıya kayarken kutucuk ekranın dışında ise eski durumuna dön // Kutucuk ekran dışında ise gizle
box.classList.remove('visible'); box.classList.remove('visible');
box.classList.add('hidden'); box.classList.add('hidden');
} }
}); });
lastScrollY = window.scrollY; // Son kaydırma pozisyonunu güncelle
} }
// Scroll ve yükleme olaylarını dinle // Scroll ve yükleme olaylarını dinle