[英]jQuery stop action “breaks” animation
I have the following code: 我有以下代码:
function play_fu() {
$( "#main_photo img" ).fadeOut(250, function() {
//change photo with new photo ++
}).fadeIn(-250, play_fu).delay(400);
}
$( "#play" ).click(function() {
$(this).hide();
$( "#pause" ).show();
play_fu();
});
$( "#pause" ).click(function() {
$( "#main_photo img" ).stop(true);
$(this).hide();
$( "#play" ).show();
});
As you can see because of function play_fu
, #main_photo img
is always animated (something is added into its animation queue). 如您所见,由于功能play_fu
, #main_photo img
始终处于动画状态(某些内容已添加到其动画队列中)。 When I click pause
I want the last animation to take place, so to change photo with new photo, then fadeIn
and then stop. 当我单击pause
我希望最后一个动画发生,因此要用新照片更改照片,然后fadeIn
然后停止。
Now, what happens is that a new photo could not have yet faded in and the animation will immediately stop while clicking pause
. 现在,发生的事情是新照片可能尚未淡入,单击“ pause
”时动画将立即停止。 Any ideas how to solve this? 任何想法如何解决这个问题?
它应该是
$( "#main_photo img" ).stop(false, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.