/* 版主推荐滚动 */ (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 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); //