Chris@5: /*! Chris@5: * jQuery Cycle Plugin (with Transition Definitions) Chris@5: * Examples and documentation at: http://jquery.malsup.com/cycle/ Chris@5: * Copyright (c) 2007-2013 M. Alsup Chris@5: * Version: 3.0.3 (11-JUL-2013) Chris@5: * Dual licensed under the MIT and GPL licenses. Chris@5: * http://jquery.malsup.com/license.html Chris@5: * Requires: jQuery v1.7.1 or later Chris@5: */ Chris@5: ;(function($, undefined) { Chris@5: "use strict"; Chris@5: Chris@5: var ver = '3.0.3'; Chris@5: Chris@5: function debug(s) { Chris@5: if ($.fn.cycle.debug) Chris@5: log(s); Chris@5: } Chris@5: function log() { Chris@5: /*global console */ Chris@5: if (window.console && console.log) Chris@5: console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); Chris@5: } Chris@5: $.expr[':'].paused = function(el) { Chris@5: return el.cyclePause; Chris@5: }; Chris@5: Chris@5: Chris@5: // the options arg can be... Chris@5: // a number - indicates an immediate transition should occur to the given slide index Chris@5: // a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc) Chris@5: // an object - properties to control the slideshow Chris@5: // Chris@5: // the arg2 arg can be... Chris@5: // the name of an fx (only used in conjunction with a numeric value for 'options') Chris@5: // the value true (only used in first arg == 'resume') and indicates Chris@5: // that the resume should occur immediately (not wait for next timeout) Chris@5: Chris@5: $.fn.cycle = function(options, arg2) { Chris@5: var o = { s: this.selector, c: this.context }; Chris@5: Chris@5: // in 1.3+ we can fix mistakes with the ready state Chris@5: if (this.length === 0 && options != 'stop') { Chris@5: if (!$.isReady && o.s) { Chris@5: log('DOM not ready, queuing slideshow'); Chris@5: $(function() { Chris@5: $(o.s,o.c).cycle(options,arg2); Chris@5: }); Chris@5: return this; Chris@5: } Chris@5: // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() Chris@5: log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); Chris@5: return this; Chris@5: } Chris@5: Chris@5: // iterate the matched nodeset Chris@5: return this.each(function() { Chris@5: var opts = handleArguments(this, options, arg2); Chris@5: if (opts === false) Chris@5: return; Chris@5: Chris@5: opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; Chris@5: Chris@5: // stop existing slideshow for this container (if there is one) Chris@5: if (this.cycleTimeout) Chris@5: clearTimeout(this.cycleTimeout); Chris@5: this.cycleTimeout = this.cyclePause = 0; Chris@5: this.cycleStop = 0; // issue #108 Chris@5: Chris@5: var $cont = $(this); Chris@5: var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); Chris@5: var els = $slides.get(); Chris@5: Chris@5: if (els.length < 2) { Chris@5: log('terminating; too few slides: ' + els.length); Chris@5: return; Chris@5: } Chris@5: Chris@5: var opts2 = buildOptions($cont, $slides, els, opts, o); Chris@5: if (opts2 === false) Chris@5: return; Chris@5: Chris@5: var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards); Chris@5: Chris@5: // if it's an auto slideshow, kick it off Chris@5: if (startTime) { Chris@5: startTime += (opts2.delay || 0); Chris@5: if (startTime < 10) Chris@5: startTime = 10; Chris@5: debug('first timeout: ' + startTime); Chris@5: this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards);}, startTime); Chris@5: } Chris@5: }); Chris@5: }; Chris@5: Chris@5: function triggerPause(cont, byHover, onPager) { Chris@5: var opts = $(cont).data('cycle.opts'); Chris@5: if (!opts) Chris@5: return; Chris@5: var paused = !!cont.cyclePause; Chris@5: if (paused && opts.paused) Chris@5: opts.paused(cont, opts, byHover, onPager); Chris@5: else if (!paused && opts.resumed) Chris@5: opts.resumed(cont, opts, byHover, onPager); Chris@5: } Chris@5: Chris@5: // process the args that were passed to the plugin fn Chris@5: function handleArguments(cont, options, arg2) { Chris@5: if (cont.cycleStop === undefined) Chris@5: cont.cycleStop = 0; Chris@5: if (options === undefined || options === null) Chris@5: options = {}; Chris@5: if (options.constructor == String) { Chris@5: switch(options) { Chris@5: case 'destroy': Chris@5: case 'stop': Chris@5: var opts = $(cont).data('cycle.opts'); Chris@5: if (!opts) Chris@5: return false; Chris@5: cont.cycleStop++; // callbacks look for change Chris@5: if (cont.cycleTimeout) Chris@5: clearTimeout(cont.cycleTimeout); Chris@5: cont.cycleTimeout = 0; Chris@5: if (opts.elements) Chris@5: $(opts.elements).stop(); Chris@5: $(cont).removeData('cycle.opts'); Chris@5: if (options == 'destroy') Chris@5: destroy(cont, opts); Chris@5: return false; Chris@5: case 'toggle': Chris@5: cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; Chris@5: checkInstantResume(cont.cyclePause, arg2, cont); Chris@5: triggerPause(cont); Chris@5: return false; Chris@5: case 'pause': Chris@5: cont.cyclePause = 1; Chris@5: triggerPause(cont); Chris@5: return false; Chris@5: case 'resume': Chris@5: cont.cyclePause = 0; Chris@5: checkInstantResume(false, arg2, cont); Chris@5: triggerPause(cont); Chris@5: return false; Chris@5: case 'prev': Chris@5: case 'next': Chris@5: opts = $(cont).data('cycle.opts'); Chris@5: if (!opts) { Chris@5: log('options not found, "prev/next" ignored'); Chris@5: return false; Chris@5: } Chris@5: if (typeof arg2 == 'string') Chris@5: opts.oneTimeFx = arg2; Chris@5: $.fn.cycle[options](opts); Chris@5: return false; Chris@5: default: Chris@5: options = { fx: options }; Chris@5: } Chris@5: return options; Chris@5: } Chris@5: else if (options.constructor == Number) { Chris@5: // go to the requested slide Chris@5: var num = options; Chris@5: options = $(cont).data('cycle.opts'); Chris@5: if (!options) { Chris@5: log('options not found, can not advance slide'); Chris@5: return false; Chris@5: } Chris@5: if (num < 0 || num >= options.elements.length) { Chris@5: log('invalid slide index: ' + num); Chris@5: return false; Chris@5: } Chris@5: options.nextSlide = num; Chris@5: if (cont.cycleTimeout) { Chris@5: clearTimeout(cont.cycleTimeout); Chris@5: cont.cycleTimeout = 0; Chris@5: } Chris@5: if (typeof arg2 == 'string') Chris@5: options.oneTimeFx = arg2; Chris@5: go(options.elements, options, 1, num >= options.currSlide); Chris@5: return false; Chris@5: } Chris@5: return options; Chris@5: Chris@5: function checkInstantResume(isPaused, arg2, cont) { Chris@5: if (!isPaused && arg2 === true) { // resume now! Chris@5: var options = $(cont).data('cycle.opts'); Chris@5: if (!options) { Chris@5: log('options not found, can not resume'); Chris@5: return false; Chris@5: } Chris@5: if (cont.cycleTimeout) { Chris@5: clearTimeout(cont.cycleTimeout); Chris@5: cont.cycleTimeout = 0; Chris@5: } Chris@5: go(options.elements, options, 1, !options.backwards); Chris@5: } Chris@5: } Chris@5: } Chris@5: Chris@5: function removeFilter(el, opts) { Chris@5: if (!$.support.opacity && opts.cleartype && el.style.filter) { Chris@5: try { el.style.removeAttribute('filter'); } Chris@5: catch(smother) {} // handle old opera versions Chris@5: } Chris@5: } Chris@5: Chris@5: // unbind event handlers Chris@5: function destroy(cont, opts) { Chris@5: if (opts.next) Chris@5: $(opts.next).unbind(opts.prevNextEvent); Chris@5: if (opts.prev) Chris@5: $(opts.prev).unbind(opts.prevNextEvent); Chris@5: Chris@5: if (opts.pager || opts.pagerAnchorBuilder) Chris@5: $.each(opts.pagerAnchors || [], function() { Chris@5: this.unbind().remove(); Chris@5: }); Chris@5: opts.pagerAnchors = null; Chris@5: $(cont).unbind('mouseenter.cycle mouseleave.cycle'); Chris@5: if (opts.destroy) // callback Chris@5: opts.destroy(opts); Chris@5: } Chris@5: Chris@5: // one-time initialization Chris@5: function buildOptions($cont, $slides, els, options, o) { Chris@5: var startingSlideSpecified; Chris@5: // support metadata plugin (v1.0 and v2.0) Chris@5: var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); Chris@5: var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null; Chris@5: if (meta) Chris@5: opts = $.extend(opts, meta); Chris@5: if (opts.autostop) Chris@5: opts.countdown = opts.autostopCount || els.length; Chris@5: Chris@5: var cont = $cont[0]; Chris@5: $cont.data('cycle.opts', opts); Chris@5: opts.$cont = $cont; Chris@5: opts.stopCount = cont.cycleStop; Chris@5: opts.elements = els; Chris@5: opts.before = opts.before ? [opts.before] : []; Chris@5: opts.after = opts.after ? [opts.after] : []; Chris@5: Chris@5: // push some after callbacks Chris@5: if (!$.support.opacity && opts.cleartype) Chris@5: opts.after.push(function() { removeFilter(this, opts); }); Chris@5: if (opts.continuous) Chris@5: opts.after.push(function() { go(els,opts,0,!opts.backwards); }); Chris@5: Chris@5: saveOriginalOpts(opts); Chris@5: Chris@5: // clearType corrections Chris@5: if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) Chris@5: clearTypeFix($slides); Chris@5: Chris@5: // container requires non-static position so that slides can be position within Chris@5: if ($cont.css('position') == 'static') Chris@5: $cont.css('position', 'relative'); Chris@5: if (opts.width) Chris@5: $cont.width(opts.width); Chris@5: if (opts.height && opts.height != 'auto') Chris@5: $cont.height(opts.height); Chris@5: Chris@5: if (opts.startingSlide !== undefined) { Chris@5: opts.startingSlide = parseInt(opts.startingSlide,10); Chris@5: if (opts.startingSlide >= els.length || opts.startSlide < 0) Chris@5: opts.startingSlide = 0; // catch bogus input Chris@5: else Chris@5: startingSlideSpecified = true; Chris@5: } Chris@5: else if (opts.backwards) Chris@5: opts.startingSlide = els.length - 1; Chris@5: else Chris@5: opts.startingSlide = 0; Chris@5: Chris@5: // if random, mix up the slide array Chris@5: if (opts.random) { Chris@5: opts.randomMap = []; Chris@5: for (var i = 0; i < els.length; i++) Chris@5: opts.randomMap.push(i); Chris@5: opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); Chris@5: if (startingSlideSpecified) { Chris@5: // try to find the specified starting slide and if found set start slide index in the map accordingly Chris@5: for ( var cnt = 0; cnt < els.length; cnt++ ) { Chris@5: if ( opts.startingSlide == opts.randomMap[cnt] ) { Chris@5: opts.randomIndex = cnt; Chris@5: } Chris@5: } Chris@5: } Chris@5: else { Chris@5: opts.randomIndex = 1; Chris@5: opts.startingSlide = opts.randomMap[1]; Chris@5: } Chris@5: } Chris@5: else if (opts.startingSlide >= els.length) Chris@5: opts.startingSlide = 0; // catch bogus input Chris@5: opts.currSlide = opts.startingSlide || 0; Chris@5: var first = opts.startingSlide; Chris@5: Chris@5: // set position and zIndex on all the slides Chris@5: $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { Chris@5: var z; Chris@5: if (opts.backwards) Chris@5: z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i; Chris@5: else Chris@5: z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; Chris@5: $(this).css('z-index', z); Chris@5: }); Chris@5: Chris@5: // make sure first slide is visible Chris@5: $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case Chris@5: removeFilter(els[first], opts); Chris@5: Chris@5: // stretch slides Chris@5: if (opts.fit) { Chris@5: if (!opts.aspect) { Chris@5: if (opts.width) Chris@5: $slides.width(opts.width); Chris@5: if (opts.height && opts.height != 'auto') Chris@5: $slides.height(opts.height); Chris@5: } else { Chris@5: $slides.each(function(){ Chris@5: var $slide = $(this); Chris@5: var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect; Chris@5: if( opts.width && $slide.width() != opts.width ) { Chris@5: $slide.width( opts.width ); Chris@5: $slide.height( opts.width / ratio ); Chris@5: } Chris@5: Chris@5: if( opts.height && $slide.height() < opts.height ) { Chris@5: $slide.height( opts.height ); Chris@5: $slide.width( opts.height * ratio ); Chris@5: } Chris@5: }); Chris@5: } Chris@5: } Chris@5: Chris@5: if (opts.center && ((!opts.fit) || opts.aspect)) { Chris@5: $slides.each(function(){ Chris@5: var $slide = $(this); Chris@5: $slide.css({ Chris@5: "margin-left": opts.width ? Chris@5: ((opts.width - $slide.width()) / 2) + "px" : Chris@5: 0, Chris@5: "margin-top": opts.height ? Chris@5: ((opts.height - $slide.height()) / 2) + "px" : Chris@5: 0 Chris@5: }); Chris@5: }); Chris@5: } Chris@5: Chris@5: if (opts.center && !opts.fit && !opts.slideResize) { Chris@5: $slides.each(function(){ Chris@5: var $slide = $(this); Chris@5: $slide.css({ Chris@5: "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0, Chris@5: "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0 Chris@5: }); Chris@5: }); Chris@5: } Chris@5: Chris@5: // stretch container Chris@5: var reshape = (opts.containerResize || opts.containerResizeHeight) && $cont.innerHeight() < 1; Chris@5: if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 Chris@5: var maxw = 0, maxh = 0; Chris@5: for(var j=0; j < els.length; j++) { Chris@5: var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); Chris@5: if (!w) w = e.offsetWidth || e.width || $e.attr('width'); Chris@5: if (!h) h = e.offsetHeight || e.height || $e.attr('height'); Chris@5: maxw = w > maxw ? w : maxw; Chris@5: maxh = h > maxh ? h : maxh; Chris@5: } Chris@5: if (opts.containerResize && maxw > 0 && maxh > 0) Chris@5: $cont.css({width:maxw+'px',height:maxh+'px'}); Chris@5: if (opts.containerResizeHeight && maxh > 0) Chris@5: $cont.css({height:maxh+'px'}); Chris@5: } Chris@5: Chris@5: var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 Chris@5: if (opts.pause) Chris@5: $cont.bind('mouseenter.cycle', function(){ Chris@5: pauseFlag = true; Chris@5: this.cyclePause++; Chris@5: triggerPause(cont, true); Chris@5: }).bind('mouseleave.cycle', function(){ Chris@5: if (pauseFlag) Chris@5: this.cyclePause--; Chris@5: triggerPause(cont, true); Chris@5: }); Chris@5: Chris@5: if (supportMultiTransitions(opts) === false) Chris@5: return false; Chris@5: Chris@5: // apparently a lot of people use image slideshows without height/width attributes on the images. Chris@5: // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. Chris@5: var requeue = false; Chris@5: options.requeueAttempts = options.requeueAttempts || 0; Chris@5: $slides.each(function() { Chris@5: // try to get height/width of each slide Chris@5: var $el = $(this); Chris@5: this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0); Chris@5: this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0); Chris@5: Chris@5: if ( $el.is('img') ) { Chris@5: var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete); Chris@5: // don't requeue for images that are still loading but have a valid size Chris@5: if (loading) { Chris@5: if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever Chris@5: log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH); Chris@5: setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout); Chris@5: requeue = true; Chris@5: return false; // break each loop Chris@5: } Chris@5: else { Chris@5: log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); Chris@5: } Chris@5: } Chris@5: } Chris@5: return true; Chris@5: }); Chris@5: Chris@5: if (requeue) Chris@5: return false; Chris@5: Chris@5: opts.cssBefore = opts.cssBefore || {}; Chris@5: opts.cssAfter = opts.cssAfter || {}; Chris@5: opts.cssFirst = opts.cssFirst || {}; Chris@5: opts.animIn = opts.animIn || {}; Chris@5: opts.animOut = opts.animOut || {}; Chris@5: Chris@5: $slides.not(':eq('+first+')').css(opts.cssBefore); Chris@5: $($slides[first]).css(opts.cssFirst); Chris@5: Chris@5: if (opts.timeout) { Chris@5: opts.timeout = parseInt(opts.timeout,10); Chris@5: // ensure that timeout and speed settings are sane Chris@5: if (opts.speed.constructor == String) Chris@5: opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10); Chris@5: if (!opts.sync) Chris@5: opts.speed = opts.speed / 2; Chris@5: Chris@5: var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250; Chris@5: while((opts.timeout - opts.speed) < buffer) // sanitize timeout Chris@5: opts.timeout += opts.speed; Chris@5: } Chris@5: if (opts.easing) Chris@5: opts.easeIn = opts.easeOut = opts.easing; Chris@5: if (!opts.speedIn) Chris@5: opts.speedIn = opts.speed; Chris@5: if (!opts.speedOut) Chris@5: opts.speedOut = opts.speed; Chris@5: Chris@5: opts.slideCount = els.length; Chris@5: opts.currSlide = opts.lastSlide = first; Chris@5: if (opts.random) { Chris@5: if (++opts.randomIndex == els.length) Chris@5: opts.randomIndex = 0; Chris@5: opts.nextSlide = opts.randomMap[opts.randomIndex]; Chris@5: } Chris@5: else if (opts.backwards) Chris@5: opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1; Chris@5: else Chris@5: opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; Chris@5: Chris@5: // run transition init fn Chris@5: if (!opts.multiFx) { Chris@5: var init = $.fn.cycle.transitions[opts.fx]; Chris@5: if ($.isFunction(init)) Chris@5: init($cont, $slides, opts); Chris@5: else if (opts.fx != 'custom' && !opts.multiFx) { Chris@5: log('unknown transition: ' + opts.fx,'; slideshow terminating'); Chris@5: return false; Chris@5: } Chris@5: } Chris@5: Chris@5: // fire artificial events Chris@5: var e0 = $slides[first]; Chris@5: if (!opts.skipInitializationCallbacks) { Chris@5: if (opts.before.length) Chris@5: opts.before[0].apply(e0, [e0, e0, opts, true]); Chris@5: if (opts.after.length) Chris@5: opts.after[0].apply(e0, [e0, e0, opts, true]); Chris@5: } Chris@5: if (opts.next) Chris@5: $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1);}); Chris@5: if (opts.prev) Chris@5: $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0);}); Chris@5: if (opts.pager || opts.pagerAnchorBuilder) Chris@5: buildPager(els,opts); Chris@5: Chris@5: exposeAddSlide(opts, els); Chris@5: Chris@5: return opts; Chris@5: } Chris@5: Chris@5: // save off original opts so we can restore after clearing state Chris@5: function saveOriginalOpts(opts) { Chris@5: opts.original = { before: [], after: [] }; Chris@5: opts.original.cssBefore = $.extend({}, opts.cssBefore); Chris@5: opts.original.cssAfter = $.extend({}, opts.cssAfter); Chris@5: opts.original.animIn = $.extend({}, opts.animIn); Chris@5: opts.original.animOut = $.extend({}, opts.animOut); Chris@5: $.each(opts.before, function() { opts.original.before.push(this); }); Chris@5: $.each(opts.after, function() { opts.original.after.push(this); }); Chris@5: } Chris@5: Chris@5: function supportMultiTransitions(opts) { Chris@5: var i, tx, txs = $.fn.cycle.transitions; Chris@5: // look for multiple effects Chris@5: if (opts.fx.indexOf(',') > 0) { Chris@5: opts.multiFx = true; Chris@5: opts.fxs = opts.fx.replace(/\s*/g,'').split(','); Chris@5: // discard any bogus effect names Chris@5: for (i=0; i < opts.fxs.length; i++) { Chris@5: var fx = opts.fxs[i]; Chris@5: tx = txs[fx]; Chris@5: if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { Chris@5: log('discarding unknown transition: ',fx); Chris@5: opts.fxs.splice(i,1); Chris@5: i--; Chris@5: } Chris@5: } Chris@5: // if we have an empty list then we threw everything away! Chris@5: if (!opts.fxs.length) { Chris@5: log('No valid transitions named; slideshow terminating.'); Chris@5: return false; Chris@5: } Chris@5: } Chris@5: else if (opts.fx == 'all') { // auto-gen the list of transitions Chris@5: opts.multiFx = true; Chris@5: opts.fxs = []; Chris@5: for (var p in txs) { Chris@5: if (txs.hasOwnProperty(p)) { Chris@5: tx = txs[p]; Chris@5: if (txs.hasOwnProperty(p) && $.isFunction(tx)) Chris@5: opts.fxs.push(p); Chris@5: } Chris@5: } Chris@5: } Chris@5: if (opts.multiFx && opts.randomizeEffects) { Chris@5: // munge the fxs array to make effect selection random Chris@5: var r1 = Math.floor(Math.random() * 20) + 30; Chris@5: for (i = 0; i < r1; i++) { Chris@5: var r2 = Math.floor(Math.random() * opts.fxs.length); Chris@5: opts.fxs.push(opts.fxs.splice(r2,1)[0]); Chris@5: } Chris@5: debug('randomized fx sequence: ',opts.fxs); Chris@5: } Chris@5: return true; Chris@5: } Chris@5: Chris@5: // provide a mechanism for adding slides after the slideshow has started Chris@5: function exposeAddSlide(opts, els) { Chris@5: opts.addSlide = function(newSlide, prepend) { Chris@5: var $s = $(newSlide), s = $s[0]; Chris@5: if (!opts.autostopCount) Chris@5: opts.countdown++; Chris@5: els[prepend?'unshift':'push'](s); Chris@5: if (opts.els) Chris@5: opts.els[prepend?'unshift':'push'](s); // shuffle needs this Chris@5: opts.slideCount = els.length; Chris@5: Chris@5: // add the slide to the random map and resort Chris@5: if (opts.random) { Chris@5: opts.randomMap.push(opts.slideCount-1); Chris@5: opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); Chris@5: } Chris@5: Chris@5: $s.css('position','absolute'); Chris@5: $s[prepend?'prependTo':'appendTo'](opts.$cont); Chris@5: Chris@5: if (prepend) { Chris@5: opts.currSlide++; Chris@5: opts.nextSlide++; Chris@5: } Chris@5: Chris@5: if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) Chris@5: clearTypeFix($s); Chris@5: Chris@5: if (opts.fit && opts.width) Chris@5: $s.width(opts.width); Chris@5: if (opts.fit && opts.height && opts.height != 'auto') Chris@5: $s.height(opts.height); Chris@5: s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); Chris@5: s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); Chris@5: Chris@5: $s.css(opts.cssBefore); Chris@5: Chris@5: if (opts.pager || opts.pagerAnchorBuilder) Chris@5: $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); Chris@5: Chris@5: if ($.isFunction(opts.onAddSlide)) Chris@5: opts.onAddSlide($s); Chris@5: else Chris@5: $s.hide(); // default behavior Chris@5: }; Chris@5: } Chris@5: Chris@5: // reset internal state; we do this on every pass in order to support multiple effects Chris@5: $.fn.cycle.resetState = function(opts, fx) { Chris@5: fx = fx || opts.fx; Chris@5: opts.before = []; opts.after = []; Chris@5: opts.cssBefore = $.extend({}, opts.original.cssBefore); Chris@5: opts.cssAfter = $.extend({}, opts.original.cssAfter); Chris@5: opts.animIn = $.extend({}, opts.original.animIn); Chris@5: opts.animOut = $.extend({}, opts.original.animOut); Chris@5: opts.fxFn = null; Chris@5: $.each(opts.original.before, function() { opts.before.push(this); }); Chris@5: $.each(opts.original.after, function() { opts.after.push(this); }); Chris@5: Chris@5: // re-init Chris@5: var init = $.fn.cycle.transitions[fx]; Chris@5: if ($.isFunction(init)) Chris@5: init(opts.$cont, $(opts.elements), opts); Chris@5: }; Chris@5: Chris@5: // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt Chris@5: function go(els, opts, manual, fwd) { Chris@5: var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; Chris@5: Chris@5: // opts.busy is true if we're in the middle of an animation Chris@5: if (manual && opts.busy && opts.manualTrump) { Chris@5: // let manual transitions requests trump active ones Chris@5: debug('manualTrump in go(), stopping active transition'); Chris@5: $(els).stop(true,true); Chris@5: opts.busy = 0; Chris@5: clearTimeout(p.cycleTimeout); Chris@5: } Chris@5: Chris@5: // don't begin another timeout-based transition if there is one active Chris@5: if (opts.busy) { Chris@5: debug('transition active, ignoring new tx request'); Chris@5: return; Chris@5: } Chris@5: Chris@5: Chris@5: // stop cycling if we have an outstanding stop request Chris@5: if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) Chris@5: return; Chris@5: Chris@5: // check to see if we should stop cycling based on autostop options Chris@5: if (!manual && !p.cyclePause && !opts.bounce && Chris@5: ((opts.autostop && (--opts.countdown <= 0)) || Chris@5: (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { Chris@5: if (opts.end) Chris@5: opts.end(opts); Chris@5: return; Chris@5: } Chris@5: Chris@5: // if slideshow is paused, only transition on a manual trigger Chris@5: var changed = false; Chris@5: if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { Chris@5: changed = true; Chris@5: var fx = opts.fx; Chris@5: // keep trying to get the slide size if we don't have it yet Chris@5: curr.cycleH = curr.cycleH || $(curr).height(); Chris@5: curr.cycleW = curr.cycleW || $(curr).width(); Chris@5: next.cycleH = next.cycleH || $(next).height(); Chris@5: next.cycleW = next.cycleW || $(next).width(); Chris@5: Chris@5: // support multiple transition types Chris@5: if (opts.multiFx) { Chris@5: if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length)) Chris@5: opts.lastFx = 0; Chris@5: else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0)) Chris@5: opts.lastFx = opts.fxs.length - 1; Chris@5: fx = opts.fxs[opts.lastFx]; Chris@5: } Chris@5: Chris@5: // one-time fx overrides apply to: $('div').cycle(3,'zoom'); Chris@5: if (opts.oneTimeFx) { Chris@5: fx = opts.oneTimeFx; Chris@5: opts.oneTimeFx = null; Chris@5: } Chris@5: Chris@5: $.fn.cycle.resetState(opts, fx); Chris@5: Chris@5: // run the before callbacks Chris@5: if (opts.before.length) Chris@5: $.each(opts.before, function(i,o) { Chris@5: if (p.cycleStop != opts.stopCount) return; Chris@5: o.apply(next, [curr, next, opts, fwd]); Chris@5: }); Chris@5: Chris@5: // stage the after callacks Chris@5: var after = function() { Chris@5: opts.busy = 0; Chris@5: $.each(opts.after, function(i,o) { Chris@5: if (p.cycleStop != opts.stopCount) return; Chris@5: o.apply(next, [curr, next, opts, fwd]); Chris@5: }); Chris@5: if (!p.cycleStop) { Chris@5: // queue next transition Chris@5: queueNext(); Chris@5: } Chris@5: }; Chris@5: Chris@5: debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide); Chris@5: Chris@5: // get ready to perform the transition Chris@5: opts.busy = 1; Chris@5: if (opts.fxFn) // fx function provided? Chris@5: opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); Chris@5: else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? Chris@5: $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); Chris@5: else Chris@5: $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); Chris@5: } Chris@5: else { Chris@5: queueNext(); Chris@5: } Chris@5: Chris@5: if (changed || opts.nextSlide == opts.currSlide) { Chris@5: // calculate the next slide Chris@5: var roll; Chris@5: opts.lastSlide = opts.currSlide; Chris@5: if (opts.random) { Chris@5: opts.currSlide = opts.nextSlide; Chris@5: if (++opts.randomIndex == els.length) { Chris@5: opts.randomIndex = 0; Chris@5: opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); Chris@5: } Chris@5: opts.nextSlide = opts.randomMap[opts.randomIndex]; Chris@5: if (opts.nextSlide == opts.currSlide) Chris@5: opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; Chris@5: } Chris@5: else if (opts.backwards) { Chris@5: roll = (opts.nextSlide - 1) < 0; Chris@5: if (roll && opts.bounce) { Chris@5: opts.backwards = !opts.backwards; Chris@5: opts.nextSlide = 1; Chris@5: opts.currSlide = 0; Chris@5: } Chris@5: else { Chris@5: opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1; Chris@5: opts.currSlide = roll ? 0 : opts.nextSlide+1; Chris@5: } Chris@5: } Chris@5: else { // sequence Chris@5: roll = (opts.nextSlide + 1) == els.length; Chris@5: if (roll && opts.bounce) { Chris@5: opts.backwards = !opts.backwards; Chris@5: opts.nextSlide = els.length-2; Chris@5: opts.currSlide = els.length-1; Chris@5: } Chris@5: else { Chris@5: opts.nextSlide = roll ? 0 : opts.nextSlide+1; Chris@5: opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; Chris@5: } Chris@5: } Chris@5: } Chris@5: if (changed && opts.pager) Chris@5: opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); Chris@5: Chris@5: function queueNext() { Chris@5: // stage the next transition Chris@5: var ms = 0, timeout = opts.timeout; Chris@5: if (opts.timeout && !opts.continuous) { Chris@5: ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd); Chris@5: if (opts.fx == 'shuffle') Chris@5: ms -= opts.speedOut; Chris@5: } Chris@5: else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic Chris@5: ms = 10; Chris@5: if (ms > 0) Chris@5: p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms); Chris@5: } Chris@5: } Chris@5: Chris@5: // invoked after transition Chris@5: $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) { Chris@5: $(pager).each(function() { Chris@5: $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); Chris@5: }); Chris@5: }; Chris@5: Chris@5: // calculate timeout value for current transition Chris@5: function getTimeout(curr, next, opts, fwd) { Chris@5: if (opts.timeoutFn) { Chris@5: // call user provided calc fn Chris@5: var t = opts.timeoutFn.call(curr,curr,next,opts,fwd); Chris@5: while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout Chris@5: t += opts.speed; Chris@5: debug('calculated timeout: ' + t + '; speed: ' + opts.speed); Chris@5: if (t !== false) Chris@5: return t; Chris@5: } Chris@5: return opts.timeout; Chris@5: } Chris@5: Chris@5: // expose next/prev function, caller must pass in state Chris@5: $.fn.cycle.next = function(opts) { advance(opts,1); }; Chris@5: $.fn.cycle.prev = function(opts) { advance(opts,0);}; Chris@5: Chris@5: // advance slide forward or back Chris@5: function advance(opts, moveForward) { Chris@5: var val = moveForward ? 1 : -1; Chris@5: var els = opts.elements; Chris@5: var p = opts.$cont[0], timeout = p.cycleTimeout; Chris@5: if (timeout) { Chris@5: clearTimeout(timeout); Chris@5: p.cycleTimeout = 0; Chris@5: } Chris@5: if (opts.random && val < 0) { Chris@5: // move back to the previously display slide Chris@5: opts.randomIndex--; Chris@5: if (--opts.randomIndex == -2) Chris@5: opts.randomIndex = els.length-2; Chris@5: else if (opts.randomIndex == -1) Chris@5: opts.randomIndex = els.length-1; Chris@5: opts.nextSlide = opts.randomMap[opts.randomIndex]; Chris@5: } Chris@5: else if (opts.random) { Chris@5: opts.nextSlide = opts.randomMap[opts.randomIndex]; Chris@5: } Chris@5: else { Chris@5: opts.nextSlide = opts.currSlide + val; Chris@5: if (opts.nextSlide < 0) { Chris@5: if (opts.nowrap) return false; Chris@5: opts.nextSlide = els.length - 1; Chris@5: } Chris@5: else if (opts.nextSlide >= els.length) { Chris@5: if (opts.nowrap) return false; Chris@5: opts.nextSlide = 0; Chris@5: } Chris@5: } Chris@5: Chris@5: var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated Chris@5: if ($.isFunction(cb)) Chris@5: cb(val > 0, opts.nextSlide, els[opts.nextSlide]); Chris@5: go(els, opts, 1, moveForward); Chris@5: return false; Chris@5: } Chris@5: Chris@5: function buildPager(els, opts) { Chris@5: var $p = $(opts.pager); Chris@5: $.each(els, function(i,o) { Chris@5: $.fn.cycle.createPagerAnchor(i,o,$p,els,opts); Chris@5: }); Chris@5: opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); Chris@5: } Chris@5: Chris@5: $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { Chris@5: var a; Chris@5: if ($.isFunction(opts.pagerAnchorBuilder)) { Chris@5: a = opts.pagerAnchorBuilder(i,el); Chris@5: debug('pagerAnchorBuilder('+i+', el) returned: ' + a); Chris@5: } Chris@5: else Chris@5: a = ''+(i+1)+''; Chris@5: Chris@5: if (!a) Chris@5: return; Chris@5: var $a = $(a); Chris@5: // don't reparent if anchor is in the dom Chris@5: if ($a.parents('body').length === 0) { Chris@5: var arr = []; Chris@5: if ($p.length > 1) { Chris@5: $p.each(function() { Chris@5: var $clone = $a.clone(true); Chris@5: $(this).append($clone); Chris@5: arr.push($clone[0]); Chris@5: }); Chris@5: $a = $(arr); Chris@5: } Chris@5: else { Chris@5: $a.appendTo($p); Chris@5: } Chris@5: } Chris@5: Chris@5: opts.pagerAnchors = opts.pagerAnchors || []; Chris@5: opts.pagerAnchors.push($a); Chris@5: Chris@5: var pagerFn = function(e) { Chris@5: e.preventDefault(); Chris@5: opts.nextSlide = i; Chris@5: var p = opts.$cont[0], timeout = p.cycleTimeout; Chris@5: if (timeout) { Chris@5: clearTimeout(timeout); Chris@5: p.cycleTimeout = 0; Chris@5: } Chris@5: var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated Chris@5: if ($.isFunction(cb)) Chris@5: cb(opts.nextSlide, els[opts.nextSlide]); Chris@5: go(els,opts,1,opts.currSlide < i); // trigger the trans Chris@5: // return false; // <== allow bubble Chris@5: }; Chris@5: Chris@5: if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) { Chris@5: $a.hover(pagerFn, function(){/* no-op */} ); Chris@5: } Chris@5: else { Chris@5: $a.bind(opts.pagerEvent, pagerFn); Chris@5: } Chris@5: Chris@5: if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) Chris@5: $a.bind('click.cycle', function(){return false;}); // suppress click Chris@5: Chris@5: var cont = opts.$cont[0]; Chris@5: var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 Chris@5: if (opts.pauseOnPagerHover) { Chris@5: $a.hover( Chris@5: function() { Chris@5: pauseFlag = true; Chris@5: cont.cyclePause++; Chris@5: triggerPause(cont,true,true); Chris@5: }, function() { Chris@5: if (pauseFlag) Chris@5: cont.cyclePause--; Chris@5: triggerPause(cont,true,true); Chris@5: } Chris@5: ); Chris@5: } Chris@5: }; Chris@5: Chris@5: // helper fn to calculate the number of slides between the current and the next Chris@5: $.fn.cycle.hopsFromLast = function(opts, fwd) { Chris@5: var hops, l = opts.lastSlide, c = opts.currSlide; Chris@5: if (fwd) Chris@5: hops = c > l ? c - l : opts.slideCount - l; Chris@5: else Chris@5: hops = c < l ? l - c : l + opts.slideCount - c; Chris@5: return hops; Chris@5: }; Chris@5: Chris@5: // fix clearType problems in ie6 by setting an explicit bg color Chris@5: // (otherwise text slides look horrible during a fade transition) Chris@5: function clearTypeFix($slides) { Chris@5: debug('applying clearType background-color hack'); Chris@5: function hex(s) { Chris@5: s = parseInt(s,10).toString(16); Chris@5: return s.length < 2 ? '0'+s : s; Chris@5: } Chris@5: function getBg(e) { Chris@5: for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { Chris@5: var v = $.css(e,'background-color'); Chris@5: if (v && v.indexOf('rgb') >= 0 ) { Chris@5: var rgb = v.match(/\d+/g); Chris@5: return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); Chris@5: } Chris@5: if (v && v != 'transparent') Chris@5: return v; Chris@5: } Chris@5: return '#ffffff'; Chris@5: } Chris@5: $slides.each(function() { $(this).css('background-color', getBg(this)); }); Chris@5: } Chris@5: Chris@5: // reset common props before the next transition Chris@5: $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) { Chris@5: $(opts.elements).not(curr).hide(); Chris@5: if (typeof opts.cssBefore.opacity == 'undefined') Chris@5: opts.cssBefore.opacity = 1; Chris@5: opts.cssBefore.display = 'block'; Chris@5: if (opts.slideResize && w !== false && next.cycleW > 0) Chris@5: opts.cssBefore.width = next.cycleW; Chris@5: if (opts.slideResize && h !== false && next.cycleH > 0) Chris@5: opts.cssBefore.height = next.cycleH; Chris@5: opts.cssAfter = opts.cssAfter || {}; Chris@5: opts.cssAfter.display = 'none'; Chris@5: $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0)); Chris@5: $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1)); Chris@5: }; Chris@5: Chris@5: // the actual fn for effecting a transition Chris@5: $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) { Chris@5: var $l = $(curr), $n = $(next); Chris@5: var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut, animInDelay = opts.animInDelay, animOutDelay = opts.animOutDelay; Chris@5: $n.css(opts.cssBefore); Chris@5: if (speedOverride) { Chris@5: if (typeof speedOverride == 'number') Chris@5: speedIn = speedOut = speedOverride; Chris@5: else Chris@5: speedIn = speedOut = 1; Chris@5: easeIn = easeOut = null; Chris@5: } Chris@5: var fn = function() { Chris@5: $n.delay(animInDelay).animate(opts.animIn, speedIn, easeIn, function() { Chris@5: cb(); Chris@5: }); Chris@5: }; Chris@5: $l.delay(animOutDelay).animate(opts.animOut, speedOut, easeOut, function() { Chris@5: $l.css(opts.cssAfter); Chris@5: if (!opts.sync) Chris@5: fn(); Chris@5: }); Chris@5: if (opts.sync) fn(); Chris@5: }; Chris@5: Chris@5: // transition definitions - only fade is defined here, transition pack defines the rest Chris@5: $.fn.cycle.transitions = { Chris@5: fade: function($cont, $slides, opts) { Chris@5: $slides.not(':eq('+opts.currSlide+')').css('opacity',0); Chris@5: opts.before.push(function(curr,next,opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.cssBefore.opacity = 0; Chris@5: }); Chris@5: opts.animIn = { opacity: 1 }; Chris@5: opts.animOut = { opacity: 0 }; Chris@5: opts.cssBefore = { top: 0, left: 0 }; Chris@5: } Chris@5: }; Chris@5: Chris@5: $.fn.cycle.ver = function() { return ver; }; Chris@5: Chris@5: // override these globally if you like (they are all optional) Chris@5: $.fn.cycle.defaults = { Chris@5: activePagerClass: 'activeSlide', // class name used for the active pager link Chris@5: after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) Chris@5: allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling Chris@5: animIn: null, // properties that define how the slide animates in Chris@5: animInDelay: 0, // allows delay before next slide transitions in Chris@5: animOut: null, // properties that define how the slide animates out Chris@5: animOutDelay: 0, // allows delay before current slide transitions out Chris@5: aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option) Chris@5: autostop: 0, // true to end slideshow after X transitions (where X == slide count) Chris@5: autostopCount: 0, // number of transitions (optionally used with autostop to define X) Chris@5: backwards: false, // true to start slideshow at last slide and move backwards through the stack Chris@5: before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) Chris@5: center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options) Chris@5: cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE) Chris@5: cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) Chris@5: containerResize: 1, // resize container to fit largest slide Chris@5: containerResizeHeight: 0, // resize containers height to fit the largest slide but leave the width dynamic Chris@5: continuous: 0, // true to start next transition immediately after current one completes Chris@5: cssAfter: null, // properties that defined the state of the slide after transitioning out Chris@5: cssBefore: null, // properties that define the initial state of the slide before transitioning in Chris@5: delay: 0, // additional delay (in ms) for first transition (hint: can be negative) Chris@5: easeIn: null, // easing for "in" transition Chris@5: easeOut: null, // easing for "out" transition Chris@5: easing: null, // easing method for both in and out transitions Chris@5: end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) Chris@5: fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms Chris@5: fit: 0, // force slides to fit container Chris@5: fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle') Chris@5: fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) Chris@5: height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well) Chris@5: manualTrump: true, // causes manual transition to stop an active transition instead of being ignored Chris@5: metaAttr: 'cycle', // data- attribute that holds the option data for the slideshow Chris@5: next: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide Chris@5: nowrap: 0, // true to prevent slideshow from wrapping Chris@5: onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement) Chris@5: onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement) Chris@5: pager: null, // element, jQuery object, or jQuery selector string for the element to use as pager container Chris@5: pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement) Chris@5: pagerEvent: 'click.cycle', // name of event which drives the pager navigation Chris@5: pause: 0, // true to enable "pause on hover" Chris@5: pauseOnPagerHover: 0, // true to pause when hovering over pager link Chris@5: prev: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide Chris@5: prevNextEvent: 'click.cycle',// event which drives the manual transition to the previous or next slide Chris@5: random: 0, // true for random, false for sequence (not applicable to shuffle fx) Chris@5: randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random Chris@5: requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded Chris@5: requeueTimeout: 250, // ms delay for requeue Chris@5: rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle) Chris@5: shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 } Chris@5: skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition Chris@5: slideExpr: null, // expression for selecting slides (if something other than all children is required) Chris@5: slideResize: 1, // force slide width/height to fixed size before every transition Chris@5: speed: 1000, // speed of the transition (any valid fx speed value) Chris@5: speedIn: null, // speed of the 'in' transition Chris@5: speedOut: null, // speed of the 'out' transition Chris@5: startingSlide: undefined,// zero-based index of the first slide to be displayed Chris@5: sync: 1, // true if in/out transitions should occur simultaneously Chris@5: timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance) Chris@5: timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag) Chris@5: updateActivePagerLink: null,// callback fn invoked to update the active pager link (adds/removes activePagerClass style) Chris@5: width: null // container width (if the 'fit' option is true, the slides will be set to this width as well) Chris@5: }; Chris@5: Chris@5: })(jQuery); Chris@5: Chris@5: Chris@5: /*! Chris@5: * jQuery Cycle Plugin Transition Definitions Chris@5: * This script is a plugin for the jQuery Cycle Plugin Chris@5: * Examples and documentation at: http://malsup.com/jquery/cycle/ Chris@5: * Copyright (c) 2007-2010 M. Alsup Chris@5: * Version: 2.73 Chris@5: * Dual licensed under the MIT and GPL licenses: Chris@5: * http://www.opensource.org/licenses/mit-license.php Chris@5: * http://www.gnu.org/licenses/gpl.html Chris@5: */ Chris@5: (function($) { Chris@5: "use strict"; Chris@5: Chris@5: // Chris@5: // These functions define slide initialization and properties for the named Chris@5: // transitions. To save file size feel free to remove any of these that you Chris@5: // don't need. Chris@5: // Chris@5: $.fn.cycle.transitions.none = function($cont, $slides, opts) { Chris@5: opts.fxFn = function(curr,next,opts,after){ Chris@5: $(next).show(); Chris@5: $(curr).hide(); Chris@5: after(); Chris@5: }; Chris@5: }; Chris@5: Chris@5: // not a cross-fade, fadeout only fades out the top slide Chris@5: $.fn.cycle.transitions.fadeout = function($cont, $slides, opts) { Chris@5: $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 }); Chris@5: opts.before.push(function(curr,next,opts,w,h,rev) { Chris@5: $(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0)); Chris@5: $(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1)); Chris@5: }); Chris@5: opts.animIn.opacity = 1; Chris@5: opts.animOut.opacity = 0; Chris@5: opts.cssBefore.opacity = 1; Chris@5: opts.cssBefore.display = 'block'; Chris@5: opts.cssAfter.zIndex = 0; Chris@5: }; Chris@5: Chris@5: // scrollUp/Down/Left/Right Chris@5: $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { Chris@5: $cont.css('overflow','hidden'); Chris@5: opts.before.push($.fn.cycle.commonReset); Chris@5: var h = $cont.height(); Chris@5: opts.cssBefore.top = h; Chris@5: opts.cssBefore.left = 0; Chris@5: opts.cssFirst.top = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.animOut.top = -h; Chris@5: }; Chris@5: $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { Chris@5: $cont.css('overflow','hidden'); Chris@5: opts.before.push($.fn.cycle.commonReset); Chris@5: var h = $cont.height(); Chris@5: opts.cssFirst.top = 0; Chris@5: opts.cssBefore.top = -h; Chris@5: opts.cssBefore.left = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.animOut.top = h; Chris@5: }; Chris@5: $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { Chris@5: $cont.css('overflow','hidden'); Chris@5: opts.before.push($.fn.cycle.commonReset); Chris@5: var w = $cont.width(); Chris@5: opts.cssFirst.left = 0; Chris@5: opts.cssBefore.left = w; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.left = 0-w; Chris@5: }; Chris@5: $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { Chris@5: $cont.css('overflow','hidden'); Chris@5: opts.before.push($.fn.cycle.commonReset); Chris@5: var w = $cont.width(); Chris@5: opts.cssFirst.left = 0; Chris@5: opts.cssBefore.left = -w; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.left = w; Chris@5: }; Chris@5: $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { Chris@5: $cont.css('overflow','hidden').width(); Chris@5: opts.before.push(function(curr, next, opts, fwd) { Chris@5: if (opts.rev) Chris@5: fwd = !fwd; Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW); Chris@5: opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; Chris@5: }); Chris@5: opts.cssFirst.left = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.top = 0; Chris@5: }; Chris@5: $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { Chris@5: $cont.css('overflow','hidden'); Chris@5: opts.before.push(function(curr, next, opts, fwd) { Chris@5: if (opts.rev) Chris@5: fwd = !fwd; Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1); Chris@5: opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; Chris@5: }); Chris@5: opts.cssFirst.top = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.animOut.left = 0; Chris@5: }; Chris@5: Chris@5: // slideX/slideY Chris@5: $.fn.cycle.transitions.slideX = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $(opts.elements).not(curr).hide(); Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,true); Chris@5: opts.animIn.width = next.cycleW; Chris@5: }); Chris@5: opts.cssBefore.left = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.width = 0; Chris@5: opts.animIn.width = 'show'; Chris@5: opts.animOut.width = 0; Chris@5: }; Chris@5: $.fn.cycle.transitions.slideY = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $(opts.elements).not(curr).hide(); Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,false); Chris@5: opts.animIn.height = next.cycleH; Chris@5: }); Chris@5: opts.cssBefore.left = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.height = 0; Chris@5: opts.animIn.height = 'show'; Chris@5: opts.animOut.height = 0; Chris@5: }; Chris@5: Chris@5: // shuffle Chris@5: $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { Chris@5: var i, w = $cont.css('overflow', 'visible').width(); Chris@5: $slides.css({left: 0, top: 0}); Chris@5: opts.before.push(function(curr,next,opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,true,true); Chris@5: }); Chris@5: // only adjust speed once! Chris@5: if (!opts.speedAdjusted) { Chris@5: opts.speed = opts.speed / 2; // shuffle has 2 transitions Chris@5: opts.speedAdjusted = true; Chris@5: } Chris@5: opts.random = 0; Chris@5: opts.shuffle = opts.shuffle || {left:-w, top:15}; Chris@5: opts.els = []; Chris@5: for (i=0; i < $slides.length; i++) Chris@5: opts.els.push($slides[i]); Chris@5: Chris@5: for (i=0; i < opts.currSlide; i++) Chris@5: opts.els.push(opts.els.shift()); Chris@5: Chris@5: // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!) Chris@5: opts.fxFn = function(curr, next, opts, cb, fwd) { Chris@5: if (opts.rev) Chris@5: fwd = !fwd; Chris@5: var $el = fwd ? $(curr) : $(next); Chris@5: $(next).css(opts.cssBefore); Chris@5: var count = opts.slideCount; Chris@5: $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { Chris@5: var hops = $.fn.cycle.hopsFromLast(opts, fwd); Chris@5: for (var k=0; k < hops; k++) { Chris@5: if (fwd) Chris@5: opts.els.push(opts.els.shift()); Chris@5: else Chris@5: opts.els.unshift(opts.els.pop()); Chris@5: } Chris@5: if (fwd) { Chris@5: for (var i=0, len=opts.els.length; i < len; i++) Chris@5: $(opts.els[i]).css('z-index', len-i+count); Chris@5: } Chris@5: else { Chris@5: var z = $(curr).css('z-index'); Chris@5: $el.css('z-index', parseInt(z,10)+1+count); Chris@5: } Chris@5: $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() { Chris@5: $(fwd ? this : curr).hide(); Chris@5: if (cb) cb(); Chris@5: }); Chris@5: }); Chris@5: }; Chris@5: $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); Chris@5: }; Chris@5: Chris@5: // turnUp/Down/Left/Right Chris@5: $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,false); Chris@5: opts.cssBefore.top = next.cycleH; Chris@5: opts.animIn.height = next.cycleH; Chris@5: opts.animOut.width = next.cycleW; Chris@5: }); Chris@5: opts.cssFirst.top = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: opts.cssBefore.height = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.animOut.height = 0; Chris@5: }; Chris@5: $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,false); Chris@5: opts.animIn.height = next.cycleH; Chris@5: opts.animOut.top = curr.cycleH; Chris@5: }); Chris@5: opts.cssFirst.top = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.height = 0; Chris@5: opts.animOut.height = 0; Chris@5: }; Chris@5: $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,true); Chris@5: opts.cssBefore.left = next.cycleW; Chris@5: opts.animIn.width = next.cycleW; Chris@5: }); Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.width = 0; Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.width = 0; Chris@5: }; Chris@5: $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,true); Chris@5: opts.animIn.width = next.cycleW; Chris@5: opts.animOut.left = curr.cycleW; Chris@5: }); Chris@5: $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 }); Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.width = 0; Chris@5: }; Chris@5: Chris@5: // zoom Chris@5: $.fn.cycle.transitions.zoom = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,false,true); Chris@5: opts.cssBefore.top = next.cycleH/2; Chris@5: opts.cssBefore.left = next.cycleW/2; Chris@5: $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); Chris@5: $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 }); Chris@5: }); Chris@5: opts.cssFirst.top = 0; Chris@5: opts.cssFirst.left = 0; Chris@5: opts.cssBefore.width = 0; Chris@5: opts.cssBefore.height = 0; Chris@5: }; Chris@5: Chris@5: // fadeZoom Chris@5: $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,false); Chris@5: opts.cssBefore.left = next.cycleW/2; Chris@5: opts.cssBefore.top = next.cycleH/2; Chris@5: $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); Chris@5: }); Chris@5: opts.cssBefore.width = 0; Chris@5: opts.cssBefore.height = 0; Chris@5: opts.animOut.opacity = 0; Chris@5: }; Chris@5: Chris@5: // blindX Chris@5: $.fn.cycle.transitions.blindX = function($cont, $slides, opts) { Chris@5: var w = $cont.css('overflow','hidden').width(); Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.animIn.width = next.cycleW; Chris@5: opts.animOut.left = curr.cycleW; Chris@5: }); Chris@5: opts.cssBefore.left = w; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.left = w; Chris@5: }; Chris@5: // blindY Chris@5: $.fn.cycle.transitions.blindY = function($cont, $slides, opts) { Chris@5: var h = $cont.css('overflow','hidden').height(); Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.animIn.height = next.cycleH; Chris@5: opts.animOut.top = curr.cycleH; Chris@5: }); Chris@5: opts.cssBefore.top = h; Chris@5: opts.cssBefore.left = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.animOut.top = h; Chris@5: }; Chris@5: // blindZ Chris@5: $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { Chris@5: var h = $cont.css('overflow','hidden').height(); Chris@5: var w = $cont.width(); Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.animIn.height = next.cycleH; Chris@5: opts.animOut.top = curr.cycleH; Chris@5: }); Chris@5: opts.cssBefore.top = h; Chris@5: opts.cssBefore.left = w; Chris@5: opts.animIn.top = 0; Chris@5: opts.animIn.left = 0; Chris@5: opts.animOut.top = h; Chris@5: opts.animOut.left = w; Chris@5: }; Chris@5: Chris@5: // growX - grow horizontally from centered 0 width Chris@5: $.fn.cycle.transitions.growX = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,true); Chris@5: opts.cssBefore.left = this.cycleW/2; Chris@5: opts.animIn.left = 0; Chris@5: opts.animIn.width = this.cycleW; Chris@5: opts.animOut.left = 0; Chris@5: }); Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.width = 0; Chris@5: }; Chris@5: // growY - grow vertically from centered 0 height Chris@5: $.fn.cycle.transitions.growY = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,false); Chris@5: opts.cssBefore.top = this.cycleH/2; Chris@5: opts.animIn.top = 0; Chris@5: opts.animIn.height = this.cycleH; Chris@5: opts.animOut.top = 0; Chris@5: }); Chris@5: opts.cssBefore.height = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: }; Chris@5: Chris@5: // curtainX - squeeze in both edges horizontally Chris@5: $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,false,true,true); Chris@5: opts.cssBefore.left = next.cycleW/2; Chris@5: opts.animIn.left = 0; Chris@5: opts.animIn.width = this.cycleW; Chris@5: opts.animOut.left = curr.cycleW/2; Chris@5: opts.animOut.width = 0; Chris@5: }); Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.width = 0; Chris@5: }; Chris@5: // curtainY - squeeze in both edges vertically Chris@5: $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,false,true); Chris@5: opts.cssBefore.top = next.cycleH/2; Chris@5: opts.animIn.top = 0; Chris@5: opts.animIn.height = next.cycleH; Chris@5: opts.animOut.top = curr.cycleH/2; Chris@5: opts.animOut.height = 0; Chris@5: }); Chris@5: opts.cssBefore.height = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: }; Chris@5: Chris@5: // cover - curr slide covered by next slide Chris@5: $.fn.cycle.transitions.cover = function($cont, $slides, opts) { Chris@5: var d = opts.direction || 'left'; Chris@5: var w = $cont.css('overflow','hidden').width(); Chris@5: var h = $cont.height(); Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts); Chris@5: opts.cssAfter.display = ''; Chris@5: if (d == 'right') Chris@5: opts.cssBefore.left = -w; Chris@5: else if (d == 'up') Chris@5: opts.cssBefore.top = h; Chris@5: else if (d == 'down') Chris@5: opts.cssBefore.top = -h; Chris@5: else Chris@5: opts.cssBefore.left = w; Chris@5: }); Chris@5: opts.animIn.left = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: }; Chris@5: Chris@5: // uncover - curr slide moves off next slide Chris@5: $.fn.cycle.transitions.uncover = function($cont, $slides, opts) { Chris@5: var d = opts.direction || 'left'; Chris@5: var w = $cont.css('overflow','hidden').width(); Chris@5: var h = $cont.height(); Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,true,true); Chris@5: if (d == 'right') Chris@5: opts.animOut.left = w; Chris@5: else if (d == 'up') Chris@5: opts.animOut.top = -h; Chris@5: else if (d == 'down') Chris@5: opts.animOut.top = h; Chris@5: else Chris@5: opts.animOut.left = -w; Chris@5: }); Chris@5: opts.animIn.left = 0; Chris@5: opts.animIn.top = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.cssBefore.left = 0; Chris@5: }; Chris@5: Chris@5: // toss - move top slide and fade away Chris@5: $.fn.cycle.transitions.toss = function($cont, $slides, opts) { Chris@5: var w = $cont.css('overflow','visible').width(); Chris@5: var h = $cont.height(); Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,true,true); Chris@5: // provide default toss settings if animOut not provided Chris@5: if (!opts.animOut.left && !opts.animOut.top) Chris@5: $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 }); Chris@5: else Chris@5: opts.animOut.opacity = 0; Chris@5: }); Chris@5: opts.cssBefore.left = 0; Chris@5: opts.cssBefore.top = 0; Chris@5: opts.animIn.left = 0; Chris@5: }; Chris@5: Chris@5: // wipe - clip animation Chris@5: $.fn.cycle.transitions.wipe = function($cont, $slides, opts) { Chris@5: var w = $cont.css('overflow','hidden').width(); Chris@5: var h = $cont.height(); Chris@5: opts.cssBefore = opts.cssBefore || {}; Chris@5: var clip; Chris@5: if (opts.clip) { Chris@5: if (/l2r/.test(opts.clip)) Chris@5: clip = 'rect(0px 0px '+h+'px 0px)'; Chris@5: else if (/r2l/.test(opts.clip)) Chris@5: clip = 'rect(0px '+w+'px '+h+'px '+w+'px)'; Chris@5: else if (/t2b/.test(opts.clip)) Chris@5: clip = 'rect(0px '+w+'px 0px 0px)'; Chris@5: else if (/b2t/.test(opts.clip)) Chris@5: clip = 'rect('+h+'px '+w+'px '+h+'px 0px)'; Chris@5: else if (/zoom/.test(opts.clip)) { Chris@5: var top = parseInt(h/2,10); Chris@5: var left = parseInt(w/2,10); Chris@5: clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)'; Chris@5: } Chris@5: } Chris@5: Chris@5: opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)'; Chris@5: Chris@5: var d = opts.cssBefore.clip.match(/(\d+)/g); Chris@5: var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10); Chris@5: Chris@5: opts.before.push(function(curr, next, opts) { Chris@5: if (curr == next) return; Chris@5: var $curr = $(curr), $next = $(next); Chris@5: $.fn.cycle.commonReset(curr,next,opts,true,true,false); Chris@5: opts.cssAfter.display = 'block'; Chris@5: Chris@5: var step = 1, count = parseInt((opts.speedIn / 13),10) - 1; Chris@5: (function f() { Chris@5: var tt = t ? t - parseInt(step * (t/count),10) : 0; Chris@5: var ll = l ? l - parseInt(step * (l/count),10) : 0; Chris@5: var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h; Chris@5: var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w; Chris@5: $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' }); Chris@5: (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none'); Chris@5: })(); Chris@5: }); Chris@5: $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); Chris@5: opts.animIn = { left: 0 }; Chris@5: opts.animOut = { left: 0 }; Chris@5: }; Chris@5: Chris@5: })(jQuery);