复制代码代码如下:
/***************滚动场次开始*******************/
function ScrollText(conteúdo, btnAnterior, btnNext, autoStart) {
este.Atraso = 10;
this.LineHeight = 20;
isto.Valor = 1;
this.Direction = "para cima";
this.Timeout = 1500;
this.ScrollContent = this.$(conteúdo);
this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
//this.ScrollContent.scrollTop = 0;
if (btnPróximo) {
este.NextButton = isto.$(btnNext);
this.NextButton.onclick = this.GetFunction(this, "Próximo");
this.NextButton.onmouseover = this.GetFunction(this, "Parar");
this.NextButton.onmouseout = this.GetFunction(this, "Iniciar");
}
if (btnAnterior) {
this.PreviousButton = this.$(btnAnterior);
this.PreviousButton.onclick = this.GetFunction(this, "Anterior");
this.PreviousButton.onmouseover = this.GetFunction(this, "Parar");
this.PreviousButton.onmouseout = this.GetFunction(this, "Iniciar");
}
this.ScrollContent.onmouseover = this.GetFunction(this, "Parar");
this.ScrollContent.onmouseout = this.GetFunction(this, "Iniciar");
if (autoInício) {
this.Start();
}
}
ScrollText.prototype.$ = função (elemento) {
retornar document.getElementById(elemento);
}
ScrollText.prototype.Previous=função(){
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("para cima");
}
ScrollText.prototype.Next=função(){
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("para baixo");
}
ScrollText.prototype.Start=função(){
clearTimeout(this.AutoScrollTimer);
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
ScrollText.prototype.Stop=função(){
clearTimeout(this.ScrollTimer);
clearTimeout(this.AutoScrollTimer);
}
ScrollText.prototype.AutoScroll=função(){
if (this.Direction == "para cima") {
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
this.ScrollContent.scrollTop = 0;
}
this.ScrollContent.scrollTop += this.Amount;
} outro {
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);
} outro {
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
}
ScrollText.prototype.Scroll = função (direção) {
if (direção == "para cima") {
if (this.ScrollContent.scrollTop == 0) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
}
this.ScrollContent.scrollTop -= this.Amount;
} outro {
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, "Rolar", direção), this.Delay);
}
}
ScrollText.prototype.GetFunction = função (variável, método, parâmetro) {
função de retorno () {
variável[método](param);
}
}
if (document.getElementById("ul_round")) {
var scrollup = new ScrollText("ul_round");
scrollup.LineHeight = 40; //单排文字滚动的高度
scrollup.Amount = 1; //注意:子模块(LineHeight)一定要能整除Amount.
scrollup.Delay = 30; //延时
scrollup.Start(); //文字自动滚动
scrollup.Direction = "para cima"; //默认设置为文字向上滚动
}
/***************滚动场次结束*******************/