$(function(){ var ua = navigator.userAgent; var anchorHader = 0; var headerHeight = 0; var hash = window.location.hash; if (ua.indexOf('iPhone') > -1 || ua.indexOf('Android') > -1) { anchorHader = 40; } else { anchorHader = 26; } //特定のハッシュタグがあったらスムーズスクロールでその場所に移動する window.addEventListener("load", function() { var anchorHeader = 40; var hash = location.hash; if (hash === '#apply') { setTimeout(function() { // iOS Safari対策で少し遅らせる var linkTarget = document.querySelector(hash); if (linkTarget) { var linkPosition = linkTarget.getBoundingClientRect().top + window.scrollY - anchorHeader - 20; window.scrollTo({ top: linkPosition, behavior: "smooth" }); } }, 300); } }); // 固定ヘッダー要素をjQueryオブジェクトとして取得 const $fixed = $("#sp_nav"); //フェードイン処理 $(window).scroll(function (){ $('.fadeIn').each(function(){ var position = $(this).offset().top; var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); if (scroll > position - windowHeight + 100){ $(this).addClass('active'); } }); // スクロール位置が200pxを超えたら if ($(this).scrollTop() > 100) { $fixed.addClass("is-show"); } else { $fixed.removeClass("is-show"); } }); // スクロール $('a[href^="#"]:not(".modal")').click(function () { var speed = 300; var href = $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - anchorHader; $('body,html').stop().animate({ scrollTop: position }, speed, 'swing'); return false; }); $(".modal").colorbox({ inline:true, maxWidth:"90%", maxHeight:"90%", opacity: 0.7 }); $("#closeBtn").click(function(){ parent.$.colorbox.close(); return false; }); });