$(function(){ gsap.registerPlugin(ScrollTrigger); /*top버튼*/ $(document).ready(function() { //$('.btn_gotop').hide(); //console.log("숨김"); }); $(window).scroll(function(){ var scrollPosition = $(this).scrollTop(); //console.log(scrollPosition); var footerTop = $('#footer').offset().top; var distanceFromFooter = footerTop - scrollPosition; if ((scrollPosition > 500) && (distanceFromFooter > $(window).height())) { $('.btn_gotop').show(); } else { $('.btn_gotop').hide(); } }); $('.btn_gotop').click(function(){ //$('html, body').animate({scrollTop:0},400); locoScroll.scrollTo("#visual"); return false; }); //올메뉴 var $depth1 = $(".allmenu .allmenuwrap .con>ul>li>a"); $depth1.click(function(){ if($(window).width() <= 1399){ if($(this).parent().hasClass("active") == false){ $(".allmenu .allmenuwrap .con>ul>li").removeClass("active"); $(this).parent().addClass("active"); $(".allmenu .allmenuwrap .con>ul>li>a").removeClass("act"); $(this).addClass("act"); $(".allmenu .allmenuwrap .con>ul>li>ul ").stop().slideUp(300); $(this).next().stop().slideDown(300); } else{ $(this).parent().removeClass("active"); $(this).next().stop().slideUp(300); $(this).removeClass("act"); } }else { $(".allmenu .allmenuwrap .con>ul>li>a").show(); $(".allmenu .allmenuwrap .con>ul>li>a").removeClass("act"); } }); $(window).on("resize", function(){ if($(this).width() <= 1399){ $(".allmenu .allmenuwrap .con>ul>li>ul ").hide(); }else { $(".allmenu .allmenuwrap .con>ul>li>ul ").show(); $(".allmenu .allmenuwrap .con>ul>li>a").removeClass("act"); } }).resize(); /**$(window).scroll(function(){ if ($(this).scrollTop() > 300){ $('.btn_gotop').show(); } else{ $('.btn_gotop').hide(); } }); $('.btn_gotop').click(function(){ $('html, body').animate({scrollTop:0},400); return false; });**/ $(".m21_tabs li").click(function(){ let tabNum = $(".m21_tabs li").index($(this)); //console.log(tabNum); $(this).addClass("on").siblings().removeClass("on"); let moveSection = tabNum + 1; if(moveSection){ locoScroll.scrollTo(".m21 #con" + moveSection); return false; /**$('html, body').animate({ scrollTop: $("#con" + moveSection).offset().top - 50 },1000);**/ } }); locoScroll= new LocomotiveScroll({ el: document.querySelector('.data-scroll-container'), smooth: true, smoothMobile: false, //getDirection: true, paused: true, onUpdate: () => { window.dispatchEvent(new Event('resize')); }, multiplier: 0.75, scrollFromAnywhere: true, smartphone: { smooth: true }, tablet: { smooth: true }, //getSpeed: true, useKeyboard: true, //reloadOnContextChange: true }); setTimeout(() => { scroll.update(); }, 5000); locoScroll.on("scroll", ScrollTrigger.update); ScrollTrigger.scrollerProxy(".data-scroll-container", { scrollTop(value) { return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y; }, getBoundingClientRect() { return {top: 0, left: 0, width: window.innerWidth, height: window.innerHeight}; }, pinType: document.querySelector(".data-scroll-container").style.transform ? "transform" : "fixed" }); ScrollTrigger.addEventListener("refresh", () => locoScroll.update()); ScrollTrigger.refresh(); $(window).resize(function(){ ww = $(window).width(); if(ww >= 1400){ mainScrollD = 820; } if(ww <= 1400){ mainScrollD = 680; } if(ww <= 768){ mainScrollD = 560; } }).resize(); $(window).on('wheel touchmove', function(event){ scroll = locoScroll.scroll.instance.scroll.y; wh = $(window).height(); dh = $(document).height(); fh = $('#footer').height(); distanceFromFooter = (dh - wh) - fh; //console.log(scroll, distanceFromFooter) if(distanceFromFooter < scroll){ $('.btn_gotop').hide(); } else { $('.btn_gotop').show(); } }); /*랭귀지버튼*/ $(".head .gnb .language .langbtn").on("click", function(){ $(".head .gnb .language ul").slideToggle(300); }); });