JSFiddle - React, Tailwind, and code Playground
HTML
<div id="wrapper">
<div id="tester"></div>
</div>
<span></span>
CSS
body, html {
height: 100%;
}
#wrapper {
height: 400%;
background: #f44 ;
}
#tester {
position: absolute;
top: 150%;
right: 0;
width: 300px;
height: 200px;
background: #fff;
border: 5px solid #000;
}
span {
position: fixed;
top: 5%;
left: 5%;
}
JavaScript
var div = document.getElementById("tester"),
info = document.querySelector("span"); // Juste pour voir
window.addEventListener("scroll", function(){
animer = (window.pageYOffset || document.documentElement.scrollTop) + document.documentElement.clientHeight > div.offsetTop;
info.innerHTML = animer; // Juste pour voir
}, false);