JSFiddle - React, Tailwind, and code Playground
HTML
<section id="first">
section 1
</section>
<section id="second">
section 2
</section>
<section id="third">
section 3
</section>
CSS
section {
height: 1000px;
}
JavaScript
$(function(){
$(window).scroll(function() {
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
var eTop = $('section#third').offset().top; //get the offset top of the element
if(eTop - ($(window).scrollTop()+$(window).height()) < 0) {
alert('I am showing!');
}
}, 250));
});
});