Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript cant understnd this slider script

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #162735
    sameershaik
    Participant

    $(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?

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.