/*! carousel transition plugin for Cycle2; version: 20130108 */ (function($) { "use strict"; $( document ).on('cycle-bootstrap', function( e, opts, API ) { if ( opts.fx !== 'carousel' ) return; API.getSlideIndex = function( el ) { var slides = this.opts()._carouselWrap.children(); var i = slides.index( el ); return i % slides.length; }; // override default 'next' function API.next = function() { var count = opts.reverse ? -1 : 1; if ( opts.allowWrap === false && ( opts.currSlide + count ) > opts.slideCount - opts.carouselVisible ) return; opts.API.advanceSlide( count ); opts.API.trigger('cycle-next', [ opts ]).log('cycle-next'); }; }); $.fn.cycle.transitions.carousel = { // transition API impl preInit: function( opts ) { opts.hideNonActive = false; opts.container.on('cycle-destroyed', $.proxy(this.onDestroy, opts.API)); // override default API implementation opts.API.stopTransition = this.stopTransition; // issue #10 for (var i=0; i < opts.startingSlide; i++) { opts.container.append( opts.slides[0] ); } }, // transition API impl postInit: function( opts ) { var pagerCutoffIndex, wrap; var vert = opts.carouselVertical; if (opts.carouselVisible && opts.carouselVisible > opts.slideCount) opts.carouselVisible = opts.slideCount - 1; var visCount = opts.carouselVisible || opts.slides.length; var slideCSS = { display: vert ? 'block' : 'inline-block', position: 'static' }; // required styles opts.container.css({ position: 'relative', overflow: 'hidden' }); opts.slides.css( slideCSS ); opts._currSlide = opts.currSlide; // wrap slides in a div; this div is what is animated wrap = $('