(function($){
$.fn.extend( {
rollList:function(option){
option=$.extend({
方向:"上",
ステップ:1,
時間:23
},オプション) ;
var step_coe,scroll_coe,score_coe;
if(option.direction=="up")
{
scroll_coe=1;
}else
{
step_coe=-1;
score_coe=0;
return this.each(){
var $this=$(this);
var itemHeight;
var temp=$("
$this") .css("overflow","hidden").children()
.appendTo(temp);
$this.append(temp.clone(true)).append(temp); $this.children();
itemHeight=itemHeight.eq(1).offset().top-itemHeight.eq(0).offset().top;
while($this.children(": last").offset().top-$this.offset().top<=$this.height())
$this.append(temp.clone(true));
var roll;
this.scrollTop=itemHeight*(1-score_coe);
roll=function (){
temp=setInterval(function(){
if(_this.scrollTop*scroll_coe>=itemHeight*score_coe)
{
_this.scrollTop=(_this.scrollTop-itemHeight)*scroll_coe;
}
_this.scrollTop =option.step*step_coe;
},option.time);
}
$this.hover(function(){
clearInterval(temp);
},function(){
roll();
});
ロール();
});
}
})
}(jQuery));
调用如下:
复制代码