window.addEventListener("scroll", ()=>{
alert('you passed red box bottom')
})
.first-box{height:200px;
width:300px;
border:1px solid red}
.second-box{
height:200px;
width:300px;
border:1px solid blue
margin-top:140px;
}
<div class="first-box"></div>
<div class="second-box"></div>
Hi, I am creating simple app using Vanilla JS, And ran into the problem, I have scroll function, which i want to fire only when, user will pass red box bottom, I have tried to use element.offsetBottom
, But unfortunately nothing came out, I want to solve this problem only pure javascript, P.S div height is not static It can be increased, depending on the content, any solution?