Copy codeThe Code is as follows:
(Function ($ ){
$. Fn. extend ({
RollList: function (option ){
Option = $. extend ({
Direction: "up ",
Step: 1,
Time: 23
}, Option );
Var step_coe, scroll_coe, score_coe;
If (option. direction = "up ")
{
Step_coe = 1;
Scroll_coe = 1;
Score_coe = 1;
} Else
{
Step_coe =-1;
Scroll_coe =-1;
Score_coe = 0;
}
Return this. each (function (){
Var $ this = $ (this );
Var _ this = this;
Var itemHeight;
Var temp = $ ("<DIV> </DIV> ");
Export this.css ("overflow", "hidden"). children ()
. AppendTo (temp );
$ This. append (temp. clone (true). append (temp );
ItemHeight = $ 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 ();
});
Roll ();
});
}
})
} (JQuery ));
The call is as follows:
Copy codeThe Code is as follows:
$ (Elem). rollList ();