window.onload = function () { const modalBtn = document.getElementById('js-modalBtn'); const modal = document.getElementById('js-modal'); modalBtn.addEventListener('click', function () { modal.classList.add('is-active'); }); [].forEach.call(document.getElementsByClassName('js-modalClose'), function (el) { el.addEventListener('click', function () { modal.classList.remove('is-active'); }) }); // if (breakpoint.matches) { // const Body = document.body; // modalBtn.addEventListener('click', function () { // Body.style.overflow = "hidden"; // }); // [].forEach.call(document.getElementsByClassName('js-modalClose'), function (el) { // el.addEventListener('click', function () { // Body.style.overflow = "auto"; // }) // }); // } }; var setFillHeight = () => { const vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); } let vw = window.innerWidth; window.addEventListener('resize', () => { // if (vw === window.innerWidth) { // // 画面の横幅にサイズ変動がないので処理を終える // return; // } // 画面の横幅のサイズ変動があった時のみ高さを再計算する vw = window.innerWidth; setFillHeight(); }); // 初期化 setFillHeight(); const breakpoint = window.matchMedia("(max-width:768px)"); breakpoint.addEventListener("change", () => { window.location.reload(); });