(function($){ $.fn.dropdown = function(){ return this.each(function(){ var $gnb = $(this), $menu = $gnb.find(".menu"), $depth1 = $gnb.find(".depth1"), $depth2 = $gnb.find(".depth2"); $gnb.mouseenter(function(){ gnbOn(); }).mouseleave(function(){ gnbOff(); }); $gnb.find("a").focusin(function(){ gnbOn(); }).focusout(function(){ gnbOff(); }); function gnbOn(){ $gnb.find($depth2).stop().animate({height: "250"});/*서브메뉴 높이 조절*/ } function gnbOff(){ $gnb.find($depth2).stop().animate({height: "0"}); } }); } })(jQuery); if (matchMedia("screen and (min-width: 1024px)").matches) { $(function(){ $(".dropdown").dropdown(); }); } else { $(function(){ }); } /*전체메뉴*/ $('#toggle').click(function() { $(this).toggleClass('active'); $('#gnb').toggleClass('open'); }); /*$('.dropdown').hover(function() { $('#logo').toggleClass('logo_on'); }); $('.dropdown').hover(function() { $('aside.util').toggleClass('util_on'); });*/ /* ============================ ✅ 앵커 이동 보정 (태그보다 조금 더 아래로) - EXTRA = 30 이면 "30px 더 아래로" 내려감 ============================ */ var EXTRA = 30; // ✅ 원하는 만큼 조절 (20~50 추천) $(document).on('click', '#gnb a[href^="#"]', function(e){ var href = $(this).attr('href'); var $target = $(href); if(!$target.length) return; e.preventDefault(); // ✅ 모바일 메뉴가 열려있으면 닫기 (레이아웃 흔들림 방지) $('#toggle').removeClass('active'); $('#gnb').removeClass('open'); // ✅ 상단 고정바 높이 var headerH = $('#toparea').outerHeight() || 0; // ✅ 태그보다 "조금 더 아래로" = 빼는 값을 줄이면 더 내려감 // (headerH - EXTRA) var top = $target.offset().top - (headerH - EXTRA); // ✅ 레이아웃 반영 한 박자 기다렸다가 이동 (첫 클릭 오차 방지) requestAnimationFrame(function(){ requestAnimationFrame(function(){ window.scrollTo({ top: top, behavior: 'smooth' }); // 주소창 해시 갱신(원하면 유지) history.replaceState(null, '', href); }); }); });