复代码代码如下:
/*****************滚动场次开始********************/
function ScrollText(content, btnPrevious, btnNext, autoStart) {
this.Delay = 10;
this.LineHeight = 20;
this.금액 = 1;
this.Direction = "위";
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, "다음");
this.NextButton.onmouseover = this.GetFunction(this, "중지");
this.NextButton.onmouseout = this.GetFunction(this, "시작");
}
if (btn이전) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction(this, "이전");
this.PreviousButton.onmouseover = this.GetFunction(this, "중지");
this.PreviousButton.onmouseout = this.GetFunction(this, "시작");
}
this.ScrollContent.onmouseover = this.GetFunction(this, "중지");
this.ScrollContent.onmouseout = this.GetFunction(this, "시작");
if (자동 시작) {
this.Start();
}
}
ScrollText.prototype.$ = 함수(요소) {
return document.getElementById(element);
}
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 = parsInt(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 = 함수(방향) {
if (방향 == "위") {
if (this.ScrollContent.scrollTop == 0) {
this.ScrollContent.scrollTop = parsInt(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 = 함수(변수, 메서드, 매개변수) {
반환 함수 () {
변수[메소드](param);
}
}
if (document.getElementById("ul_round")) {
var scrollup = new ScrollText("ul_round");
scrollup.LineHeight = 40; //单排文字滚动의 높이
스크롤업.금액 = 1; //주의: 子模块(LineHeight) 一定要能整除Amount.
스크롤업.지연 = 30; //延时
스크롤업.시작(); //문자 자체 滚动
scrollup.Direction = "위로"; //默认设置为文字向上滚动
}
/*****************滚动场次结束********************/