function?startMove(obj,json,fn){
clearInterval(obj.timer);
obj.timer?=?setInterval(function(){
var?all?=?true;//假設全部執(zhí)行成功
for(var?attr?in?json){
//判斷是否為透明度
if(attr?==?"opacity"){
var?icur?=?Math.round(parseFloat(getStyle(obj,attr))?*?100);
}else{
var?icur?=?parseInt(getStyle(obj,attr));
}
var?speed?=?(json[attr]?-?icur)/10;
speed?=?speed>0?Math.ceil(speed):Math.floor(speed);
if(icur?!=?json[attr]){
all?=?false;
}
//判斷是否為透明度
if(attr?==?"opacity"){
obj.style[attr]?=?(icur?+?speed)/100;;
}else{
obj.style[attr]?=?icur?+?speed?+?"px";
}???
if(all){
clearInterval(obj.timer);
if(fn){
fn();
}
}
}
},30);??
}
//解決IE兼容
function?getStyle(obj,attr)?{
var?style?=?null;??
if(window.getComputedStyle){
style?=?window.getComputedStyle(obj,?null)[attr];
}else{
style?=?obj.currentStyle[attr];
}
return?style;
}
2017-01-10
if(all){
clearInterval(obj.timer);
}?
放在屬性變化的后面