复制代码代码如下:
/***************滚动场次用始******************/
ฟังก์ชั่น ScrollText (เนื้อหา, btnPrevious, btnNext, autoStart) {
นี้.ดีเลย์ = 10;
นี่.LineHeight = 20;
นี่จำนวน = 1;
this.Direction = "ขึ้น";
นี่หมดเวลา = 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.NextButton.onmouseover = this.GetFunction (นี่คือ "หยุด");
this.NextButton.onmouseout = this.GetFunction (นี่คือ "เริ่ม");
-
ถ้า (btnก่อนหน้า) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction (นี่คือ "ก่อนหน้า");
this.PreviousButton.onmouseover = this.GetFunction (นี่คือ "หยุด");
this.PreviousButton.onmouseout = this.GetFunction (นี่คือ "เริ่ม");
-
this.ScrollContent.onmouseover = this.GetFunction (นี่คือ "หยุด");
this.ScrollContent.onmouseout = this.GetFunction (นี่คือ "เริ่ม");
ถ้า (เริ่มอัตโนมัติ) {
นี้.Start();
-
-
ScrollText.prototype.$ = ฟังก์ชั่น (องค์ประกอบ) {
กลับ document.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(นี่, "AutoScroll"), this.Timeout);
-
ScrollText.prototype.Stop = ฟังก์ชั่น () {
clearTimeout(this.ScrollTimer);
clearTimeout(this.AutoScrollTimer);
-
ScrollText.prototype.AutoScroll = ฟังก์ชั่น () {
ถ้า (this.Direction == "ขึ้น") {
ถ้า (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
this.ScrollContent.scrollTop = 0;
-
this.ScrollContent.scrollTop += this.Amount;
} อื่น {
ถ้า (parseInt (this.ScrollContent.scrollTop) <= 0) {
this.ScrollContent.scrollTop = parseInt (this.ScrollContent.scrollHeight) / 2;
-
this.ScrollContent.scrollTop -= this.Amount;
-
ถ้า (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
this.ScrollTimer = setTimeout(this.GetFunction(นี่, "AutoScroll"), this.Delay);
} อื่น {
this.AutoScrollTimer = setTimeout(this.GetFunction(นี่, "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;
-
ถ้า (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
this.ScrollContent.scrollTop = 0;
-
ถ้า (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
this.ScrollTimer = setTimeout (this.GetFunction (นี่, "เลื่อน", ทิศทาง), this.Delay);
-
-
ScrollText.prototype.GetFunction = function (ตัวแปร, วิธีการ, พารามิเตอร์) {
ฟังก์ชันส่งคืน () {
ตัวแปร [วิธีการ] (พารามิเตอร์);
-
-
ถ้า (document.getElementById("ul_round")) {
var scrollup = new ScrollText("ul_round");
scrollup.LineHeight = 40; //单排文字滚动的高度
scrollup.จำนวน = 1; //注意:子模块(LineHeight)一定要能整除Amount.
scrollup.Delay = 30; //延时
scrollup.Start(); // 文字自动滚动
scrollup.Direction = "ขึ้น"; //默认设置为文字向上滚动
-
/***************滚动场次结束*****************/