var mark2=true;
if(mark2){
move(1);
mark2=false;
}
function move(){
$(".box").animate({
width: arrW[index],
height: arrH[index],
opacity: arrO[index],
left: arrL[index],
top: arrT[index]
},500,function(){
mark2=true;
})
}
以上代码执行move(1); mark2=false;这两句的时候,move函数中用了animate动画函数,那move的调用是属于异步的吗?也就是放到任务队列中执行吗,所以首先执行mark2=false;这样理解对吗?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
调用move肯定是同步的阻塞的,
animate也是同步阻塞的
结果是
如果move不是同步的
你会先看到“运行结束”然后才是其他的东西
如果animate不是同步的
你会看到move end 在 animate start 前头。
比如
结果是