웹 브라우저/뷰포트에 요소가 표시되면 3 개의 요소 (테스트 1, 테스트 2, 테스트 3)를 하나씩 표시하려고합니다. 아래 코드를 인터넷에서 찾았습니다. Fadein은 작동하지만 사용자가 "경유지"에 도달하면 스크롤하여 페이지가로드되는 대신 즉시로드됩니다. 어쩌면 이것은 이해할 수없는 오프셋 코드 때문일 수 있습니까? 이 경우 어떻게됩니까? 그들이 볼 때 그들이으로 display:none
와웨이 포인트 플러그인을 사용하여 하나씩 요소를 표시합니다.
<script type="text/javascript">
$(document).ready(function() {
$('.test1').waypoint(function(event, direction) {
$(this).fadeIn(1500);
}, {
offset: function() {
return -$(this).height();
}
});
$('.test2').waypoint(function(event, direction) {
$(this).fadeIn(2000);
}, {
offset: function() {
return -$(this).height();
}
});
$('.test3').waypoint(function(event, direction) {
$(this).fadeIn(2500);
}, {
offset: function() {
return -$(this).height();
}
});
});
</script>