var timer = setInterval(function(){ var t = new Date() - startTime; var d = time; if ( t >= d ) { t = d; clearInterval( timer ); callback(); } //callback()放于此处会导致少执行一次for循环 for ( var key in mJson ) { var b = startVal[key]; var c = endVal[key] - b; var s = Tween[cv]( t , b , c , d ); obj.style[key] = s + 'px'; } },13);/////改写为 var timer = setInterval(function(){ var t = new Date() - startTime; var d = time; if ( t >= d ) { t = d; clearInterval( timer ); } for ( var key in mJson ) { var b = startVal[key]; var c = endVal[key] - b; var s = Tween[cv]( t , b , c , d ); obj.style[key] = s + 'px'; } if ( t == d ) { callback && callback.call(obj); } },13);//callback是自命名的函数可换为wangdachui
添加回答
举报
0/150
提交
取消