运动框架
程序员文章站
2022-03-27 09:29:52
...
function startMove(obj, attr, iTarget) {
clearInterval(obj.timer);
obj.timer = setInterval(function () {
var iCur = 0;
if (attr == "opacity") {
iCur = parseInt(parseFloat(getStyle(obj, attr) * 100));
} else {
iCur = parseInt(getStyle(obj, attr));
}
//var iCur = parseInt(getStyle(obj, attr));
var speed = (iTarget - iCur) / 7;
//speed > 0 ? : ;
if (speed >= 0) {
Math.ceil(speed)
} else
{
Math.floor(speed)
}
if (Math.abs(iCur - iTarget) < 1) {
iCur = iTarget;
clearInterval(obj.timer);
alert("1111");
} else {
if (attr == "opacity") {
obj.style[attr] = (iCur + speed) / 100;
obj.style.filter = "alpha(opacity=" + (iCur + speed) + ")";
txt.value = obj.style.filter;
txt.value = obj.style[attr]
} else {
obj.style[attr] = iCur + speed + "px";
document.title = obj.style[attr] + "Speed:" + speed;
}
}
}, 100)
}
function getStyle(obj, attr) {
if (obj.currentStyle) {
return obj.currentStyle[attr];
} else {
return getComputedStyle(obj, false)[attr];
}
}
上一篇: paypal最简单的PHP在线支付SDK
下一篇: win10双系统卸载ubuntu的方法