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> ...
随机推荐
- PHP函数篇详解十进制、二进制、八进制和十六进制转换函数说明
PHP函数篇详解十进制.二进制.八进制和十六进制转换函数说明 作者: 字体:[增加 减小] 类型:转载 中文字符编码研究系列第一期,PHP函数篇详解十进制.二进制.八进制和十六进制互相转换函数说明 ...
- linux学习之系统管理、网络配置、软件安装
一.ifconfig,命令查看linux系统IP 二.su切换到root下(已是root用户不用切换),使用setup命令启用界面操作 CentOS我安装的是Minimal版本,没有安 ...
- 初学JDBC,JDBC工具类的简单封装
//工具类不需要被继承 public final class JdbcUtils{ //封装数据库连接参数,便于后期更改参数值 private static String url="jdbc ...
- xss跨站实例总结
跨站脚本攻击(Cross-site scripting,通常简称为XSS)发生在客户端,可被用于进行窃取隐私.钓鱼欺骗.偷取密码.传播恶意代码等攻击行为. 恶意的攻击者将对客户端有危害的代码放到服务器 ...
- centos下使用eclipse jlink 调试uboot
一.安装java jdk 1.CentOS默认情况下,会安装OpenOffice之类的软件,这些软件需要Java的支持,默认会安装JDK的环境,若需要特定的Java环境,最好将默认的JDK彻底删除: ...
- Hadoop Streaming例子(python)
以前总是用java写一些MapReduce程序现举一个例子使用Python通过Hadoop Streaming来实现Mapreduce. 任务描述: HDFS上有两个目录/a和/b,里面数据均有3列, ...
- iOS多线程GCD(转)
转自:http://www.cnblogs.com/pure/archive/2013/03/31/2977420.html Grand Central Dispatch (GCD)是Apple开发的 ...
- Y2K Accounting Bug(贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10945 Accepted: 54 ...
- Linux下安装配置MongoDB 3.0.x 版本数据库
说明: 操作系统:CentOS 5.X 64位 IP地址:192.168.21.128 实现目的: 安装配置MongoDB数据库 具体操作: 一.关闭SElinux.配置防火墙 1.vi /etc/s ...
- [Unity3D]引擎崩溃、异常、警告、BUG与提示总结及解决方法
1.U3D经常莫名奇妙崩溃. 一般是由于空异常造成的,多多检查自己的引用是否空指针. 2.编码切换警告提示. 警告提示:Some are Mac OS X (UNIX) and some ...