Skip to content

Instantly share code, notes, and snippets.

@fercocuzza
fercocuzza / gist:1e6e63a5edccc1f9da63
Created August 4, 2015 17:44
hide-div-on-scroll
$(window).scroll(function(){
var threshold = 200; // number of pixels before bottom of page that you want to start fading
var op = (($(document).height() - $(window).height()) - $(window).scrollTop()) / threshold;
if( op <= 0 ){
$("#thing-to-hide").hide();
} else {
$("#thing-to-hide").show();
}
$("#thing-to-hide").css("opacity", op );
});