// go to top $(document).ready(function(){ $(window).scroll(function () { var position = $(window).scrollTop(); if (position > 112) { // 탑버튼 보여줄 스크롤 위치지정 $('.hideBT').slideDown("slow"); } else { $('.hideBT').slideUp("slow"); } }); $('.hideBT #back2top').click(function () { $('body,html').animate({scrollTop: 0}, 200); // 클릭시 스크롤 탑으로 이동 }); }); var prevWidth = $(window).width(); var widthTimer; jQuery(document).ready(function($){ // PC ver header-fix $(window).scroll(function(){ var $pos = $(window).scrollTop(); // PC - header - fix if ($(window).width() > 1199) { if ($pos > 50) $("#header").addClass("fix"); else if($pos < 1) $("#header").removeClass("fix"); } // PC - sub - layout - animation if ($(window).width() > 1199) { if ($pos > 300) $(".sub-cate").addClass("fix"); else $(".sub-cate").removeClass("fix"); } }); // PC ver allMenu $(".pc-menu-btn a").click(function(){ $(".all-menu-box").stop().animate({"height":"450px"},"fast",function(){ $(this).addClass("active"); }); if ($(".all-menu-box").hasClass("active")) { $(".all-menu-box").stop().animate({"height":"0"},"fast",function(){ $(this).removeClass("active"); }); } return false; }); // instagram 모바일버전(4개) 적용 var $insta = $(".insta-list li"); for (var i=0 ; i < 4 ; i++ ) { $insta.eq(i).addClass("show"+(i+1)); } setGnb(); }); // header reset $(window).resize(function(){ var newWidth = $(window).width(); if ((prevWidth < 1200 && newWidth > 1199) || (newWidth < 1200 && prevWidth > 1199)) { $("#header *").removeAttr("style"); $("#header").removeClass("fix"); $(".sub-cate").removeClass("fix"); $(".gnb-box, .gnb-box *").removeAttr("style"); $(".prod-info").removeClass("on"); } if ((prevWidth < 1024 && newWidth > 1023) || (newWidth < 1024 && prevWidth > 1023)) { $("#header *").removeAttr("style"); $(".gnb-box, .gnb-box *").removeAttr("style"); } if ((prevWidth < 768 && newWidth > 767) || (newWidth < 768 && prevWidth > 767)) { $("#header *").removeAttr("style"); $(".gnb-box, .gnb-box *").removeAttr("style"); } clearTimeout(widthTimer); setTimeout(function(){ prevWidth = newWidth; },100); }); function setGnb() { // PC ver gnb-animation var onH=100, offH=100; var $pc_header_hover = $(".pc-box-bg"); var $header = $(".h-box"); // header 액션 function header_onAction() { $header.stop().animate({"height":onH+"px"},300); } function header_offAction() { $header.stop().animate({"height":offH+"px"},300); } $(".gnb > li").on("mouseenter focusin", function(){ if ($(window).width() > 1199) { var $gsub = $(this).children(".gnb-sub"); header_onAction(); $(".gnb-sub").not($gsub).slideUp("fast"); $gsub.slideDown("fast"); $pc_header_hover.stop().animate({"height":onH+"px"},300); if ($(".all-menu-box").hasClass("active")) { $(".all-menu-box").stop().animate({"height":"0"},function(){ $(this).removeClass("active"); }); } } }); $(".gnb-box").on("mouseleave focusout", function(){ if ($(window).width() > 1199) { header_offAction(); $(".gnb-sub").slideUp("fast"); $pc_header_hover.stop().animate({"height":0+"px"},300); } }); // device ver gnb-animation $(".gnb > li > a").on("click", function(){ if ( $(window).width() < 1199 ) { var $idx = $(this).parent("li").index(); var $gnb_sub = $(this).siblings("ul"); var $on = $(this).parent("li").hasClass("mobile-on"); $(".gnb-sub").not($gnb_sub).hide(); $(".gnb li").removeClass("mobile-on"); if (!$on) { $(this).parent("li").addClass("mobile-on"); $(".gnb-sub").eq($idx).show(); } else { $(this).parent("li").removeClass("mobile-on"); $(".gnb-sub").eq($idx).hide(); } return false; } }); } // device ver slideNav Toggle function openNav() { $(".sideNav").show(); $(".sideNav-bg").fadeIn('fast', function(){ $(".gnb-box").addClass("opened"); $("html").addClass("no-scroll"); }); } function closeNav() { $(".sideNav").hide(); $(".sideNav-bg").fadeOut("fast", function(){ $(".gnb-box").removeClass("opened"); $("html").removeClass("no-scroll"); }); }