jQuery 动画延迟不起作用
当用户将鼠标悬停在 div 上时,我正在为 div 制作动画,只是想要一点延迟,但它似乎并没有添加延迟,是我做错了什么吗?
$(".carousel-desc").mouseenter(function () {
$(this).delay(1000).animate({ 'height': '180px' }, { queue: false, duration: 600 });
});
$(".carousel-desc").mouseleave(function () {
$(this).delay(1000).animate({ 'height': '40px' }, { queue: false, duration: 600 });
});
谢谢,J。
I am animating a div when a user hovers over and just wanted a bit of a delay on it but it doesn't seem to add the delay in, is there something i'm doing wrong?
$(".carousel-desc").mouseenter(function () {
$(this).delay(1000).animate({ 'height': '180px' }, { queue: false, duration: 600 });
});
$(".carousel-desc").mouseleave(function () {
$(this).delay(1000).animate({ 'height': '40px' }, { queue: false, duration: 600 });
});
Thanks, J.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为问题是
queue: false;
通常你的动画会排队,但你让 animate-function 立即进行动画处理。也许这会满足您的需求:
对于您的东西:
I think the problem is
queue: false;
Usally your animation get queued, but you let the animate-function animate immediately.Maybe this will do what you propably need:
for your stuff:
.delay() 会延迟动画队列
,因为您将
queue: false
放入您的动画选项,它会立即执行。像这样使用它,它将被修复
工作示例:
http://jsfiddle.net/hxfGg/
.delay() delays an animation queue
since you put
queue: false
in your animation options, it is executed immediately.use it like this and it will be fixed
working example:
http://jsfiddle.net/hxfGg/
我同意 Snicksie 的观点,但是,对于您当前的代码情况,有一个更好的方法:
[ 查看输出]
I agree with Snicksie, however, for your current case of code, there is a better approach:
[ View output ]