jquery animation repeat, what is wrong with my syntax? -


can please evaluate code , let me know if correct.

i trying run 1 animation after another, pause 5000 milliseconds, reset heights 0 , repeat animation again indefinitely.

function animatethis(){             $(".bars div:nth-child(1)").animate({'height':'49px'}, 2000, function() {                 $(".bars div:nth-child(2)").animate({'height':'112px'}, 2000, function() {                     $(".bars div:nth-child(3)").animate({'height':'174px'}, 2000, function() {                         $(".bars div:nth-child(4)").animate({'height':'236px'}, 2000, function() {                             $(".bars div:nth-child(5)").animate({'height':'298px'}, 2000, function() {                                               $('.bars div').delay(2000).css({"height" : "0"}), function() { animatethis()};                             });                         });                     });                                                                           });             });         }     $(".bars").ready(function(){animatethis()}); 

the example can seen @ http://execusite.com/fazio/files/careers-banner/test.html

i have reformatted answers have received yesterday still doesn't work , haven't received feedback.

thanks!

you can this:

example: http://jsfiddle.net/patrick_dw/t5acf/4/

function animatethis() {     var length = $('.bars div').stop().each(function(i, val) {         $(val).delay(i * 2000).animate({ height: (i * 62) + 49 }, 2000, function() {             if (i === (length - 1)) {                 $('.bars div').animate({ height: 0 }, 2000, animatethis);             }         });     }).length; }  $(document).ready(function() { animatethis(); }); 

edit: didn't notice animation 0. fixed updated version.

edit: adding .stop() before new .each() seemed clean issue having.

edit: made little more efficient replacing $(this).index() i (which represents same index).


i'm not paying close enough attention. didn't want animate height 0, rather wanted delay 5000 milliseconds, reset.

example: http://jsfiddle.net/patrick_dw/t5acf/5/

function animatethis() {     var length = $('.bars div').each(function(i, val) {         $(val).delay(i * 2000).animate({ height: (i * 62) + 49 }, 2000, function() {             if (i === (length - 1)) {                 settimeout(function() {                      $('.bars div').height(0);                      animatethis();                 }, 5000);             }         });     }).length; }  $(document).ready(function() { animatethis(); }); 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -