jQuery Novice to Ninja: Understanding math for crossfade slideshow

I’m having some difficulty understanding the math behind the crossfade slideshow on page 114.

If anyone can explain how this math works please let me know.

Thanks


$(document).ready(function(){
	rotatePics(0);
});

function rotatePics(currentPhoto) {
  var numberOfPhotos = $('#photos img').length;
  currentPhoto = currentPhoto % numberOfPhotos;
	
	$('#photos img').eq(currentPhoto).fadeOut(function() {
		// re-order the z-index
		$('#photos img').each(function(i) {
      		$(this).css(
        		'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
      		);
    	});

		$(this).show();
  		setTimeout(function() {rotatePics(++currentPhoto);}, 4000);
	});
}


Hey Jack, I haven’t done this yet but I think the concept is to stack the images then use the z-index in your css file to change which image is on top of the stack. It fades in every 4 seconds

(4000)

Is this what you mean. I’m a little confused as to what you are asking.