I am trying to have one div stack on top of another on scroll. Right now, the second div opacity is set to 0 and once the bottom of the second div is reached, opacity becomes 1. How can I adjust this so that opacity becomes 1 when scroll reaches the top of the div instead?
$(document).ready(function() {
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('#thrillercontainer').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'},100);
$('#horrorcontainer').slideUp(100);
}