我试图在滚动时将一个 div 堆栈放在另一个堆栈之上。现在,第二个 div 的不透明度设置为 0,一旦到达第二个 div 的底部,不透明度就变为 1。我该如何调整它,以便当滚动到达 div 的顶部时不透明度变为 1?
$(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);
}