Math.floor(-0.5) = -1,Math.ceil(0.5) = 1,为了有一个速度值。。。看到有说jquery的。。ooDiv.stop.animate()吗。。。感觉还是自己写原生js封装比较好
2015-02-12
else {
oattr = parseInt(getStyle(obj,attr));
}
var speed = (json[attr]-oattr)/8;
speed = speed >0?Math.ceil(speed):Math.floor(speed);
if (oattr != json[attr]) {
flag = false;
oattr = parseInt(getStyle(obj,attr));
}
var speed = (json[attr]-oattr)/8;
speed = speed >0?Math.ceil(speed):Math.floor(speed);
if (oattr != json[attr]) {
flag = false;
2015-02-02
function startMove (obj,json,fn) {
clearInterval(obj.timer);
obj.timer = setInterval(function () {
var flag = true;
for(var attr in json){
var oattr = 0;
if (attr == 'opacity') {
oattr = Math.round(parseFloat(getStyle(obj,attr))*100);
}
clearInterval(obj.timer);
obj.timer = setInterval(function () {
var flag = true;
for(var attr in json){
var oattr = 0;
if (attr == 'opacity') {
oattr = Math.round(parseFloat(getStyle(obj,attr))*100);
}
2015-02-02