(function($){$.fn.Scroll=function(options){const $this=$(this);const $ul=$("ul",$this);if($ul.length===0)return this;let $lis=$("li",$ul);let liSize=$lis.length;if(liSize<1)return this;const def={delay:3e3,speed:"slow",direction:"left",easing:"swing",auto:true,area:"scroll-box-area",areaWidth:"100%",areaHeight:"100%",areaMargin:"0",areaPadding:"0",btnRight:"btn-right",btnLeft:"btn-left",btnUp:"btn-up",btnDown:"btn-down"};let opt=$.extend({},def,options);opt.speed=opt.speed.toLowerCase();opt.direction=opt.direction.toLowerCase();opt.easing=opt.easing.toLowerCase();let $MC=null;if($this.find("."+opt.area).length<1){const style={position:"relative",width:opt.areaWidth,height:opt.areaHeight,padding:opt.areaPadding,margin:opt.areaMargin,overflow:"hidden"};$ul.wrap('
');$MC=$ul.parent("."+opt.area);$MC.css(style)}else{$MC=$("."+opt.area,$this)}let lW=$lis.eq(0).width();let lH=$lis.eq(0).height();let uW=liSize*lW;let uH=liSize*lH;if("left|right".indexOf(opt.direction)>=0&&uW>=$MC.width()){$ul.width(uW*2).append($lis.clone())}else if("up|down".indexOf(opt.direction)>=0&&uH>=$MC.height()){$ul.height(uH*2).append($lis.clone())}else{return this}let index=1;let scrollLeft=function(){$MC.finish().animate({scrollLeft:lW*index},opt.speed,opt.easing,function(){index++;if(index>liSize){index=1;$MC.scrollLeft(0)}})};let scrollRight=function(){if(index===1){index=liSize+1;$MC.scrollLeft(uW)}index--;$MC.finish().animate({scrollLeft:lW*index-lW},opt.speed,opt.easing)};let scrollUp=function(){$MC.finish().animate({scrollTop:lH*index},opt.speed,opt.easing,function(){index++;if(index>liSize){index=1;$MC.scrollTop(0)}})};let scrollDown=function(){if(index===1){index=liSize+1;$MC.scrollTop(uH)}index--;$MC.finish().animate({scrollLeft:lH*index-lH},opt.speed,opt.easing)};let scrollAction=null;let myMarquee=null;switch(opt.direction){case"left":scrollAction=scrollLeft;break;case"up":scrollAction=scrollUp;break;case"right":scrollAction=scrollRight;break;case"down":scrollAction=scrollDown;break;default:scrollAction=scrollLeft}if(scrollAction!==null&&opt.auto){myMarquee=setInterval(scrollAction,opt.delay);$MC.hover(function(){clearInterval(myMarquee)},function(){myMarquee=setInterval(scrollAction,opt.delay)})}$this.delegate("."+opt.btnRight,"click",scrollLeft);$this.delegate("."+opt.btnLeft,"click",scrollRight);$this.delegate("."+opt.btnUp,"click",scrollDown);$this.delegate("."+opt.btnDown,"click",scrollUp);return this}})(jQuery);