How can I set a pause between 2 functions?
I have defined the following function:
- function animacion_frase($elemento)
- {
- $tiempo_1=1000;
- $tiempo_2=1000;
- $tiempo_pausa=1000;
-
- $($elemento+" .parte-primera").animate({left:"+=20px", opacity:1}, $tiempo_1).animate({left:"+=0px"}, $tiempo_pausa).animate({opacity:.0}, $tiempo_2).animate({left:"-=20px"}, 0);
- $($elemento+" .parte-segunda").animate({left:"-=20px", opacity:1}, $tiempo_1).animate({left:"+=0px"}, $tiempo_pausa).animate({opacity:.0}, $tiempo_2).animate({left:"+=20px"}, 0);
- }
And I am calling this function for two different elements:
- function animate_element(){
- animacion_frase("#frases-homepage #frase-1");
- animacion_frase("#frases-homepage #frase-2");
- animacion_frase("#frases-homepage #frase-3");
- setTimeout("animate_element()",9000);
- }
But I want to add a pause between the the two calls. If I use a setTimeout to call the second function it works, but nothing else happens.
- function animate_element(){
- animacion_frase("#frases-homepage #frase-1");
- setTimeout('animacion_frase("#frases-homepage #frase-2")', 3000);
- setTimeout('animacion_frase("#frases-homepage #frase-3")', 3000);
- setTimeout("animate_element()",9000);
- }
What am I doing wrong?
Thanks in advanced!