复制代码代码如下:
/*************** 动场次开始*****************/
функция ScrollText(content, btnPrevious, btnNext, autoStart) {
this.Delay = 10;
this.LineHeight = 20;
это.Сумма = 1;
this.Direction = "вверх";
this.Timeout = 1500;
this.ScrollContent = this.$(содержание);
this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
//this.ScrollContent.scrollTop = 0;
если (btnNext) {
this.NextButton = this.$(btnNext);
this.NextButton.onclick = this.GetFunction(this, «Далее»);
this.NextButton.onmouseover = this.GetFunction(this, «Стоп»);
this.NextButton.onmouseout = this.GetFunction(this, «Начать»);
}
если (btnPrevious) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction(this, «Предыдущий»);
this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
this.PreviousButton.onmouseout = this.GetFunction(this, «Начать»);
}
this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
this.ScrollContent.onmouseout = this.GetFunction(this, «Начать»);
если (автостарт) {
это.Начать();
}
}
ScrollText.prototype.$ = функция (элемент) {
вернуть документ.getElementById(элемент);
}
ScrollText.prototype.Previous = функция () {
ClearTimeout(this.AutoScrollTimer);
ClearTimeout(this.ScrollTimer);
this.Scroll("вверх");
}
ScrollText.prototype.Next = функция () {
ClearTimeout(this.AutoScrollTimer);
ClearTimeout(this.ScrollTimer);
this.Scroll("вниз");
}
ScrollText.prototype.Start = функция () {
ClearTimeout(this.AutoScrollTimer);
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
ScrollText.prototype.Stop = функция () {
ClearTimeout(this.ScrollTimer);
ClearTimeout(this.AutoScrollTimer);
}
ScrollText.prototype.AutoScroll = функция () {
if (this.Direction == "вверх") {
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
this.ScrollContent.scrollTop = 0;
}
this.ScrollContent.scrollTop += this.Amount;
} еще {
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);
} еще {
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
}
ScrollText.prototype.Scroll = функция (направление) {
если (направление == "вверх") {
если (this.ScrollContent.scrollTop == 0) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
}
this.ScrollContent.scrollTop -= this.Amount;
} еще {
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, "Прокрутка", направление), this.Delay);
}
}
ScrollText.prototype.GetFunction = функция (переменная, метод, параметр) {
функция возврата () {
переменная[метод](параметр);
}
}
if (document.getElementById("ul_round")) {
вар прокрутка = новый ScrollText («ul_round»);
прокрутка.LineHeight = 40; //单排文字滚动的高度
прокрутка. Сумма = 1; //Ограничение:Отображение(LineHeight)Объем.
прокрутка.Задержка = 30; //延时
прокрутка.Начать(); //文字自动滚动
прокрутка.Направление = "вверх"; // 默认设置为文字向上滚动
}
/*************** 动场次结束*****************/