I use a background image slider to rotate between two background images. I works but there is one problem.
When it switches between the two images, there is a point where the screen is white. Yes its only a spit second, but it would be nice if one image fades in as the other fades out. What can I do to fix this problem.
$(document).ready(function(){
var imgArr = new Array(
'images/home/background_image_1.jpg',
'images/home/background_image_2.jpg'
);
var preloadArr = new Array();
var i;
/* preload images */
for(i=0; i < imgArr.length; i++){
preloadArr[i] = new Image();
preloadArr[i].src = imgArr[i];
}
var currImg = 1;
var intID = setInterval(changeImg, 20000);
/* image rotator */
function changeImg(){
$('#background-image').fadeOut(1500, function(){
$(this).css('background','url(' + preloadArr[currImg++%preloadArr.length].src +')') .css("background-position", "center").css("background-repeat", "no-repeat").css("background-size", "cover");
}).fadeIn(1500);
}
});