Copy codeThe Code is as follows:
*****************/
Function ScrollText (content, btnPrevious, btnNext, autoStart ){
This. Delay = 10;
This. LineHeight = 20;
This. Amount = 1;
This. Direction = "up ";
This. Timeout = 1500;
This. ScrollContent = this. $ (content );
This. ScrollContent. innerHTML + = this. ScrollContent. innerHTML;
// This. ScrollContent. scrollTop = 0;
If (btnNext ){
This. NextButton = this. $ (btnNext );
This. NextButton. onclick = this. GetFunction (this, "Next ");
This. NextButton. onmouseover = this. GetFunction (this, "Stop ");
This. NextButton. onmouseout = this. GetFunction (this, "Start ");
}
If (btnPrevious ){
This. previusbutton = this. $ (btnPrevious );
This. previusbutton. onclick = this. GetFunction (this, "Previous ");
This. previusbutton. onmouseover = this. GetFunction (this, "Stop ");
This. previusbutton. onmouseout = this. GetFunction (this, "Start ");
}
This. ScrollContent. onmouseover = this. GetFunction (this, "Stop ");
This. ScrollContent. onmouseout = this. GetFunction (this, "Start ");
If (autoStart ){
This. Start ();
}
}
ScrollText. prototype. $ = function (element ){
Return document. getElementById (element );
}
ScrollText. prototype. Previous = function (){
ClearTimeout (this. AutoScrollTimer );
ClearTimeout (this. ScrollTimer );
This. Scroll ("up ");
}
ScrollText. prototype. Next = function (){
ClearTimeout (this. AutoScrollTimer );
ClearTimeout (this. ScrollTimer );
This. Scroll ("down ");
}
ScrollText. prototype. Start = function (){
ClearTimeout (this. AutoScrollTimer );
This. AutoScrollTimer = setTimeout (this. GetFunction (this, "AutoScroll"), this. Timeout );
}
ScrollText. prototype. Stop = function (){
ClearTimeout (this. ScrollTimer );
ClearTimeout (this. AutoScrollTimer );
}
ScrollText. prototype. AutoScroll = function (){
If (this. Direction = "up "){
If (parseInt (this. ScrollContent. scrollTop)> = parseInt (this. ScrollContent. scrollHeight)/2 ){
This. ScrollContent. scrollTop = 0;
}
This. ScrollContent. scrollTop + = this. Amount;
} Else {
If (parseInt (this. ScrollContent. scrollTop) <= 0 ){
This. ScrollContent. scrollTop = parseInt (this. ScrollContent. scrollHeight)/2;
}
This. ScrollContent. scrollTop-= this. Amount;
}
If (parseInt (this. ScrollContent. scrollTop) % this. LineHeight! = 0 ){
This. ScrollTimer = setTimeout (this. GetFunction (this, "AutoScroll"), this. Delay );
} Else {
This. AutoScrollTimer = setTimeout (this. GetFunction (this, "AutoScroll"), this. Timeout );
}
}
ScrollText. prototype. Scroll = function (direction ){
If (direction = "up "){
If (this. ScrollContent. scrollTop = 0 ){
This. ScrollContent. scrollTop = parseInt (this. ScrollContent. scrollHeight)/2;
}
This. ScrollContent. scrollTop-= this. Amount;
} Else {
This. ScrollContent. scrollTop + = this. Amount;
}
If (parseInt (this. ScrollContent. scrollTop)> = parseInt (this. ScrollContent. scrollHeight)/2 ){
This. ScrollContent. scrollTop = 0;
}
If (parseInt (this. ScrollContent. scrollTop) % this. LineHeight! = 0 ){
This. ScrollTimer = setTimeout (this. GetFunction (this, "Scroll", direction), this. Delay );
}
}
ScrollText. prototype. GetFunction = function (variable, method, param ){
Return function (){
Variable [method] (param );
}
}
If (document. getElementById ("ul_round ")){
Var scrollup = new ScrollText ("ul_round ");
Scrollup. LineHeight = 40; // The scroll height of a single row of Text
Scrollup. Amount = 1; // note: the sub-module (LineHeight) must be able to fully remove Amount.
Scrollup. Delay = 30; // latency
Scrollup. Start (); // Automatic Text scrolling
Scrollup. Direction = "up"; // The text is set to scroll up by default.
}
*****************/