复制代码代码如下 :
/***************滚动场次开始******************/
function ScrollText (contenu, btnPrevious, btnNext, autoStart) {
this.Delay = 10 ;
this.LineHeight = 20 ;
this.Montant = 1 ;
this.Direction = "vers le haut" ;
this.Timeout = 1500 ;
this.ScrollContent = this.$(content);
this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
//this.ScrollContent.scrollTop = 0;
si (btnSuivant) {
this.NextButton = this.$(btnNext);
this.NextButton.onclick = this.GetFunction(this, "Suivant");
this.NextButton.onmouseover = this.GetFunction(this, "Stop");
this.NextButton.onmouseout = this.GetFunction(this, "Démarrer");
}
if (btnPrécédent) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction(this, "Précédent");
this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
this.PreviousButton.onmouseout = this.GetFunction(this, "Démarrer");
}
this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
this.ScrollContent.onmouseout = this.GetFunction(this, "Démarrer");
si (démarrage automatique) {
this.Start();
}
}
ScrollText.prototype.$ = fonction (élément) {
return document.getElementById(element);
}
ScrollText.prototype.Previous = fonction () {
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("vers le haut");
}
ScrollText.prototype.Next = fonction () {
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("vers le bas");
}
ScrollText.prototype.Start = fonction () {
clearTimeout(this.AutoScrollTimer);
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
ScrollText.prototype.Stop = fonction () {
clearTimeout(this.ScrollTimer);
clearTimeout(this.AutoScrollTimer);
}
ScrollText.prototype.AutoScroll = fonction () {
if (this.Direction == "up") {
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
this.ScrollContent.scrollTop = 0;
}
this.ScrollContent.scrollTop += this.Amount;
} autre {
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);
} autre {
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
}
ScrollText.prototype.Scroll = fonction (direction) {
if (direction == "vers le haut") {
si (this.ScrollContent.scrollTop == 0) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
}
this.ScrollContent.scrollTop -= this.Amount;
} autre {
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 = fonction (variable, méthode, paramètre) {
fonction de retour () {
variable[méthode](param);
}
}
if (document.getElementById("ul_round")) {
var scrollup = new ScrollText("ul_round");
scrollup.LineHeight = 40 ; //单排文字滚动的高度
scrollup.Montant = 1 ; //注意:子模块(LineHeight)pourAmount.
scrollup.Delay = 30 ; //延时
scrollup.Start(); //文字自动滚动
scrollup.Direction = "vers le haut"; //默认设置为文字向上滚动
}
/***************滚动场次结束******************/