document.addEventListener("DOMContentLoaded", function() { const fadeEls = document.querySelectorAll('.fadeUp2'); const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if(entry.isIntersecting){ entry.target.classList.add('show'); } }); }, { threshold: 0.2 }); fadeEls.forEach(el => observer.observe(el)); }); //글자가 조금씩 위로 올라가도록 설정 // 타이핑 효과 function startTyping(element){ const text = element.dataset.text; element.innerHTML = ""; let i = 0; function type(){ if(i < text.length){ element.innerHTML += text[i]; i++; setTimeout(type, 60); } } type(); } // 스크롤 등장할 때 타이핑 시작 document.addEventListener("DOMContentLoaded", function(){ const typingEls = document.querySelectorAll(".typingText"); const observer2 = new IntersectionObserver(entries => { entries.forEach(entry => { if(entry.isIntersecting){ startTyping(entry.target); } }); }, { threshold: 0.4 }); typingEls.forEach(el => observer2.observe(el)); });