显示有误

博客园 首页 新随笔 联系 订阅 管理

function getStyle(obj,name)
{
if(obj.currentStyle)
{
return obj.currentStyle[name];
}
else
{
return getComputedStyle(obj,false)[name];
}
}
var timer=null;
function move(obj,what,target){
clearInterval(obj.timer);
obj.timer=setInterval(function()
{
var cur=0;
if(what=='opacity')
{
cur=Math.round(parseFloat(getStyle(obj,what)));
}
else{
var cur=parseInt(getStyle(obj,what));
}
var speed=(target-cur)/6;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(cur==target)
{
clearInterval(obj.timer);
}
else
{
if(what=='opacity')
{
obj.style.filter='alpha(opaity:'+(speed+cur)+')';
obj.style.opacity=(speed+cur)/100;
}
else
{
obj.style.width=cur+speed+'px';
}
}
},30);

posted on 2016-09-20 10:34  显示有误  阅读(151)  评论(0编辑  收藏  举报