/** * js/front.js */ $(function () { const $body = $('body'); /* --------------------------------------- 메뉴 아이콘 토글 ---------------------------------------- */ $(document).on('click', '.menu-icon', function (e) { e.preventDefault(); $body.toggleClass('nav-active'); }); $(document).on("click", ".modal-open", function (e) { e.preventDefault(); $body.removeClass('nav-active'); $('#' + $(this).data("modal")).iziModal('open', this); }); }); //mobilemenu 열림 및 modal 위치인식 및 바디스트롤잠금적용 : iziModal.js, mobile-responsive.js-하위메뉴적용포함 $(document).ready(function() { //setTimeout(function () { // $("#visual").addClass("active"); //}); //top버튼 이동 Type2 $('.btn_up_layer').click(function(){ $("html, body").animate({scrollTop:0}, 'slow'); return false; }); /* 스크롤이 설정한 높이 이상 내려갔을때 스타일추가하기 */ if ($(window).width() > 0) { $(window).on("scroll",function(ev){ if($(window).scrollTop() > 50 ) { $('.btn_up_layer').addClass('active'); //$('#header').addClass('bg_on'); //$('.nav-but-wrap').addClass('bg_on'); } else{ $('.btn_up_layer').removeClass('active'); //$('#header').removeClass('bg_on'); //$('.nav-but-wrap').removeClass('bg_on'); } return false; }); } }); /* end */ $(function () { gnb(); classToggle(); fileUpload(); // fileupload $(this).find('.nice-select').niceSelect(); // selectbox scrollTopMov(); subMenuToggle(); accordion(); uiTab(); }); //xscroll $(window).on('load', function(){ xScroll('.x-scroll'); kScroll('.k-scroll'); // scroll bar true }); // iscroll outerwidth function calcWidth(target) { var $target = $(target); $target.each(function(){ var child = $(this).children(), width = 0; child.each(function(){ width += $(this).outerWidth(true); }); $(this).css('width', width); }); } // iscroll function xScroll(obj) { var $obj = $(obj), tabs = $obj.find('.tabs'); if ( $(obj).length <= 0 ) { return } else { $(window).resize(function(){ calcWidth(tabs); }); calcWidth(tabs); new IScroll(obj , { scrollX : true, scrollY : false, mouseWheel : false, autoCenterScroll : true, bounce : true }); } } // iscroll function kScroll(obj) { var $obj = $(obj), tabs = $obj.find('.tabs'); if ( $(obj).length <= 0 ) { return } else { $(window).resize(function(){ calcWidth(tabs); }); calcWidth(tabs); new IScroll(obj , { scrollX : true, scrollY : false, mouseWheel : false, autoCenterScroll : true, bounce : true, scrollbars: true }); } } // file upload function fileUpload() { var obj = $('.inputfile-wrap'); if (obj.length <= 0) return; var fileTarget = obj.find('input[type=file]'); fileTarget.on('change', function(){ if (window.FileReader) { var filename = $(this)[0].files[0].name; } else { var filename = $(this).val().split('/').pop().split('\\').pop(); } $(this).siblings('input[type=text]').val(filename); }); } // class toggle function classToggle() { $('[data-toggle="class-toggle"]').find('button, a').click(function(){ var li = $(this).closest('li'); var lis = li.siblings('li'); var wraps = $(this).closest($('[data-toggle="class-toggle"]')); var toggleSelf = wraps.data('toggle-self'); var toggleClass = wraps.data('toggle-class'); var className = toggleClass === undefined ? 'active' : toggleClass; if (toggleSelf){ if (li.hasClass(className)){ li.removeClass(className); } else { lis.removeClass(className); li.addClass(className); } } else { lis.removeClass(className); li.addClass(className); } }); } // gnb pc nav function gnb() { $('#gnb #gnb1_ul').hover(function(){ $('#gnb').addClass('on'); $('.gnb2_ul').css('display','block'); $('header.gbg-white').addClass('bg_on'); //$(this).parent('.gnb_wrap').parent('#gnb.on-wh').parent('#header').addClass('gnb-on'); setTimeout(function(){ $('.gnb2_ul').addClass('on'); },200); }, function(){ $('#gnb').removeClass('on'); $('.gnb2_ul').css('display','none'); $('.gnb2_ul').removeClass('on'); $('header.gbg-white').removeClass('bg_on'); // $(this).parent('.gnb_wrap').parent('#gnb.on-wh').parent('#header').removeClass('gnb-on'); }) // gnb pc nav End //gnb active $("#gnb .gnb1_li").each(function(){ if ($(this).children("a").text() == $(".location-tit .depth_1").text() ){ $(this).children("a").addClass('active'); } }); // GNB End } // accordion function accordion() { var wrap = $('.ui-accordion'), list = wrap.find('li'), title = wrap.find('.accord-title'), toggle = title.find('.btn-toggle'); if(wrap.length <= 0) return; // 접근성 대응 list.each(function(){ var $btn = $(this).find('.accord-title .btn-toggle'), $content = $(this).find('.accord-cont'), id = $(this).index(); $btn.attr({ 'id' : 'accord-toggle' + id, 'aria-controls' : 'accord-cont' + id }); $content.attr({ 'id' : 'accord-cont' + id, 'role' : 'region', 'aria-labelledby' : 'accord-toggle' + id }) }); toggle.click(function(){ var li = $(this).parent('.accord-title').parent('li'), cont = $(this).parent('.accord-title').siblings('.accord-cont'), blind = $(this).find('.blind'); if (li.hasClass('open')) { $(this).attr('aria-expanded', 'false'); cont.slideUp(); li.removeClass('open'); blind.text('상세보기'); } else { $(this).attr('aria-expanded', 'true'); cont.slideDown(); li.addClass('open'); blind.text('닫기'); } }); } // tab function uiTab() { var tab = '[data-evt="tab"]'; var isMapRendered = false; $(document).on('click', tab + ' a', function (e) { e.preventDefault(); var $this = $(this), id = $this.attr('href'), $target = $('[data-id=' + id + ']'), $siblings = $this.parents('li').siblings('').find('a'); $siblings.each(function () { var id = $(this).attr('href'); $(this).parents('li').removeClass('active'); $('[data-id=' + id + ']').hide(); }); $this.parents('li').addClass('active'); $target.show(); // 탭이 활성화된 후 지도를 렌더링 if (id === 'tabB' && !isMapRendered) { renderKakaoMap(); isMapRendered = true; } else { // 이미 지도가 로드된 후 재방문 시에도 스크롤 트리거 리프레시 requestAnimationFrame(() => { if (typeof lenis !== 'undefined') lenis.resize(); if (typeof ScrollTrigger !== 'undefined') ScrollTrigger.refresh(); }); } return false; }); if ( tab.length <= 0 ) return; $(tab).find('a').each(function(){ var tg = $(this).attr('href'); $('[data-id="'+tg+'"]').hide(); }); $(tab + ' > li:first-child a').click(); } // [추가] 카카오 지도 렌더링 함수 구별 function renderKakaoMap() { var map_h = "500"; if($(window).width() < 768) { map_h = "400"; } if (typeof daum !== 'undefined' && daum.roughmap && daum.roughmap.Lander) { new daum.roughmap.Lander({ "timestamp" : "1779801559236", "key" : "og8z6uegqdr", "mapHeight" : map_h }).render(); // 🔥 [핵심 추가] 지도가 그려진 직후 Lenis 스크롤 리사이즈 및 리프레시 // setTimeout을 통해 카카오 지도의 DOM 생성이 완전히 끝난 직후 실행되도록 보장합니다. setTimeout(function() { if (typeof lenis !== 'undefined') { lenis.resize(); } if (typeof ScrollTrigger !== 'undefined') { ScrollTrigger.refresh(); } }, 100); // 0.1초의 미세한 딜레이를 주어 완전히 렌더링된 후 작동하도록 합니다. } } // 스크롤 앵커이동 function scrollTopMov() { if (jQuery(window).width() > 1024) { $('.tab--scroll').click(function(){ $('html, body').animate({ scrollTop: $( $.attr(this, 'href') ).offset().top - 100 }, 500); return false; }); } else{ $('.tab--scroll').click(function(){ $('html, body').animate({ scrollTop: $( $.attr(this, 'href') ).offset().top - 100 }, 500); return false; }); } } /* Toggle */ function subMenuToggle() { // $('.submenuM').on('click', function(){ // $(this).siblings('.submenu_toggle').stop().slideToggle(); // }) $(".dropdownbox").click(function(){ $(".optionArea").toggleClass("showMenu"); $(".optionArea li").click(function(){ $(".dropdownbox > p").text($(this).text()); $(".optionArea").removeClass("showMenu"); }); }); }