I am trying to change the src of an existing image with a series of other images. I have got this working but the transition is terrible and not smooth at all. I guess this is because it abruptly loads the new image AFTER the initial one is faded out rather than at the same time.
Is there any clever way to make this transition completely smooth?
var images = new Array ('image1.jpg', 'image2.jpg', 'image3.jpg');
var index = 1;
function rotateImage()
{
$('.Parallax-host').children(':first-child').find('.Index-page-image img').fadeTo(1000,0.30, function()
{
$(this).attr('src', images[index]);
$(this).fadeTo(500,1, function()
{
if (index == images.length-1)
{
index = 0;
}
else
{
index++;
}
});
});
}
$(document).ready(function()
{
setInterval (rotateImage, 5000);
});
I dont have access to the markup here so it needs to be a jquery only solution.