معلومات المنتج:
/***************************************/
وظيفة ScrollText(content, btnPrevious, btnNext, autoStart) {
هذا.تأخير = 10؛
this.LineHeight = 20;
this.Amount = 1;
this.Direction = "up";
this.Timeout = 1500;
this.ScrollContent = this.$(content);
this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
//this.ScrollContent.scrollTop = 0;
إذا (بتننكست) {
this.NextButton = this.$(btnNext);
this.NextButton.onclick = this.GetFunction(this, "Next");
this.NextButton.onmouseover = this.GetFunction(this, "Stop");
this.NextButton.onmouseout = this.GetFunction(this, "Start");
}
إذا (btnالسابق) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction(this, "السابق");
this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
this.PreviousButton.onmouseout = this.GetFunction(this, "Start");
}
this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
this.ScrollContent.onmouseout = this.GetFunction(this, "Start");
إذا (تشغيل تلقائي) {
this.Start();
}
}
ScrollText.prototype.$ = الوظيفة (العنصر) {
إرجاع document.getElementById(element);
}
ScrollText.prototype.Previous = الوظيفة () {
ClearTimeout(this.AutoScrollTimer);
ClearTimeout(this.ScrollTimer);
this.Scroll("up");
}
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 = الوظيفة () {
إذا (هذا. الاتجاه == "أعلى") {
إذا (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(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;
}
إذا (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, "Scroll"، اتجاه)، this.Delay);
}
}
ScrollText.prototype.GetFunction = الوظيفة (متغير، طريقة، معلمة) {
وظيفة الإرجاع () {
متغير[طريقة](بارام);
}
}
إذا (document.getElementById("ul_round")) {
var التمرير = new ScrollText("ul_round");
Scrollup.LineHeight = 40; //الحصول على أفضل النتائج
التمرير. المبلغ = 1؛ //القيمة:子模块(LineHeight)一定要能整除Amount.
التمرير. تأخير = 30؛ //延时
التمرير. ابدأ () ؛ //المصدر: 滚动
التمرير لأعلى. الاتجاه = "لأعلى"؛ //الحصول على أفضل النتائج
}
/***************************************************/