Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade in delay on Load

I've stumpled on something quite nice, I've wanted to use in some upcoming project.

It's an animated opacity on load, or you can call it fade in.

I wondered if you could link some elements together (ex. 3) so element2 only starts when element1 is finished, and element3 when no. 2 is?

Or should you define a delay on element2 and multiply the delay on element3?

like image 266
curly_brackets Avatar asked Dec 08 '22 02:12

curly_brackets


2 Answers

If you had divs, say class="faded", you could fade each in on load, each in a row like this:

$(".faded").each(function(i) {
  $(this).delay(i * 400).fadeIn();
});

You can view a demo of this effect here, or a slower version here. The 400 is for 400ms, the duration of the normal .fadeIn() speed :)

You can either use .hide() to hide them on page load, like this:

$(".faded").hide()

Or do it in the CSS:

.faded { display: none; }
like image 85
Nick Craver Avatar answered Dec 22 '22 00:12

Nick Craver


You could have the fadeIn on element2 begin at the completion callback time of element1:

 element1.fadeIn(500, function() {  
       element2.fadeIn(500, function() { 
            etc...
like image 20
Joey C. Avatar answered Dec 22 '22 01:12

Joey C.