Created
February 5, 2013 21:41
-
-
Save alexcican/4717987 to your computer and use it in GitHub Desktop.
Snippet for fading in content as you scroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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