// スクロールバーの幅計算 const setScrollbarWidth = () => { const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth // カスタムプロパティの値を更新する document.documentElement.style.setProperty('--scrollbar', `${scrollbarWidth}px`); // console.log("スクロールバーの幅" + scrollbarWidth + "px"); }; // 表示されたとき window.addEventListener('load', setScrollbarWidth); // リサイズしたとき window.addEventListener('resize', setScrollbarWidth); // フェードインアニメーション let fadeItem = document.querySelectorAll(".fadeIn"); let windowH = window.innerHeight; let scrollY = window.scrollY; const fadeInFunc = () => { for(let i = 0; i < fadeItem.length; i++) { let itemTop = Math.floor(fadeItem[i].getBoundingClientRect().top); if(itemTop < windowH * 0.9) { fadeItem[i].style.cssText = 'opacity: 1; transform: translateY(0)'; } else { fadeItem[i].style.cssText = ''; } } } window.addEventListener('scroll', fadeInFunc, false);