I'm making a responsive website with some parallax images and the very first image is meant to be a cycling image, like an image slider. I am using jquery Cool kitten for its responsiveness.
The related jquery plugins i have loaded are:
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
The css for the div is:
#slide2 {
background-image:url(../images/darkmap.png);
height:700px;
}
I have found that using HTML images for the background with this layout can be problematic, which is why i'm avoiding that by using an array:
var imageIndex = 0;
var imagesArray = [
"images/photo1.png",
"images/photo2.png",
"images/photo3.png"
];
I have a code wrapped in a $(document).ready()
function that changes the css background to the array and then cycles through the array and I added fadeIn()
for a smooth transition:
function changeImage(){
var index = imageIndex++ % imagesArray.length;
$("#slide2").css("background","url('"+ imagesArray[index] +"')");
}
setInterval(changeImage, 5000);
changeImage.fadeIn();
The image cycle is working fine, but for some reason the fadeIn()
is not working, it just blinks from one image to the other. Can someone please tell me what I am missing?