내 웹 사이트에서 이벤트 타임 라인을 만들고 타임 라인을 스크롤하면서 각 요소 (클래스 '.event')를 사용하여 페이드 인하려고합니다. 나는 문제가있다 - 그들은 모두 개별적으로보다는 오히려 동시에 퇴색한다.Jquery를 사용하여 스크롤 할 때 요소를 희미하게합니다.
왜 그런가? 미리 감사드립니다!
$(document).ready(function() {
/* Every time the window is scrolled ... */
$(window).scroll(function(){
/* Check the location of each desired element */
$('.event').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);
}
});
});
});
마크 업과 스타일 및 코드로 JSFiddle을 만들 수 있습니까? 내가 만든 JSFiddle에 JS를 놓으면 잘 작동한다. http://jsfiddle.net/drn33/. 우리는 왜 그것이 효과가 없는지 알아보기 위해 무엇이 다른지 알아볼 필요가 있습니다. –
그래, 여기 링크가 확실한 http://jsfiddle.net/edharrison89/V5DU7/ –