如何使用 jQuery 确定元素是否正在动画? [英] How do I find out with jQuery if an element is being animated?
本文介绍了如何使用 jQuery 确定元素是否正在动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试移动页面上的一些元素,并且在动画发生期间,我希望将溢出:隐藏"应用于元素,并在动画完成后将溢出"返回到自动"完成.
I'm trying to move some elements on the page, and during the time the animation occurs, I want to have "overflow:hidden" applied to an elemnt, and "overflow" back to "auto" once the animation is completed.
我知道 jQuery 有一个实用函数,可以确定某个元素是否正在被动画化,但我在文档中的任何地方都找不到它
I know jQuery has an utility function that determines whether some element is being animated but I can't find it anywhere in the docs
推荐答案
if( $(elem).is(':animated') ) {...}
更多信息:https://api.jquery.com/animated-选择器/
或者:
$(elem)
.css('overflow' ,'hidden')
.animate({/*options*/}, function(){
// Callback function
$(this).css('overflow', 'auto');
};
这篇关于如何使用 jQuery 确定元素是否正在动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文