window.addEventListener('load', function(){ // 사업 소개 이벤트 let businessLinks = document.querySelectorAll('.snb-menu-anchor a'); let header = document.querySelector('header'); // 사업소개 클릭 이벤트 businessLinks.forEach((link) => { link.addEventListener('click', function(e){ // 기본 이벤트 제거 e.preventDefault(); let targetId = this.getAttribute('href'); let targetSec = document.querySelector(targetId); let headerHeight = header ? header.offsetHeight : 0; if(lenis){ lenis.scrollTo(targetSec, { offset: -headerHeight, duration:2, easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), }); } else { const targetPosition = targetSec.getBoundingClientRect().top + window.pageYOffset; window.scrollTo({ top: targetPosition - headerHeight, behavior: 'smooth' }); // targetSec.scrollIntoView({ // behavior: 'smooth', // block: 'start' // }); } }) }) let html = document.querySelector('html'); // 인증자료 이벤트 let certiLists = document.querySelectorAll('.bbs-certi .list li'); let certiModal = document.querySelector('.bbs-certi .modal'); let certiModalBg = document.querySelector('.bbs-certi .modal-bg'); // 모달창 슬라이드 let modalSwiper = new Swiper('.modal .swiper', { spaceBetween:10, navigation: { nextEl: ".modal .next", prevEl: ".modal .prev", }, pagination: { el: '.modal .progress', type: 'progressbar', }, }); certiLists.forEach((list, i) => { // 클릭 이벤트 list.addEventListener('click', function(){ modalSwiper.slideTo(i); // 모달창 활성화 certiModal.classList.add('open'); // 모달창 활성화 시 부드러운 스크롤 중지 함수 호출 scrollOff(); }); }) certiModalBg.addEventListener('click', function(){ // 모달창 비활성화 certiModal.classList.remove('open'); // 모달창 비활성화 시 부드러운 스크롤 실행 함수 호출 scrollOn(); }) const params = new URLSearchParams(window.location.search); const targetId = params.get('pageId'); if (targetId) { const el = document.getElementById(targetId); if (el) { setTimeout(() => { const headerHeight = header?.offsetHeight || 0; const top = el.getBoundingClientRect().top + window.pageYOffset - headerHeight; window.scrollTo({ top, behavior: 'smooth' }); }, 100); } } }, false);