I have been using a code snippet I found to fade in elements with the class "hideme" as I scroll to them. However, the elements only fade in when they are fully visible. Is there a way to modify the code so that they fade in as soon as they appear in the browser?
I attempted to change the ">" to "=" in this line and it somewhat worked:
if( bottom_of_window = bottom_of_object ){
But it's not functioning properly when applied to the second set of elements.
Thank you!
Original Source: http://jsfiddle.net/tcloninger/e5qaD/
Here is the code:
$(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 in */
if( bottom_of_window = bottom_of_object ){
$(this).animate({'opacity':'1'},500);
}
});
});
});