Newer
Older
newweb / js / fade.js
const ScrollContent = document.querySelectorAll('.scroll');
console.log(ScrollContent);
console.log('画面の高さ',window.innerHeight); 

document.addEventListener('scroll', () => { 

  for (let i=0; i < ScrollContent.length; i++){
    const ElementDistance = ScrollContent[i].getBoundingClientRect().top 
    + ScrollContent[i].clientHeight * .5;
    if (window.innerHeight > ElementDistance){ 
      ScrollContent[i].classList.add('show'); 
    }; 
  }
})