function easing(obj, prop, end, speed){
obj = typeof obj == "object" ? obj : document.getElementById(obj);
speed = speed || 1.2;
if(!obj) return;
var lastV = parseInt(obj.style[prop]) || obj["offset" + prop.replace(/\w/, function(a){return a.toUpperCase();})];
function animate(){
if(lastV < end){
lastV = end - Math.floor((end - lastV)/speed);
obj.style[prop] = lastV + "px";
}else{
clearInterval(iTimer);
obj.style[prop] = end + "px";
}
}
var iTimer = setInterval(animate, 30);
}
posted on 2008-08-11 16:54
汪杰 阅读(158)
评论(0) 编辑 收藏 引用 所属分类:
javascript