$(function () { //--------------------------------------------- // SP閲覧時のみ電話番号にリンクを付ける //--------------------------------------------- var ua = navigator.userAgent; if (ua.indexOf("iPhone") > 0 || ua.indexOf("Android") > 0) { $(".tel-link").each(function () { var str = $(this).text(); $(this).html( $("") .attr("href", "tel:" + str.replace(/-/g, "")) .append(str + ""), ); }); } //--------------------------------------------- // 外部リンクを別ウィンドウで開く //--------------------------------------------- $("a[href^=https]") .not('[href*="' + location.hostname + '"]') .attr("target", "_blank"); $("a[href^=http]") .not('[href*="' + location.hostname + '"]') .attr("target", "_blank"); //--------------------------------------------- // スムーズスクロール //--------------------------------------------- //#を含むリンクが対象 $('a[href^="#"]').click(function () { var speed = 600, href = $(this).attr("href"), //href="#"ならページトップ(html)へ href="#"以外ならhrefの指定先へ target = $(href == "#" || href == "" ? "html" : href), position = target.offset().top; $("body,html").animate({ scrollTop: position }, speed, "swing"); return false; }); //--------------------------------------------- // pagetopボタン スクロールでフェードイン //--------------------------------------------- // 300pxスクロールしたらpagetopボタンを表示する var topBtn = $("#PageTop"); topBtn.hide(); $(window).scroll(function () { if ($(this).scrollTop() > 300) { topBtn.fadeIn(); } else { topBtn.fadeOut(); } }); //--------------------------------------------- // スクロールで要素を表示 //--------------------------------------------- function showElementAnimation() { var element = document.getElementsByClassName("js-animation"); if (!element) return; // 要素がなかったら処理をキャンセル var showTiming = window.innerHeight > 768 ? 200 : 40; // 要素が出てくるタイミングはここで調整 var scrollY = window.pageYOffset; var windowH = window.innerHeight; for (var i = 0; i < element.length; i++) { var elemClientRect = element[i].getBoundingClientRect(); var elemY = scrollY + elemClientRect.top; if (scrollY + windowH - showTiming > elemY) { element[i].classList.add("is-show"); } else if (scrollY + windowH < elemY) { // 上にスクロールして再度非表示にする場合はこちらを記述 element[i].classList.remove("is-show"); } } } showElementAnimation(); window.addEventListener("scroll", showElementAnimation); //--------------------------------------------- // ローディング画面 //--------------------------------------------- $(window).on("load", function () { var loading = $("#loading"); //ローディングエリアを隠す処理 var isHidden = function () { loading.fadeOut(1000); //1000ミリ秒かけてフェードアウト $("body").removeClass("js-no-scroll"); }; //1000ミリ秒後にloadingFunc開始 setTimeout(isHidden, 1000); }); //--------------------------------------------- // 登壇者表示 //--------------------------------------------- var $items = $(".js-kouen-item"); var delay = 50; function checkAnimation() { var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); // 🔽 ここだけ追加 var isSP = window.innerWidth <= 767; var triggerOffset = isSP ? 300 : 500; // SP / PC $items.each(function (index) { var $el = $(this); var elementTop = $el.offset().top; if (scrollTop + windowHeight > elementTop + triggerOffset) { if (!$el.hasClass("fade-in")) { setTimeout(function () { $el.addClass("fade-in"); }, index * delay); } } else if (scrollTop + windowHeight < elementTop) { $el.removeClass("fade-in"); } }); } $(window).on("scroll resize", checkAnimation); checkAnimation(); //--------------------------------------------- // タイムテーブル表示 //--------------------------------------------- $(window).on("scroll", checkAnimation); checkAnimation(); // 初期表示対策 var $rows = $(".js-timetable-row"); var delay = 180; function checkTableAnimation() { var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); $rows.each(function (index) { var $row = $(this); var rowTop = $row.offset().top; // 表示領域に入ったら if (scrollTop + windowHeight > rowTop + 80) { if (!$row.hasClass("is-show")) { setTimeout(function () { $row.addClass("is-show"); }, index * delay); } } // 画面外に戻ったらリセット(複数回OK) else if (scrollTop + windowHeight < rowTop) { $row.removeClass("is-show"); } }); } $(window).on("scroll", checkTableAnimation); checkTableAnimation(); });