Update 1.js

This commit is contained in:
FURK4NGG
2024-11-26 23:19:47 +03:00
committed by GitHub
parent b3632ef7cf
commit 958e42a6d5
+9 -6
View File
@@ -1,30 +1,33 @@
// 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; // Ekranın %80'i tetik noktası const triggerBottom = window.innerHeight * 0.8; // Tetikleme 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) { if (boxTop < triggerBottom && boxBottom > 0 && window.scrollY > lastScrollY) {
// Kutucuk ekranın içinde ise görünür yap // Sadece aşağıya kayarken kutucuk ekranın içinde ise animasyonu tetikle
box.classList.add('visible'); box.classList.add('visible');
box.classList.remove('hidden'); box.classList.remove('hidden');
} else { } else if (window.scrollY < lastScrollY && boxBottom < window.innerHeight) {
// Kutucuk ekran dışında ise gizle // Yukarıya kayarken kutucuk ekranın dışında ise eski durumuna dön
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
window.addEventListener('scroll', checkVisibility); window.addEventListener('scroll', checkVisibility);
window.addEventListener('load', checkVisibility); window.addEventListener('load', checkVisibility);
/*IMAGE CHANGER*/ /*IMAGE CHANGER*/
let currentIndex = 0; let currentIndex = 0;
const images = document.querySelectorAll('#photo img'); const images = document.querySelectorAll('#photo img');