J'ai une animation flash simple que j'essaye de reconstruire avec jQuery. J'ai 5 animations qui sont chaînées pour démarrer l'une après l'autre. Après que toutes les animations se soient déclenchées, j'en ai besoin pour faire une pause pendant 5 secondes, se libérer et recommencer l'animation. J'ai besoin de le faire indéfiniment. Voici mon code:jQuery répéter des animations dans les fonctions
$(".bars").ready(function() {
$(".barone").animate({
'height': '49px'
}, 2000, function() {
$(".bartwo").animate({
'height': '112px'
}, 2000, function() {
$(".barthree").animate({
'height': '174px'
}, 2000, function() {
$(".barfour").animate({
'height': '236px'
}, 2000, function() {
$(".barfive").animate({
'height': '298px'
}, 2000, function() {
$('.bars div').delay(5000, function() {
$('.bars div').css({
"height": "0"
});
});
});
});
});
});
});
});
S'il vous plaît pardonnez ma mise en forme source, ce champ de texte n'est pas d'accord avec moi.
Vous pouvez également voir l'exemple à: http://execusite.com/fazio/files/careers-banner/test.html
Toute aide est grandement appréciée
Serait-ce correct alors?
animateThis fonction() { $ (» bars div:. Nième enfant (1) "). Animent ({ 'height': '49px'}, 2000, function() { $ (" barres. div: nth-child (2) "). animate ({'height': '112px'}, 2000, function() { $ (". bars div: nth-enfant (3) "). animate ({' hauteur ':' 174px '}, 2000, function() { $. ("bars div. nième enfant (4)") animer ({ 'height': '236px'}, 2000, function() { $ ("barres div. nième enfant (5)"). animate ({ 'height': '298px'}, 2000, function() {
$ ('barres div') retard (2000).. css ({ "hauteur": "0"}), la fonction() {animateThis()}; }); }); });
}); }); } $ (".bar"). Ready (function() {animateThis()});
Je présente mes excuses pour mon ignorance, je suis un peu nouveau pour jQuery et en essayant toujours de saisir la syntaxe.
Lorsque vous modifiez un message, vous pouvez sélectionner une région, puis cliquez sur le petit « 1010 » pour « tiret 4 espaces ». –
Merci beaucoup! –
vous pouvez certainement améliorer le code, généraliser le code et l'appeler à partir d'une fonction – kobe