var
Move = {
version:
'1.5'
,
isEmptyObject:
function
(obj) {
for
(
var
attr in obj) {
return
false;
}
return
true;
},
getStyle:
function
(obj, attr) {
if
(obj.currentStyle) {
return
obj.currentStyle[attr];
}
else
{
return
getComputedStyle(obj, null)[attr];
}
},
action:
function
(obj, json, sv, callback) {
_this = this;
if
(_this.isEmptyObject(obj)) {
return
false;
}
clearInterval(obj.timer);
obj.timer = setInterval(
function
() {
var
isAllCompleted = true,
speed,
attrValue,
targetV;
for
(attr in json) {
attrValue = _this.getStyle(obj, attr);
switch
(attr) {
case
'opacity'
:
attrValue = Math.
round
((isNaN(parseFloat(attrValue)) ? 1 : parseFloat(attrValue)) * 100);
speed = (json[attr] * 100 - attrValue) / (sv || 4);
targetV = json[attr] * 100;
break
;
default
:
attrValue = isNaN(parseInt(attrValue)) ? 0 : parseInt(attrValue);
speed = (json[attr] - attrValue) / (sv || 4);
targetV = json[attr];
}
speed = speed > 0 ? Math.
ceil
(speed) : Math.
floor
(speed);
if
(attrValue != targetV) {
isAllCompleted = false;
}
switch
(attr) {
case
'opacity'
:
{
obj.style.filter =
"alpha(opacity="
+ (attrValue + speed) +
")"
;
obj.style.opacity = (attrValue + speed) / 100;
};
break
;
default
:
obj.style[attr] = attrValue + speed +
'px'
;
}
}
if
(isAllCompleted) {
clearInterval(obj.timer);
if
(typeof callback ===
'function'
) {
callback();
}
}
}, 30);
}
};