js 实现单行文本滚动效果
js 代码如下:
/***************滚动场次开始*****************/
function ScrollText(content, btnPrevious, btnNext, autoStart) {
this.Delay = ;
this.LineHeight = ;
this.Amount = ;
this.Direction = "up";
this.Timeout = ;
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, "Next");
this.NextButton.onmouseover = this.GetFunction(this, "Stop");
this.NextButton.onmouseout = this.GetFunction(this, "Start");
}
if (btnPrevious) {
this.PreviousButton = this.$(btnPrevious);
this.PreviousButton.onclick = this.GetFunction(this, "Previous");
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");
if (autoStart) {
this.Start();
}
}
ScrollText.prototype.$ = function (element) {
return document.getElementById(element);
}
ScrollText.prototype.Previous = function () {
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("up");
}
ScrollText.prototype.Next = function () {
clearTimeout(this.AutoScrollTimer);
clearTimeout(this.ScrollTimer);
this.Scroll("down");
}
ScrollText.prototype.Start = function () {
clearTimeout(this.AutoScrollTimer);
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
ScrollText.prototype.Stop = function () {
clearTimeout(this.ScrollTimer);
clearTimeout(this.AutoScrollTimer);
}
ScrollText.prototype.AutoScroll = function () {
if (this.Direction == "up") {
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / ) {
this.ScrollContent.scrollTop = ;
}
this.ScrollContent.scrollTop += this.Amount;
} else {
if (parseInt(this.ScrollContent.scrollTop) <= ) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / ;
}
this.ScrollContent.scrollTop -= this.Amount;
}
if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != ) {
this.ScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Delay);
} else {
this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}
}
ScrollText.prototype.Scroll = function (direction) {
if (direction == "up") {
if (this.ScrollContent.scrollTop == ) {
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / ;
}
this.ScrollContent.scrollTop -= this.Amount;
} else {
this.ScrollContent.scrollTop += this.Amount;
}
if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / ) {
this.ScrollContent.scrollTop = ;
}
if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != ) {
this.ScrollTimer = setTimeout(this.GetFunction(this, "Scroll", direction), this.Delay);
}
}
ScrollText.prototype.GetFunction = function (variable, method, param) {
return function () {
variable[method](param);
}
}
if (document.getElementById("ul_round")) {
var scrollup = new ScrollText("ul_round");
scrollup.LineHeight = ; //单排文字滚动的高度
scrollup.Amount = ; //注意:子模块(LineHeight)一定要能整除Amount.
scrollup.Delay = ; //延时
scrollup.Start(); //文字自动滚动
scrollup.Direction = "up"; //默认设置为文字向上滚动
}
/***************滚动场次结束*****************/
html代码:
<ul id="ul_round">
<li>今天上午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天下午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天临时场次<b class="c_c00">:-:</b>,
已经结束
</li> <li>今天上午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天下午场<b class="c_c00">:-:</b>,
已经结束
</li>
<li>今天临时场次<b class="c_c00">:-:</b>,
已经结束
</li>
</ul>
js 实现单行文本滚动效果的更多相关文章
- js实现文字上下滚动效果
大家都知道,做html页面时,为了提升网页的用户体验,我们需要在网页中加入一些特效,比如单行区域文字上下滚动就是经常用到的特效.如下图示效果: <html> <head> &l ...
- js文字展示各种滚动效果
js文字展示各种滚动效果:http://www.dowebok.com/demo/188/
- js 实现文字列表滚动效果
今天要实现抽奖名单在首页滚动展示的效果,就用js写了一个,代码如下: html代码: <style type="text/css"> *{margin:;padding ...
- animate.css配合wow.min.js实现各种页面滚动效果
有的页面在向下滚动的时候,有些元素会产生细小的动画效果.虽然动画比较小,但却能吸引你的注意.比如刚刚发布的 iPhone 6 的页面(查看).如果你希望你的页面也更加有趣,那么你可以试试 WOW.js ...
- js实现表格无缝滚动效果
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- js实现页面消息滚动效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- WPF 文本滚动效果 渐变效果
<DockPanel> <StackPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom&qu ...
- js实现新闻条目滚动效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js实现简单易用的上下无缝滚动效果
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
随机推荐
- 菲涅尔反射(Fresnel Reflection)
离线渲染中,通常可以用kd,ks,kt(分别代表物体的漫反射系数,镜面反射系数,透射系数)来简单地描述一个物体的基本材质,例如,我们将一个物体设置为:kd=0,ks=0.1,kt=0.9,即代表一束光 ...
- FreeMarker template error!
部署项目后发现以下“FreeMarker template error!”的问题,google.baidu猛一顿搜索无果后开始认真分析异常信息. FreeMarker template error! ...
- Silverlight实例教程 - 自定义扩展Validation类,验证框架的总结和建议(转载)
Silverlight 4 Validation验证实例系列 Silverlight实例教程 - Validation数据验证开篇 Silverlight实例教程 - Validation数据验证基础 ...
- linux学习笔记 2013-09-02
1,解压一个tar.gz文件夹 tar -xvzf filename.tar.gz 2,删除一个文件夹下所有的文件 rm -rf * 3,安装文件 sudo apt-get install XXX. ...
- 让我们一起学习《Node.js入门》一书吧!
Node.js入门 读完本书之后,你将完成一个完整的web应用,该应用允许用户浏览页面以及上传文件. 里面对一些知识的讲解,让你略窥Node.js的门径.最好一段代码一段代码的写下来,我的习惯是手里拿 ...
- Spark-1.0.0 standalone分布式安装教程
Spark目前支持多种分布式部署方式:一.Standalone Deploy Mode:二Amazon EC2.:三.Apache Mesos:四.Hadoop YARN.第一种方式是单独部署,不需要 ...
- 畅通工程再续(MST)
畅通工程再续 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- 敲点JavaScript代码
1. DOM DEMO-表格的行排序 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...
- java中堆栈(stack)和堆(heap)
原文地址:http://blog.csdn.net/jerryao/article/details/874101 1.内存分配策略 按照编译原理的观点,程序运行时的内存分配有三种策略,分别是静态的,栈 ...
- ListView异步加载网络图片完美版之双缓存技术
本示例参考学习了一个国外的示例:http://code.google.com/p/android-imagedownloader/,有兴趣的同学下载研究一下. 问题描述:在这一篇博客中将会为大家讲解如 ...