Can you help me with CSS3 animations triggered by scrolling?
I came across a code that reveals a DIV element as the user scrolls down:
<script type="text/javascript">
$(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);
}
});
});
});
</script>
I'm working on a website with 5 different sections that should be revealed as the user scrolls to them. But I have a question about how to animate the contents within those boxes.
For example: In each box, there will be a title, content, and images. How can I make these elements appear one after another as the user scrolls? With the current code, all elements are shown at once.
I want the title to appear first, then the content, and finally the images when the user scrolls down. And this sequence should repeat for each box as the user navigates through them.
I've tried using CSS3 delays, but I can't predict how quickly users will scroll down.
Any tips would be greatly appreciated!