(() => { const { EventManager, utils: { removeLocalStorage, isMobileDevice } } = ShopbySkin; const headerEl = document.querySelector('shopby-header-v2'); // 뷰포트 높이를 1vh로 설정 let vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); // 헤더의 높이 var header = document.querySelector('.header'); var headerHeight = header.offsetHeight; document.documentElement.style.setProperty('--headerh', headerHeight + 'px'); document.querySelector('.down-btn').addEventListener('click', function(e) { e.preventDefault(); var footer = document.getElementById('footer'); var position = footer.getBoundingClientRect().top + window.scrollY; // footer의 위치 계산 // 부드러운 스크롤 애니메이션 window.scrollTo({ top: position, behavior: 'smooth' }); }); // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.initialize({ apiOption: { platform: 'PC', }, }).then(() => { EventManager.fire('QUERY_PAGE_SCRIPTS', ShopbyExternalScript?.scripts); }); // 클릭이벤트 맵 // 1. SIGN_OUT : 로그아웃 const headerActionMap = { SIGN_OUT: () => { // 디자인교과서 로그아웃 시 자동 로그인 제거 removeLocalStorage('SAVE_MEMBER_LOGIN'); removeLocalStorage('SAVE_MEMBER_LOGIN_REFRESH'); removeLocalStorage('SAVE_MEMBER_LOGIN_REFRESH_DT'); EventManager.fire('SIGN_OUT'); }, GO_MY_MENU: (e) => { if (!utils.isSignedIn()) { e.preventDefault(); const from = e.target.href; const nextUrl = `${location.origin}/pages/sign-in/sign-in.html`; location.href = `${nextUrl}?from=${encodeURIComponent(from)}`; } }, }; // 클릭이벤트 핸들러 const clickEventListener = (e) => { const action = e?.target?.closest('[shopby-action]')?.getAttribute('shopby-action'); headerActionMap[action]?.(e); }; // 상단 카테고리 slider 초기화 EventManager.on('PAGE_LOAD_COMPLETED', ({ profile }) => { EventManager.fire('INIT_CATEGORY_SLIDER', { direction: 'horizontal', effect: 'slide', slidesPerView: 'auto', spaceBetween: 20, }); // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.setGlobalObjectSb({ getPlatform: () => (isMobileDevice ? 'MOBILE_WEB' : 'PC'), profile, }); }); headerEl?.addEventListener('click', clickEventListener); const searchParams = new URLSearchParams(location.search); const trackingKey = searchParams.get('trackingKey'); const channelType = searchParams.get('channelType'); const { setTrackingKey, setChannelType } = ShopbySkin.utils; setTrackingKey(trackingKey); setChannelType(channelType); })();