Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1 lines (1 sloc) 2.01 KB
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=o.start,running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=c.find("ul"),li=c.find("li"),itemLength=li.size();c.css("visibility","visible");li.css("overflow","hidden").css("float",o.vertical?"none":"left").children().css("overflow","hidden");ul.css("margin","0").css("padding","0").css("position","relative").css("list-style-type","none").css("z-index","1");c.css("overflow","hidden").css("position","relative").css("z-index","2").css("left","0px");var f=o.vertical?height(li):width(li);var g=f*itemLength;var h=f*o.visible;li.css("width",li.width()).css("height",li.height());ul.css(sizeCss,g+"px").css(animCss,-(b*f));c.css(sizeCss,h+"px");if(o.btnPrev){$(o.btnPrev).click(function(){return go(b-o.scroll)})}if(o.btnNext){$(o.btnNext).click(function(){return go(b+o.scroll)})}if(o.btnGo){$.each(o.btnGo,function(i,a){$(a).click(function(){return go(i)})})}if(o.mouseWheel&&c.mousewheel){c.mousewheel(function(e,d){return d>0?go(b-o.scroll):go(b+o.scroll)})}if(o.auto){setInterval(function(){go(b+1)},o.auto+o.speed)}function vis(){return li.gt(b-1).lt(o.visible)};function go(a){if(!running){running=true;if(o.beforeStart)o.beforeStart.call(this,vis());if(a<0&&b==0){if(o.circular)b=itemLength-o.visible;else return}else if(a>=itemLength-o.visible&&b+o.visible>=itemLength){if(o.circular)b=0;else return}else b=a;ul.animate(animCss=="left"?{left:-(b*f)}:{top:-(b*f)},o.speed,o.easing,function(){ul.css(animCss,-(b*f)+"px");if(o.afterEnd)o.afterEnd.call(this,vis());running=false})}return false}})};function css(a,b){return parseInt($.css(a.jquery?a[0]:a,b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);