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ç
const boxes = document.querySelectorAll('.services_id');
// Görünürlük kontrol fonksiyonu
// Sorun çözümü için görünürlük kontrolü
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) => {
const boxTop = box.getBoundingClientRect().top;
const boxBottom = box.getBoundingClientRect().bottom;
if (boxTop < window.innerHeight && boxBottom > triggerTop) {
// Kutucuk ekranın alt kısmında ise görünür yap
if (boxTop < triggerBottom) {
box.classList.add('visible');
box.classList.remove('hidden');
} else {
// Kutucuk ekranın dışında ise gizle
box.classList.remove('visible');
box.classList.add('hidden');
}
});
}
// Scroll ve yükleme olaylarını dinle
window.addEventListener('scroll', checkVisibility);
window.addEventListener('load', checkVisibility);
/*IMAGE CHANGER*/