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)}
})
Suber丶林
牧后黄昏
化龙贝
相关分类