How can I 开发者_运维问答get this animation sequence to repeat after a delay of 5 seconds?
function homeanimation(){
$('#identity-text-01').fadeIn(1000).delay(2000).fadeOut(1000);
$('#identity-image-01').delay(2000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#print-text-01').delay(6000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#print-image-01').delay(7000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#web-text-01').delay(12000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#web-image-01').delay(13000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#wayfinding-text-01').delay(18000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#wayfinding-image-01').delay(19000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#exhibit-text-01').delay(24000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#exhibit-image-01').delay(25000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#recognition-text-01').delay(30000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#recognition-image-01').delay(31000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#packaging-text-01').delay(36000).fadeIn(1000).delay(2000).fadeOut(1000);
$('#packaging-image-01').delay(37000).fadeIn(1000).delay(2000);
};
homeanimation();
Thanks for your help!
Change the last line:
$('#packaging-image-01').delay(37000).fadeIn(1000).delay(2000);
to:
$('#packaging-image-01').delay(37000).fadeIn(1000).delay(2000);
setTimeout('homeanimation()', 5000);
You can delay the execution of any code in javascript by setting a timeout:
function MyAlert(msg) {
alert(msg);
}
//By using a function object as the first parameter
//any variables you need to use/pass will still be in scope
var msg = "Hey there!";
var delay = 5000; //the delay in milliseconds to wait (in this case 5 seconds)
setTimeout(function() { MyAlert(msg); }, delay);
精彩评论