$(document).ready(function() {
rotatePics(1);
}
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);
});
//till here actual of jquery//
//from here my explanation starts//
1st step:
here value of
currentPhoto = 1;
let numberOfPhotos = 5;
currentPhoto = 1 % 5 = 0 (modulus value);
2nd step:
$(‘#photos img’).eq(0).fadeOut(function(){
$(‘photos img’).each(function(i){
$(this).css(‘z-index’, ( (5-1) + 0) % 5);
its z-index = 1;
})
$(this).show();
setTimeout(function() {rotatePics(++currentPhoto);}, 4000);
}
pls tell he how z-index value is reordering?