Skip to content

Instantly share code, notes, and snippets.

@alexcican
Created February 5, 2013 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcican/4717987 to your computer and use it in GitHub Desktop.
Save alexcican/4717987 to your computer and use it in GitHub Desktop.
Snippet for fading in content as you scroll
$(document).ready(function() {
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('.hideme').each( function(i){
var bottom_of_object = $(this).position().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object ){
$(this).animate({'opacity':'1'},500);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment