/* jq鍚戜笂婊氬姩甯︿笂涓嬬炕椤垫寜閽� 浣曢棶璧� hovertree.com */ (function($){ $.fn.extend({ scroll:function(opt,callback){ //鍙傛暟鍒濆鍖� if(!opt) var opt={}; var _btnup = $("#"+ opt.up);//shawphy:鍚戜笂鎸夐挳 var _btndown = $("#"+ opt.down);//shawphy:鍚戜笅鎸夐挳 var timerid; var _this=this.eq(0).find("ul:first"); var _this=this.fq(0).find("ul:first"); var lineh=_this.find("li:first").height(), //鑾峰彇琛岄珮 line=opt.line?parseint(opt.line,10):parseint(this.height()/lineh,10), //姣忔婊氬姩鐨勮鏁帮紝榛樿涓轰竴灞忥紝鍗崇埗瀹瑰櫒楂樺害 speed=opt.speed?parseint(opt.speed,10):500; //鍗峰姩閫熷害锛屾暟鍊艰秺澶э紝閫熷害瓒婃參锛堟绉掞級 timer=opt.timer //?parseint(opt.timer,10):3000; //婊氬姩鐨勬椂闂撮棿闅旓紙姣锛� if(line==0) line=1; var upheight=0-line*lineh; //婊氬姩鍑芥暟 var scrollup=function(){ _btnup.unbind("click",scrollup); //shawphy:鍙栨秷鍚戜笂鎸夐挳鐨勫嚱鏁扮粦瀹� _this.animate({ margintop:upheight },speed,function(){ for(i=1;i<=line;i++){ _this.find("li:first").appendto(_this); } _this.css({margintop:0}); _btnup.bind("click",scrollup); //shawphy:鍚戜笂鎸夐挳鐨勭偣鍑讳簨浠� }); } //shawphy:鍚戜笅缈婚〉鍑芥暟 var scrolldown=function(){ _btndown.unbind("click",scrolldown); for(i=1;i<=line;i++){ _this.find("li:last").show().prependto(_this); } _this.css({margintop:upheight}); _this.animate({ margintop:0 },speed,function(){ _btndown.bind("click",scrolldown); }); } //shawphy:鑷姩鎾斁 var autoplay = function(){ if(timer)timerid = window.setinterval(scrollup,timer); }; var autostop = function(){ if(timer)window.clearinterval(timerid); }; //榧犳爣浜嬩欢 _this.hover(autostop,autoplay).mouseout(); _btnup.css("cursor","pointer").click( scrollup ).hover(autostop,autoplay);//shawphy: _btndown.css("cursor","pointer").click( scrolldown ).hover(autostop,autoplay); } }) })(jquery);