3
The following code makes an "image Fader" in a div
that I have in my document. However, the effect is very 'dry', I would like to have a transition during the image exchange, like the "fade" effect of jQuery.
var images = ['image-1.jpg','image-2.jpg','image-3.jpg','image-4.jpg','image-5.jpg','image-6.jpg'],
index = 0,
maxImages = images.length - 1;
var timer = setInterval(function() {
var curImage = images[index];
index = (index == maxImages) ? 0 : ++index;
$('.header').css({'background-image':'url(./img/'+curImage+')'});
}, 1500);
How could I do?
Follow a fiddle with a small example.
What kind of transition do you expect to achieve? One image erasing and then the other appearing, one image "transforming" into the other... I believe it is possible to do this, but not with
background-image
- according to that answer in Soen, no customizable properties onbackground-image
, then you will have to "simulate" a background using another element (and in that yes, apply transition effects).– mgibsonbr