[英]how can I animate an element and don't continue till it finished?
I just want to animate element during a game of cards, but the problem is that when I use the animate function the code is continue to run. 我只想在纸牌游戏中对元素进行动画处理,但是问题是当我使用动画功能时,代码会继续运行。 I tried with the promise()
and done()
function, but for some reason it doesn't help. 我尝试了promise()
和done()
函数,但是由于某种原因,它没有帮助。
Here is what I did: 这是我所做的:
$(document).ready( function() {
$(".demoCard").animate({
"margin-top": '-150'
}, 1000, "easeInSine", function() {
$(".demoCard").remove();
});
});
According to the api documentation. 根据api文档。 Your callback is correct. 您的回调是正确的。 Try updating your jQuery api. 尝试更新您的jQuery api。 Maybe you are using an outdated version. 也许您使用的是过时的版本。 If that doesn't work, try removing your easing argument. 如果这样不起作用,请尝试删除缓动参数。 JQuery might be trying to use the easing argument as a callback function. jQuery可能正在尝试将easing参数用作回调函数。 If you need your easing, make sure you have jQuery UI installed and loaded. 如果需要放松,请确保已安装并加载了jQuery UI。 Otherwise, jQuery won't recognize the easing, and try to use easeInOutSine
as the callback function. 否则,jQuery将无法识别缓动,并尝试使用easeInOutSine
作为回调函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.