function startMove(obj,json,fn){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
var all = true;//假设全部执行成功
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;
}