const element = document.getElementById('targetElement'); const targetElementPosition = window.pageYOffset + element.getBoundingClientRect().top; document.getElementsByTagName('body')[0].onscroll = (e) => { const pos = window.pageYOffset; if( targetElementPosition > pos ) { // 処理 } };
対象となる要素がページの上端からどれだけの距離にあるのか計算する の応用とかの話
ただいまコメントを受けつけておりません。