firing code on the last gallery item
  • Hey,
    I'm having some difficulty getting some code to fire when pretty photo reaches its last slideshow frame.

    So I'm trying to hide all of the lightboxes controls and then flip through each image in the gallery. The number of gallery items could change so I'm trying to execute some code only when the loop reaches its last fire to show the controls again. (CODE BELOW)

    PROBLEM: seems to be with the way JS is incrementing the variable for the loop. if I alert that variable, it reaches 5 everytime the loop runs, so the nested if statement (if (i==numItems)) fires each time the loop does.
    Personally I would've assumed that after the first image is shown then i=1 or 0 whatever, and then the second time the loop ran i=2 and so on untill the script reaches the end.
    Is there a way to achieve that kind of functionality in JS or am I barking up the wrong tree?


    I can;t think of a way to inject another event into the last gallery item so I'm stumped at the moment, any help would be much apprieciated!



    //hide the controls
    $('.pp_close, .pp_arrow_next, .pp_arrow_previous').hide();
    //number of items in the gallery
    var numItems = $('ul.gallery li').length;
    //loop prettyPhotos next image function with a delay
    var i=1;
    for (i=1;i

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!