$(document).ready(function () { //scroll-move.js 서브페이지 컨텐츠 스크롤 이벤트 subpagescroll(); //스크롤시 헤더 아래에 lnb고정, header css변경 함수 function lnb_fix(size) { let height = $(document).scrollTop(), $lnb = $('#lnb'), $contents = $('.contents'); if (height > 40) { $header.attr('class', 'active'); if (height > size) { $lnb.addClass('active'); $contents.addClass('active'); } else if (height < size) { $lnb.removeClass('active'); $contents.removeClass('active'); } } else if (height == 0) { $lnb.removeClass('active'); $header.attr('class', 'n_active'); } } //반응형에 따라 lnb 고정위치 변경, 함수 호출 (헤더 높이값이 달라져서) $(window).resize(function () { $(window).scroll(function () { if (1200 < $(window).width()) { //lnb고정 lnb_fix(490); } else if (768 < $(window).width() && $(window).width() <= 1200) { //lnb고정 lnb_fix(283); } else if ($(window).width() <= 767) { //lnb고정 lnb_fix(162); } }) }).resize(); //메뉴바 드롭다운 호버 이벤트 (모바일이 아닐 경우에만 함수호출) $('.sub-menu, .menu-bg').hide(); $('.header-gnb, .menu-bg').mouseover(function () { menu_on(); }).mouseout(function () { let height = $(document).scrollTop(); menu_out('active'); //스크롤이 맨 위 라면 헤더 배경 투명 if (height == 0) { menu_out('n_active'); } }); let $menubg = $('.sub-menu, .menu-bg'), $header = $('#header'), $headergnb = $('.header-gnb'), $headergnbli = $('.header-gnb>ul>li'), $submenu = $('.sub-menu'); //메인베뉴바 드롭다운 함수 태블릿 이하라면 호출x function menu_on() { if ($(window).width() <= 1200) { return; } $menubg.stop().slideDown(200); $header.attr('class', 'active'); $headergnb.css('width', '1000px'); $headergnbli.css('width', '150px'); $submenu.css('margin-left', '0'); } function menu_out(a) { if ($(window).width() <= 1200) { return; } $('.sub-menu, .menu-bg').stop().slideUp(200); $header.attr('class', a); $headergnb.css('width', '800px'); $headergnbli.css('width', 'auto'); $submenu.css('margin-left', '-50px'); } //lnb 호버 submenu 드롭다운 let $lnbsub = $('#lnb .lnb-sub'), $lnbmainli = $('#lnb .main-li'); $lnbsub.hide(); $lnbmainli.mouseover(function () { $lnbmainli.removeClass('mouseon'); $(this).addClass('mouseon'); $(this).find('.lnb-sub').stop().slideDown(200); }).mouseout(function () { $lnbmainli.removeClass('mouseon'); $(this).find('.lnb-sub').stop().slideUp(200); }) //lnb 호버 컬러 이벤트 let $lnbli = $('#lnb ul li'); $lnbli.mouseover(function () { $lnbli.removeClass('mouseon'); $(this).addClass('mouseon'); }).mouseout(function () { $lnbli.removeClass('mouseon'); }) //contents sub btn(상세메뉴) 클릭 이벤트 색상 let $subbtnli = $('.sub-btn li'); $subbtnli.on('click', function () { $subbtnli.removeClass('active'); $(this).addClass('active'); }); //sub btn 클릭이벤트 let $boxcon = $('.box-wrap .box-con'); $('.box-wrap .box-con:gt(0)').hide(); $subbtnli.eq(0).on('click', function () { $boxcon.hide(); $('.con-1').show(); }) $subbtnli.eq(1).on('click', function () { $boxcon.hide(); $('.box-wrap .con-2').show(); }) function year_fix(scrollThresholds) { let height = $(document).scrollTop(); console.log(height); //스크롤 값을 배열로 나열하고 if (height > scrollThresholds[0]) { $('.contents-intro04 .box-wrap').addClass('on'); //-1에서 시작해야 i가 5까지 도달 할 수 있음 let activeIndex = -1; //스크롤 위치(height)가 i번째 조건보다 작으면 i-1에 addclass for (let i = 1; i < scrollThresholds.length; i++) { if (height < scrollThresholds[i]) { activeIndex = i - 1; break; } } // 마지막 조건값보다 스크롤이 더 크면 마지막 인덱스를 활성화 if (activeIndex === -1) { activeIndex = scrollThresholds.length - 1; } // 활성화된 인덱스에 따라 클래스 설정 $('.contents-intro04 .year-num li').removeClass('active').eq(activeIndex).addClass('active'); } else { $('.contents-intro04 .box-wrap').removeClass('on'); $('.contents-intro04 .year-num li').removeClass('active').eq(0).addClass('active'); } } function applyYearFix() { let windowWidth = $(window).width(); if (windowWidth > 1200) { //데스크탑 스크롤 year_fix([780, 1831, 2725, 3633, 4837]); } else if (windowWidth > 768 && windowWidth <= 1200) { //태블릿 스크롤 year_fix([520, 1493, 2316, 3151, 4222]); } } //intro04.html에서만 실행 if (window.location.pathname === "/01_intro/intro04.html") { $(window).on('resize scroll', applyYearFix); } let $topbtn = $(".top-btn"); // $topbtn.hide(); // //공지사항, 온라인견적문의 게시판에서는 보이지 않도록함 // if (window.location.pathname !== "/06_cust/cust01.html" && // window.location.pathname !== "/05_requ/requ02.html") { // $(window).scroll(function () { // if ($(this).scrollTop() > 250) { //250 넘으면 버튼이 보여짐니다. // $topbtn.css('transition', 'none') // $topbtn.fadeIn(); // } else { // $topbtn.css('transition', 'none') // $topbtn.fadeOut(); // } // }); // } //css 애니메이션 $topbtn.mouseover(function () { $topbtn.css({ 'background-color': '#135992', 'color': '#fff' }) }).mouseout(function () { $topbtn.css({ 'background': '#fff', 'color': '#135992' }) }) // 버튼 클릭시 맨 위로 이독 $topbtn.click(function () { $('html, body').animate({ scrollTop: 0 // 0 까지 animation 이동합니다. }, 300); // 속도 400 return false; }); //게시판 글쓰기버튼 따라다니는거 근데 fixed로 변경했음 //쓸려면 포지션 픽스드에서 앱솔, bottom을 top으로 바꿔야힘 (css) // let tmp = parseInt($(".skin_write_btn_area").css('top')); // $(".skin_write_btn_area").hide(); // $(window).scroll(function () { // let scrollTop = $(window).scrollTop()+200; // let obj_position = scrollTop + tmp + "px"; // if(scrollTop >= 150){ // $(".skin_write_btn_area").show(); // $(".skin_write_btn_area").stop().animate({ // "top": obj_position // }, 300); // } // }).scroll(); });