I'm trying to create a homepage with a changing background. Right now, I have it set so that the body itself holds the background image, and I simply want one image to fade to the next and then cycle through to the beginning.
My first issue: it isn't working. Period. My second issue: if it did work, it would probably instantly transition to the next one before delaying on the interval...how can I prevent this?
Following is my code, which is found at the bottom of the tags on the html document:
$(window).load(function() {
var current_scene = 0;
setInterval(function() {
if (current_scene == 0) {
var current_scene = 1;
$(body).animate({
backgroundImage: 'url(...)'
},400);
} else if (current_scene == 1) {
var current_scene = 2;
$(body).animate({
backgroundImage: 'url(...)'
},400);
} else {
var current_scene = 0;
$(body).animate({
backgroundImage: 'url(...)'
},400);
}
}, 3000);
});
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire