jQuery Cycle : Multiple Instances, detect end of each instance

Posted by guylabbe.ca on Stack Overflow See other posts from Stack Overflow or by guylabbe.ca
Published on 2012-06-10T22:36:17Z Indexed on 2012/06/10 22:39 UTC
Read the original article Hit count: 285

Filed under:
|

I am using multiple instances of Cycle for a portfolio; Only one is shown and the others are hidden. Each Cycle is a project with multiple images.

The only thing I can't figure out is how to detect the end of the « current » Cycle instance.

with after: function, it is triggered for all instances at once, impossible to get « local » events.

Here is my code :

    $('.sldr_closeup').each(function() {
    var currId = $(this).attr('id');
    window['num_'+currId] = 0;
    $(this).cycle({
        timeout:0,
        speed:500,
        fx:'fade',
        next:'.nextimages',
        prev:'.previmages',
        fit:1,
        nowrap:1,
        autstop:0,
        after : function(c,n,o,f) {

            var currId = $(this).parent('div').attr('id');

            (f) ? window['num_'+currId] ++ : window['num_'+currId] --;
            if ((o.slideCount == window['num_'+currId] )) {

                alert(currId);
                $('.nextimages').stop().fadeTo(400,0,function(){
                    if(currId != $('.projectList .projet').last().find('a').attr('rel'))
                        $('.nextproject').stop().fadeTo(400,1);
                    $(this).hide();

                });
            }
        }
    }).cycle('pause');

});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about cycle