function commonJs() { const wrap = document.querySelector('.wrap'); const html = document.querySelector('html'); const header = document.querySelector('header'); let windowWidth = window.innerWidth; let windowHeight = window.innerHeight; let mobileWidth = 1200; let scrollPos = 0; let stickyPos = 0; let ticking = false; let headerMenu = document.querySelector('.h_menu'); let burgerMenu = document.querySelector('.h_mobile__btn'); let linkToggle; let timer; window.addEventListener('scroll', scroll, false); window.addEventListener("resize", resize, false); // Page Load Class Add setTimeout(function () { wrap.classList.add('main-active'); }, 200); (headerAnimate = function (call) { windowWidth = window.innerWidth; windowHeight = window.innerHeight; scrollPos = window.scrollY || window.pageYOffset; animated(); if (windowWidth > mobileWidth) { burgerMaker(); } })(); function animated() { sticky(); } function resize() { clearTimeout(timer); timer = setTimeout(function () { timer = null; handle(); }, 66); } function handle() { call = "resize"; headerAnimate(call, windowWidth); } function scroll() { if (!ticking) { window.requestAnimationFrame(() => { call = 'scroll'; headerAnimate(call); ticking = false; }); ticking = true; } } function sticky() { let scrollPos = window.pageYOffset || document.documentElement.scrollTop; if (scrollPos > 0) { header.classList.add('active'); } else { header.classList.remove('active'); } stickyPos = scrollPos <= 0 ? 0 : scrollPos; } // Header Menu headerMenu.addEventListener('mouseover', isOver); headerMenu.addEventListener('mouseout', isOut); function isOver() { // html.style.overflow = "hidden"; header.setAttribute('data-hover', 'on'); } function isOut() { // html.style.overflow = ""; header.removeAttribute('data-hover'); } // Global Menu let headerGlobal = document.querySelector('.h_global'); headerGlobal.addEventListener('mouseover', function () { this.classList.add('on'); }); headerGlobal.addEventListener('mouseleave', function () { setTimeout(function () { headerGlobal.classList.remove('on'); }, 200); }); // Mobile Menu burgerMenu.addEventListener("click", function () { burgerMaker(this); }); function hideSubMenu() { linkToggle = document.querySelectorAll('.h_menu__toggle'); for (let i = 0; i < linkToggle.length; i++) { linkToggle[i].setAttribute('aria-toggle', 'false'); } } function clickSubMenu() { hideSubMenu(); for (let i = 0; i < linkToggle.length; i++) { linkToggle[i].addEventListener('click', function () { if (this.getAttribute('aria-toggle') === 'true') { hideSubMenu(); } else { hideSubMenu(); this.setAttribute('aria-toggle', 'true'); } }); } } clickSubMenu(); function burgerMaker(e) { if (e === undefined || e.getAttribute('aria-pressed') === 'true') { header.setAttribute('data-header-mobile', 'off'); burgerMenu.setAttribute('aria-pressed', 'false'); hideSubMenu(); html.style.overflow = ''; } else { burgerMenu.setAttribute('aria-pressed', 'true'); header.setAttribute('data-header-mobile', 'on'); html.style.overflow = 'hidden'; linkToggle.forEach((link) => { link.addEventListener('click', function (e) { e.preventDefault(); }); }); } } // AOS Animation AOS.init({ // offset: 300, duration: 800, // easing: 'linear', once: true, }); } function privacyModalEvent() { let privacyModalBtn = document.getElementById('privacyModalBtn'); let privacyModal = document.getElementById('privacyModal'); let modalClose = document.querySelector('.modal-privacy .close--modal'); let modalClose2 = document.querySelector('.modal-privacy .modal-bg'); if (privacyModalBtn) { privacyModalBtn.addEventListener('click', function () { privacyModal.classList.add('open'); }); modalClose.addEventListener('click', function () { privacyModal.classList.remove('open'); }); modalClose2.addEventListener('click', function () { privacyModal.classList.remove('open'); }); } } function gsapEvent() { // GSAP gsap.registerPlugin(ScrollTrigger, ScrollToPlugin); } function history() { const history = document.querySelector('.about .history'); if (history) { let historyProgress = gsap.timeline({ scrollTrigger: { trigger: ".his-line", start: "-10% 65%", end: "bottom 95% center", scrub: true, // markers: true, } }) .from(".progress", { height: 0, ease: "none" }); let dots = document.querySelectorAll('.month'); let years = document.querySelectorAll('.year'); for (let i = 0; i < dots.length; i++) { let dot = dots[i]; // 현재 dot gsap.to(dot, { scrollTrigger: { trigger: dot, start: "top 87%", end: "top 25%", onEnter: () => { dot.classList.add('on'); }, onLeaveBack: () => { dot.classList.remove('on'); }, scrub: true, // markers : true, } }); } for (let i = 0; i < years.length; i++) { let year = years[i]; // 현재 year gsap.to(year, { scrollTrigger: { trigger: year, start: "top 85%", end: "top 25%", onEnter: () => { year.classList.add('on'); }, onLeaveBack: () => { year.classList.remove('on'); }, scrub: true, // markers : true, } }); } } } function inquiry() { let inquiryForm = document.getElementById('inquiryForm'); if (inquiryForm) { let inquiryName = document.getElementById('inquiryName'); let inquiryTel = document.getElementById('inquiryTel'); let inquiryEmail = document.getElementById('inquiryEmail'); let inquirySubject = document.getElementById('inquirySubject'); let inquiryContext = document.getElementById('inquiryContext'); let agreeCheck = document.getElementById('agreeCheck'); let inquirySubmit = document.querySelector('.inquirySubmit'); let inquiryPrivacy = document.querySelector('.inquiryPrivacy'); let privacyModal = document.getElementById('privacyModal'); let modalClose = document.querySelector('.modal-privacy .close--modal'); let modalClose2 = document.querySelector('.modal-privacy .modal-bg'); // 개인정보처리방침 inquiryPrivacy.addEventListener('click', function () { privacyModal.classList.add('open'); }); modalClose.addEventListener('click', function () { privacyModal.classList.remove('open'); }); modalClose2.addEventListener('click', function () { privacyModal.classList.remove('open'); }); // 유효성 검사 inquirySubmit.addEventListener('click', function (e) { e.preventDefault(); if (inquiryName.value === "") { alert('이름을 입력해 주세요.') inquiryName.focus(); return false; } if (inquiryTel.value === "") { alert('연락처를 입력해 주세요.') inquiryTel.focus(); return false; } if (inquiryEmail.value === "") { alert('이메일을 입력해 주세요.') inquiryTel.focus(); return false; } if (inquirySubject.value === "") { alert('제목을 입력해 주세요.') inquirySubject.focus(); return false; } if (inquiryContext.value === "") { alert('내용을 입력해 주세요.') inquiryContext.focus(); return false; } if (!agreeCheck.checked) { alert('개인정보 수집·이용에 동의해 주세요.'); agreeCheck.focus(); return false; } if (confirm("문의하시겠습니까?")) { const formData = new FormData(document.forms[0]); formData.append("mode", "reg"); $.ajax({ type: "POST", url: "./proc/proc.php", processData: false, contentType: false, data: formData, success: function (data) { if (data.result === 'YES') { alert('문의가 접수되었습니다. \n담당자 확인 후 연락드리겠습니다.'); location.replace(location.href); } else { alert(data.message); } }, err: function (err) { console.log("err:", err) } }) } }); } }