Update 1.js
This commit is contained in:
+6
-8
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user