I am working on this demo code. Why am I not able to console log when the top of #c
is hitting the bottom of screen?
$(window).scroll(function() {
var elemTop = $("#c").offset().top;
var screenBot = $(window).height();
var currentTop = elemTop - $(window).scrollTop();
if(currentTop == screenBot) {
console.log('Bottom of C Hits the View');
}
});
div{ height:500px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="a">Section A</div>
<div id="b">Section B</div>
<div id="c">Section C</div>
<div id="d">Section D</div>