熟人
中级会员
 
UID 92185
精华
0
积分 332
帖子 476
金钱 332 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2007-4-29
状态 离线
|
[广告]: q
m
请教一下在ff中使用setInterval的问题
在ff中使用setInterval和setTimeout方法似乎都存在动画效果不流畅的问题
不知道是否是我的使用方法有问题 隔一段时间ff的效果就会“卡住”一会儿 而ie没有问题
代码如下 请高手指教
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>
<script type="text/javascript">
function mList(id){
this._distance = 1;
this._interval = 10;
this._console = null;
this._totalLength = 0;
this._margins = 5;
if(null != id){
this._console = document.getElementById(id);
}
}
mList.prototype.ini = function(id){
this._console = document.getElementById(id);
var children = this._console.childNodes;
for(var i = 0;i < children.length;i ++){
this._totalLength += parseInt(children[i].clientWidth) + this._margins;
}
}
mList.prototype.goLeft = function(){
this._console.style.left = this._console.offsetLeft - this._distance + "px";
if(this._console.offsetLeft < 0-(parseInt(this._console.firstChild.clientWidth) + this._margins)){
this._console.appendChild(this._console.firstChild);
this._console.style.left = "0px";
}
}
mList.prototype.move = function(objName){
tt = setInterval(objName+".goLeft()", this._interval);
}
var tt = null;
var ll = null;
window.onload = function(){
ll = new mList();
ll.ini("line");
ll.move("ll");
}
</script>
<style type="text/css">
#console{
position:relative;
width:200px;
height:80px;
border:solid #000000 1px;
overflow:hidden;
}
#line{
position:absolute;
width:300px;
overflow:hidden;
margin:0;
padding:0;
list-style-type:none;
background-color:#99FFFF;
left:10px;
top:0px;
}
#line li{
float:left;
width:60px;
height:80px;
margin-left:5px;
display:inline;
}
</style>
</head>
<body>
<div id="console">
<ul id="line"><li style="background-color:#00FFFF;">1</li><li style="background-color:#CCCCCC;">2</li><li style="background-color:#33FFFF;">3</li><li style="background-color:#00FF00;">4</li><li style="background-color:#FF0000;">5</li><li style="background-color:#66CC33;">6</li><li style="background-color:#6699FF;">7</li></ul>
</div>
</body>
</html>
|  性格:馋 懒 奸 猾 坏
兴趣:吃 喝 嫖 赌 抽
职业:坑 蒙 拐 骗 偷 |
|