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;
})
}
The above code is executedmove(1); mark2=false;
When these two sentences are used, the animate
animation function is used in the move
function, then# Is the call to ##move asynchronous? That is to say, put it in the task queue for execution, so execute it first
mark2=false;Is this correct?
I think you can write
console.log('')
directly on the code and print the content to verify the order you guessed.jquery’s animate is asynchronous, needless to say, http://www.cnblogs.com/aaronj...
The general principle is to use setTimeout and the like to delay execution regularly. Obviously, animate's callback will be placed in the task queue when the callback point is reached, so
mark2=false
must be executed firstCalling move must be synchronously blocking,
animate is also synchronously blocking
The result is
If move is not synchronous
You will see "Run End" first and then other things
If animate is not synchronous
You will see move end before animate start.
For example
The result is