function promiseanimate(ball,distance){ return new Promise(function(resolve,reject){ function _animate(ball,distance,cb) { time=setTimeout(function(){ var marginLeft=parseInt(ball.style.marginLeft,10) if(marginLeft===distance){ clearTimeout(time) cb&&cb() }else{ if(marginLeft<distance){ marginLeft++ }else{ marginLeft-- }} ball.style.marginLeft=marginLeft animate(ball,distance,cb) },13)} })
- 3 回答
- 0 关注
- 5438 浏览
添加回答
举报
0/150
提交
取消