$(document).ready(function () { // 클래스가 "scroll_on"인 모든 요소를 선택합니다. const $counters = $(".scroll_on"); // 노출 비율(%)과 애니메이션 반복 여부(true/false)를 설정합니다. const exposurePercentage = 60; // ex) 스크롤 했을 때 $counters 컨텐츠가 화면에 100% 노출되면 숫자가 올라갑니다. const loop = false; // 애니메이션 반복 여부를 설정합니다. (true로 설정할 경우, 요소가 화면에서 사라질 때 다시 숨겨집니다.) // 윈도우의 스크롤 이벤트를 모니터링합니다. $(window).on('scroll', function () { // 각 "scroll_on" 클래스를 가진 요소에 대해 반복합니다. $counters.each(function () { const $el = $(this); // 요소의 위치 정보를 가져옵니다. const rect = $el[0].getBoundingClientRect(); const winHeight = window.innerHeight; // 현재 브라우저 창의 높이 const contentHeight = rect.bottom - rect.top; // 요소의 높이 // 요소가 화면에 특정 비율만큼 노출될 때 처리합니다. if (rect.top <= winHeight - (contentHeight * exposurePercentage / 100) && rect.bottom >= (contentHeight * exposurePercentage / 100)) { $el.addClass('active'); } // 요소가 화면에서 완전히 사라졌을 때 처리합니다. if (loop && (rect.bottom <= 0 || rect.top >= window.innerHeight)) { $el.removeClass('active'); } }); }).scroll(); $(".privacy_open").click(function(){ $("#privacy").fadeIn(); }); $("#privacy, .close").click(function(){ $("#privacy").fadeOut(); }); // //Default Action // $(".tab_content").hide(); //Hide all content // $("ul.tabs li:first").addClass("active").show(); //Activate first tab // $(".tab_content:first").show(); //Show first tab content // //On Click Event // $("ul.tabs li").click(function() { // $("ul.tabs li").removeClass("active"); //Remove any "active" class // $(this).addClass("active"); //Add "active" class to selected tab // $(".tab_content").hide(); //Hide all tab content // var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content // $(activeTab).fadeIn(); //Fade in the active content // return false; // }); $('#back-top').click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); }); function setPage(arg) { //navigation hn:1depth, sn:2depth, cn:3depth 를 받음 page = jQuery.extend({ hn : "", sn : "", cn : "" }, arg || {}); if(window.console) { console.log("hn : " + page.hn); } if(page.hn != 22) { $("#menu ul li.hn" + page.hn + " a").addClass("on"); //1depth 활성 } if(page.hn >= 23) { $("#menu ul li.hn" + page.hn + " a").addClass("on"); //유틸 1depth 활성 } $(".tabs li.sn" + page.sn).find(" a").addClass("on").end().find("> ul").addClass("on").find("> li.cn" + page.cn + " a").addClass("on"); //2depth 활성 }