链式运动实例 运动框架应用 微博

6 篇文章 0 订阅

源代码:

<!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=utf-8" />
<title>微博效果</title>
<style>
*{
margin:0;
padding:0;
}
#txt{
color:#090;
}
#oul{
width:700px;
height:500px;
display:block;
border:1px solid #000;
position:relative;
left:700px;
overflow:hidden;
}
#oul li{
color:#9FC;
list-style:none;
width:700px;
border-bottom:#000 1px dashed;
opacity:0;
overflow:hidden;
}
</style>
<script src="完美运动框架.js" type="text/javascript"></script>
<script>
window.οnlοad=function(){
var Txt=document.getElementById('txt');
var oBt=document.getElementById('obt');
var oUl=document.getElementById('oul');
oBt.οnclick=function(){
var oLi=document.createElement('li');
oLi.innerHTML=Txt.value;
Txt.value='';
oUl.insertBefore(oLi,oUl.childNodes[0]);
var target=oLi.offsetHeight;
oLi.style.height=0;
startMove(oLi,{height:target},function(){startMove(oLi,{opacity:100});
})
}
}
</script>
</head>


<body>
<textarea rows="10" cols="80" id="txt"></textarea><input type="button" value="发布" id="obt" />
<ul id="oul">
</ul>
</body>
</html>

//老一套运动框架

// JavaScript Document
function getStyle(obj,name){
if(obj.currentStyle){
return obj.currentStyle[name];
}else{
return getComputedStyle(obj,false)[name];
}
}
function startMove(obj,json,fun){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var bstop=true;
for(var attr in json){
var beginning=0;
if(attr=='opacity'){
beginning=Math.round(parseFloat(getStyle(obj, attr))*100);
}else{
beginning=parseInt(getStyle(obj,attr));
}
var speed=(json[attr]-beginning)/6;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(beginning!=json[attr])
  bstop=false;
     if(attr=='opacity')
{
obj.style.filter='alpha(opacity:'+(beginning+speed)+')';
obj.style.opacity=(beginning+speed)/100;
}
else
{
obj.style[attr]=beginning+speed+'px';
}

}
if(bstop){
           clearInterval(obj.timer);
             if(fun)fun();
             }

},30)

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值