setTimeout(function?(){
var?currentLen?=?parseInt(num.style.marginLeft,10);
if(currentLen?==?len){
resolve();
}
else{
if(currentLen?<len){
currentLen++;
}
else{
currentLen--;
}
}
num.style.marginLeft?=?currentLen?+'px';
__animate();
},10)如題,為什么要寫(xiě)在里面,寫(xiě)在else外,只要當(dāng)前marginleft值不等于要求的長(zhǎng)度,寫(xiě)在外面不也是會(huì)執(zhí)行的么,只是先后順序不同,但是實(shí)際小球只動(dòng)了3次,很不理解為什么會(huì)這樣。
為什么_animate()以及賦值marginLeft要寫(xiě)在else里面
Conqueror1st
2017-03-02 18:34:14