dahngeek
12/6/2013 - 12:59 AM

Responsive jQuery Cycle slider

Responsive jQuery Cycle slider

var activeSlide;

$(document).ready(function() {

$('.cycle').cycle({
    containerResize: 1,
    width: 'fit',
    after: function(curr, next, obj) {
        activeSlide = obj.currSlide;
    }
});

$(window).resize(function(){
    $('.cycle').cycle('destroy');
    $('.cycle').each(function(){
        newWidth = $(this).parent('div').width();
        $(this).width(newWidth);
        $(this).height('auto');
        $(this).children('div').width(newWidth);
        $(this).children('div').height('auto');
    });
    $('.cycle').cycle({
        containerResize: 1,
        width: 'fit',
        after: function(curr, next, obj) {
            activeSlide = obj.currSlide;
        },
        startingSlide: activeSlide
    });
});

});