0
votes

So here is my cycle declaration:

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('.prev')[index == 0 ? 'hide' : 'show']();
    $('.next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}

$(function() {
    $('#slideshow').cycle({
        pager:  '#nav',
        prev:   '.prev',
        next:   '.next',
        after:   onAfter,
    }).cycle('pause');
});

and i want add active class function on after: option. I want to keep both functions in after:

this is the active class function:

$('#slideshow').cycle({
    after: function(el, next_el) {
        $(next_el).addClass('active');
    },
    before: function(el) {
        $(el).removeClass('active');
    }
});

thanks for the help!

1

1 Answers

0
votes

You can combine the two after functions by adding the second to yours and using the appropriate parameter:

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('.prev')[index == 0 ? 'hide' : 'show']();
    $('.next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
    $(next).addClass('active');
}