[英]jQuery animate() complete callback not calling
I have got the following code:我有以下代码:
if ($newCardLoader != null) {
$cardsContainer.animate({
maxHeight: futureHeight + "px"
}, 500, "ease", function() {
$cardsContainer.classList.remove("clamp-height-large");
$cardsContainer.classList.add("clamp-height-fit");
console.log("done");
});
}
The log and the style changes just don't happen.日志和样式更改不会发生。 I have seen several posts on this topic and followed all of them.我看过几篇关于这个主题的帖子,并关注了所有帖子。
To me, it seems correct.在我看来,这似乎是正确的。 Hope somebody can help be out!希望有人可以帮忙!
Consider the following.考虑以下。
if ($newCardLoader != null) {
$cardsContainer.animate({
maxHeight: futureHeight + "px"
}, 500, "ease", function() {
$cardsContainer.toggleClass("clamp-height-large clamp-height-fit");
console.log("done");
});
}
See more: https://api.jquery.com/toggleclass/查看更多: https ://api.jquery.com/toggleclass/
@imvain2 and @Rory McCrossan suggestions are correct. @imvain2 和 @Rory McCrossan 的建议是正确的。 $cardsContainer needs to be a jQuery object ie $cardsContainer 需要是一个 jQuery 对象,即
$("#some-id")
Mine was wrongfully vanilla eg我的是错误的香草,例如
$("#some-id")[0]
This mistake does not throw errors and the animation works anyway.这个错误不会引发错误,并且动画仍然有效。 Only the callback does not work.只有回调不起作用。 This makes it hard to spot to thank you!这让人很难发现感谢你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.