function getComputer(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
function startMove(obj,attr,target,fn) {
clearInterval(obj.timer);
obj.timer=setInterval(function(){
if(attr=="opacity"){
var cur=Math.round(parseFloat(getComputer(obj,attr))*100);
}else{
var cur=parseInt(getComputer(obj,attr));
}
var speed=target-cur;
speed>0 ?(speed=Math.ceil(speed/3)):(speed=Math.floor(speed/3));
if(cur==target){
clearInterval(obj.timer);
if(fn){
fn();
}
}else{
if(attr=="opacity"){
// obj.style.filter=Alpha("opacity:'+(cur+speed)+");
obj.style.opacity=(speed+cur)/100;
}else{
obj.style[attr]=cur+speed+"px";
}
}
},300)
}
添加回答
举报
0/150
提交
取消