$(function(){ var $animation_elements = $('.ani'); var $window = $(window); function check_if_in_view() { var window_height = $window.height(); var window_top_position = $window.scrollTop(); var window_bottom_position = (window_top_position + window_height); $.each($animation_elements, function() { var $element = $(this); var element_height = $element.outerHeight(); var element_top_position = $element.offset().top; var element_bottom_position = (element_top_position + element_height); //check to see if this current container is within viewport if ((element_bottom_position >= window_top_position) && (element_top_position <= window_bottom_position)) { $element.addClass('in-view'); } else { //$element.removeClass('in-view'); } }); } $window.on('scroll resize', check_if_in_view); $window.trigger('scroll'); // Hide Header on on scroll down var didScroll; var lastScrollTop = 0; var delta = 5; var navbarHeight = $('#header').outerHeight(); $(window).scroll(function(event){ didScroll = true; }); setInterval(function() { if (didScroll) { hasScrolled(); didScroll = false; } }, 250); function hasScrolled() { var st = $(this).scrollTop(); // Make sure they scroll more than delta if(Math.abs(lastScrollTop - st) <= delta) return; // If they scrolled down and are past the navbar, add class .nav-up. // This is necessary so you never see what is "behind" the navbar. if (st > lastScrollTop && st > navbarHeight){ // Scroll Down $('#header').removeClass('nav-down').addClass('nav-up'); } else { // Scroll Up if(st + $(window).height() < $(document).height()) { $('#header').removeClass('nav-up').addClass('nav-down'); } } lastScrollTop = st; } let btnchk = 0; $(".btn_menu").click(function(){ if(btnchk == 0){ $(this).stop().addClass("openmenu"); $(".allmenuBg").addClass("on"); $(".allmenu").addClass("open"); $(".gnb").css("z-index","5000"); btnchk = 1; }else{ $(this).stop().removeClass("openmenu"); $(".allmenuBg").removeClass("on"); $(".allmenu").removeClass("open"); $(".gnb").css("z-index","1"); btnchk = 0; } }); var $depth1 = $(".allmenu .allmenuwrap>div>ul>li>a"); $depth1.click(function(){ if($(window).width() <= 1399){ if($(this).parent().hasClass("active") == false){ $(".allmenu .allmenuwrap>div>ul>li").removeClass("active"); $(this).parent().addClass("active"); $(".allmenu .allmenuwrap>div>ul>li>ul ").stop().slideUp(300); $(this).next().stop().slideDown(300); } else{ $(this).parent().removeClass("active"); $(this).next().stop().slideUp(300); } }else { $(".allmenu .allmenuwrap>div>ul>li>a").show(); //$(".allmenu .allmenuwrap>div>ul>li>a").removeClass("on"); } }); $(window).on("resize", function(){ if($(this).width() <= 1399){ $(".allmenu .allmenuwrap>div>ul>li>ul").hide(); }else { $(".allmenu .allmenuwrap>div>ul>li>ul").show(); } }).resize(); $(window).scroll(function(){ scroll = $(window).scrollTop(); footChk = $("#footer").outerHeight() btm_scroll = $(document).height() - $(window).height() ; if(scroll > btm_scroll - footChk){ $(".btn_top").addClass("act"); }else{ $(".btn_top").removeClass("act"); }; }); $(".btn_top").click(function(){ $('body,html').animate({scrollTop: 0}, 300); }) $(".head .btn_lang").click(function(e){ e.preventDefault(); console.log(1); $(".head .btn_lang .lang_box .lang_list").slideToggle(300); }); $(".head .btn_lang .lang_box .lang_list li").click(function(e){ e.stopPropagation(); }); });