jquery's animation will automatically enter the queue, there is a problem, these animations will be executed one by one, and our actual intention is that when the mouse moves away when the animation is terminated.
animation method for stopping elements:stop ()
syntax structure:stop ([Clearqueue],[gotoend])
Both Clearqueue and gotoend are optional parameters, which are Boolean values.
Clearqueue: Do you want to empty the list of animations that are not playing
Gotoend: Whether to jump directly to the end state of the animation being performed
The Stop () method is often used in animation of hover time to avoid the delay animation caused by inconsistent animation effects with the cursor action.
For example:
1234567 |
$(
".test"
).hover(
function
(){
$(
this
).stop()
.animate({height:
"150"
,width:
"300"
},200);
},
function
(){
$(
this
).stop()
.animate({height:
"50"
,width:
"100"
},3200);
});
|
Determines whether an element is animated:
123 |
if (! $(elememt).is( ":animated" ) ){ //判断元素是否处于动画状态 //如果当前没有进行动画,则添加 } |
How jquery stops animate animation for an element, and how to tell if it is in an animated state