/* hamburgerMenu */ $(function() { $("div.menu-trigger").click(function() { $(this).toggleClass("active"); $("nav").fadeToggle(150); /* $("html").toggleClass("scrollfix"); */ return false; }); }); /* smooth-scroll */ const header = document.querySelector(".fixed-header"); const headerHeight = header ? header.offsetHeight + 21 : 180; function scrollToPos(position) { const startPos = window.scrollY; const distance = Math.min( position - startPos, document.documentElement.scrollHeight - window.innerHeight - startPos ); const duration = 900; let startTime; function easeOutExpo(t, b, c, d) { return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b; } function animation(currentTime) { if (startTime === undefined) { startTime = currentTime; } const timeElapsed = currentTime - startTime; const scrollPos = easeOutExpo(timeElapsed, startPos, distance, duration); window.scrollTo(0, scrollPos); if (timeElapsed < duration) { requestAnimationFrame(animation); } else { window.scrollTo(0, position); } } requestAnimationFrame(animation); } function loadImages() { const targets = document.querySelectorAll("[data-src]"); for (const target of targets) { const dataSrc = target.getAttribute("data-src"); const currentSrc = target.getAttribute("src"); if (dataSrc !== currentSrc) { target.setAttribute("src", dataSrc); } } } for (const link of document.querySelectorAll('a[href*="#"]')) { link.addEventListener("click", (e) => { const hash = e.currentTarget.hash; const target = document.getElementById(hash.slice(1)); if (!hash || hash === "#top") { e.preventDefault(); scrollToPos(0); } else if (target) { e.preventDefault(); loadImages(); const position = target.getBoundingClientRect().top + window.scrollY - headerHeight; scrollToPos(position); history.pushState(null, "", hash); } }); } const urlHash = window.location.hash; if (urlHash) { const target = document.getElementById(urlHash.slice(1)); if (target) { history.replaceState(null, "", window.location.pathname); window.scrollTo(0, 0); loadImages(); window.addEventListener("load", () => { const position = target.getBoundingClientRect().top + window.scrollY - headerHeight; scrollToPos(position); history.replaceState(null, "", window.location.pathname + urlHash); }); } } /* touchevent */ $(function () { var userAgent = navigator.userAgent; var link = $(".js-link-hover"); if (userAgent.indexOf("iPhone") >= 0 || userAgent.indexOf("iPad") >= 0 || userAgent.indexOf("Android") >= 0) { link.on("touchstart", function () { $(this).addClass("link-hover"); }); /* link.on("touchend", function () { $(this).removeClass("link-hover"); }); */ } else { link.hover( function () { $(this).addClass("link-hover"); }, function () { $(this).removeClass("link-hover"); } ); } }); /* linkDelay */ $(function () { var uaLinkDelay = navigator.userAgent; if (uaLinkDelay.indexOf("iPhone") >= 0 || uaLinkDelay.indexOf("iPad") >= 0 || uaLinkDelay.indexOf("Android") >= 0) { $(".js-link-hover").on("click", function() { event.preventDefault(); var link = $(this).attr("href"); setTimeout(function() { location.href= link; }, 375); }); } }); /* mvTop-random */ function shuffleContent(container) { var content = container.find("> *"); var total = content.length; content.each(function() { content.eq(Math.floor(Math.random() * total)).prependTo(container); }); } $(function() { shuffleContent($("header.mvTop section")); }); /* mvTop-slick */ $(function() { $("header.mvTop section").slick( { autoplay: true, autoplaySpeed: 4500, infinite: true, fade: true, cssEase: 'linear', speed: 450, dots: true, arrows: false, pauseOnFocus: false, pauseOnHover: false, swipe: false, }); }); /* detail-slick */ $(function() { $("div.detailSlide").slick( { autoplay: true, autoplaySpeed: 3000, infinite: true, variableWidth: true, speed: 150, dots: false, responsive: [{ breakpoint: 767, settings: { variableWidth: false, centerMode: true, slidesToShow: 1, centerPadding: '12vw', } }] }); }); /* faq-slick */ $(function() { $("div.faqSlide").slick( { autoplay: true, autoplaySpeed: 3000, infinite: true, variableWidth: true, speed: 150, dots: false, responsive: [{ breakpoint: 767, settings: { variableWidth: false, centerMode: true, slidesToShow: 1, centerPadding: '12vw', } }] }); }); /* professional-slick */ $(function() { $("div.professionalSlide").slick( { autoplay: true, autoplaySpeed: 3000, infinite: true, centerMode: true, slidesToShow: 3, centerPadding: '12vw', speed: 150, dots: false, responsive: [{ breakpoint: 767, settings: { slidesToShow: 1, centerPadding: '12vw', } }] }); }); /* school-slick */ $(function() { $("section.schoolSlick").slick( { arrows: false, autoplay: true, autoplaySpeed: 2500, dots: true, responsive: [ { breakpoint: 767, settings: { dots:true, }, } ], }); }); /* top-bg */ var topBgHeight = $("div.contentTop").height(); $(function() { $("div.contentTop").height(h); }); /* gsap-top */ gsap.fromTo(".bgTop-a", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "section.topTitle", start: "top bottom", end: "bottom bottom", }, } ); gsap.fromTo(".bgTop-b", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "section.message", start: "top bottom", end: "bottom bottom", }, } ); gsap.fromTo(".mvv .layout", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "section.mvv", start: "top bottom", end: "bottom bottom", }, } ); gsap.fromTo(".provide .layout", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "section.provide", start: "top center", }, } ); gsap.fromTo(".bgTop-c", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "div.detailSlide", start: "top bottom", end: "bottom bottom", }, } ); gsap.fromTo(".bgTop-d", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "section.news-topics", start: "top bottom", end: "bottom bottom", }, } ); gsap.fromTo(".bgTop-e", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "div.faqSlide", start: "top bottom", end: "bottom bottom", }, } ); gsap.fromTo(".bgTop-f", { autoAlpha: 0, y: 15, }, { autoAlpha: 1, y: 0, duration: 1, scrollTrigger: { trigger: "footer", start: "top bottom", end: "bottom bottom", }, } );