//전체 라인 높이 function updateAfterHeight() { const historyContent = document.querySelector('.history_list_wrap'); const height = historyContent.offsetHeight; const style = document.createElement('style'); style.innerHTML = ` .history_list_wrap::after { height: ${height - 118}px; } `; const existingStyle = document.querySelector('style#history-after-style'); if (existingStyle) { existingStyle.remove(); } style.id = 'history-after-style'; document.head.appendChild(style); } updateAfterHeight(); window.addEventListener('resize', updateAfterHeight); // 탭 버튼 클릭 & 스크롤 이벤트 const Historybuttons = document.querySelectorAll('.btn_history_year button'); const Historycontents = document.querySelectorAll('.history_content'); const offset = 80; function handleButtonClick(event) { const year = event.target.getAttribute('data-year'); const Historycontents = document.getElementById('year_' + year); const targetPosition = Historycontents.offsetTop - offset; window.scrollTo({ top: targetPosition, behavior: 'smooth' }); Historybuttons.forEach(button => button.classList.remove('active')); event.target.classList.add('active'); // Historycontents.forEach(section => section.classList.remove('active')); // Historycontents.classList.add('active'); } function handleScroll() { const scrollPosition = window.scrollY + offset; Historycontents.forEach(section => { const top = section.offsetTop; const bottom = top + section.offsetHeight; const year = section.id.split('_')[1]; if (scrollPosition >= top && scrollPosition < bottom) { Historybuttons.forEach(button => button.classList.remove('active')); document.querySelector(`.btn_history_year button[data-year="${year}"]`).classList.add('active'); } }); } Historybuttons.forEach(button => button.addEventListener('click', handleButtonClick)); window.addEventListener('scroll', handleScroll);