//获得样式
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
//运动函数
function startMove(obj,json,fn){
clearInterval(obj.timer);
var iStop = true;
obj.timer = function(){
for(attr in json){
//获得当前样式
var iCur =0;
if(attr=="opacity"){
icur = parseInt(parseFloat(getStyle(obj,attr))*100);
}else{
icur = parseInt(getStyle(obj,attr));
}
//获得速度
var iSpeed = (json[attr] - iCur)/8;
iSpeed = iSpeed > 0?Math.ceil(iSpeed):Math.floor(iSpeed);
if(json[attr]!=iCur){
iStop =false;
}
//运动
if(attr == "opacity"){
obj.style.opacity = (iCur + iSpeed)/100;
obj.style.filter = alpha(opacity =(iCur + iSpeed) );
}else{
obj.style[attr] = (iCur + iSpeed) + "px"
}
}
if(iStop){
if(fn)fun();
}
}
}
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
//运动函数
function startMove(obj,json,fn){
clearInterval(obj.timer);
var iStop = true;
obj.timer = function(){
for(attr in json){
//获得当前样式
var iCur =0;
if(attr=="opacity"){
icur = parseInt(parseFloat(getStyle(obj,attr))*100);
}else{
icur = parseInt(getStyle(obj,attr));
}
//获得速度
var iSpeed = (json[attr] - iCur)/8;
iSpeed = iSpeed > 0?Math.ceil(iSpeed):Math.floor(iSpeed);
if(json[attr]!=iCur){
iStop =false;
}
//运动
if(attr == "opacity"){
obj.style.opacity = (iCur + iSpeed)/100;
obj.style.filter = alpha(opacity =(iCur + iSpeed) );
}else{
obj.style[attr] = (iCur + iSpeed) + "px"
}
}
if(iStop){
if(fn)fun();
}
}
}