jQuery的淡出的同时动画结束 [英] jQuery fadeOut at same time animation ends

查看:182
本文介绍了jQuery的淡出的同时动画结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code这动画的背景图像。在动画结束时,它淡出。不过,我想实现的是有元素淡出之前的动画完成。所以,如果动画需要6秒,淡出需要2秒,褪色会开始在4秒钟,这样的动画,和衰落的端部的端部在相同的超时发生。任何帮助将是非常美联社preciated。

  first_slide.animate({'背景大小':'100%'},6000,线性)淡出(2000);


解决方案

您有不同的方式分配动画,加入队列:假值,因此DIV可以在同一time.Then有两个动画只需添加一个延时:

http://jsfiddle.net/8df2t/

  first_slide.animate({
    背景尺寸':100%
},{
    时间:6000,
    宽松:线性,
    队列:假的
})
    .delay(4000).fadeOut(2000);

I have the following code that animates a background image. At the end of the animation, it fades out. However, what I would like to achieve is have the element fade out before the animation is complete. So, if the animation takes 6 seconds, and the fadeout takes 2 seconds, the fade would start at 4 seconds so that the end of the animation, and the end of the fade out happen at the same time. Any help would be much appreciated.

first_slide.animate({'background-size':'100%'}, 6000, 'linear').fadeOut(2000);

解决方案

You have to assign the animation differently, adding queue:false value so the div can have two animations at the same time.Then just add a delay:

http://jsfiddle.net/8df2t/

first_slide.animate({
    'background-size': '100%'
}, {
    duration: 6000,
    easing: 'linear',
    queue: false
})
    .delay(4000).fadeOut(2000);

这篇关于jQuery的淡出的同时动画结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆