I have the below jquery which is adding or removing a class when the user hits the bottom of the page. I'd like to adjust this code to implement the change when the user is close to the bottom, or perhaps when the bottom comes into viewport?
Any help greatly appreciated!
JS
// Add/remove class to/from .logo upon reaching bottom of page
$(window).scroll(function() {
$(".logo").removeClass("viewport-bottom");
if($(window).scrollTop() + $(window).height() === $(document).height()) {
//you are at bottom
$(".logo").addClass("viewport-bottom");
}
});