I\'m looking to use jQuery to remove the need of using a GIF\'s to create a fairly simple animation.
What I want is an image to have four stages. 1) Nothing showing
This is much easier and maintains chain-ability:
JQuery:
$(document).ready(function(){
//rotator - delay, children
$('#slideshow').rotator(50, 'img');
});
Markup:
Plugin:
(function( $ ){
$.fn.rotator = function(delay, child){
//set curImage val
var currImg = 0;
var currIt = true;
//set array of images
var ss = $('#slideshow').children(child);
var ssize = ss.size();
setInterval(function() {
if(currIt){
$(ss[currImg]).css('opacity','1');
currIt = !currIt;
}else if (!currIt){
$(ss[currImg]).css('opacity','0');
$(ss[currImg+1]).css('opacity','1');
currIt = !currIt;
currImg++;
}
//reset
if(currImg >= ssize){
currImg = 0;
$(ss[currImg]).css('opacity','1');
}
}, delay);
return this;
};
})(jQuery);