如何使多个jQuery动画同时运行? [英] How to make multiple jQuery animations run at the same time?

查看:367
本文介绍了如何使多个jQuery动画同时运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们在两者之间存在差异,我希望它们同时运行.这是代码:

As it stands there us a difference between the two and I want them to run at the same time. Here is the code:

$(selector1).animate({
    height: '670'
}, 2000, function() {
    // Animation complete.  
});

$(selector2).animate({
    top: '670'
}, 2000, function() {
    // Animation complete.
});​

推荐答案

使用queue:false.您可以在此处查看完整的文档.

Using queue:false. You can see the full docshere.

$(selector1).animate({
    height: '670'
}, {
    duration: 2000,
    queue: false,
    complete: function() { /* Animation complete */ }
});

$(selector2).animate({
    top: '670'
}, {
    duration: 2000,
    queue: false,
    complete: function() { /* Animation complete */ }
});

文档:

添加了

.animate(属性,选项)版本:1.0

.animate( properties, options ) version added: 1.0

属性:动画将朝其移动的CSS属性图.
选项:传递给该方法的其他选项的映射.支持的键:
duration:一个字符串或数字,确定动画将运行多长时间.
easing:一个字符串,指示要在过渡中使用哪个缓动函数.
complete:动画完成后调用的函数.
step:在动画的每个步骤之后要调用的功能.
queue: 一个布尔值,指示是否将动画放置在效果队列中.如果为false,则动画将立即开始.从jQuery 1.7开始,queue选项还可以接受一个字符串,在这种情况下,动画将添加到该字符串表示的队列中.
specialEasing:由properties参数及其相应的缓动函数(添加的1.4)定义的一个或多个CSS属性的映射.

properties A map of CSS properties that the animation will move toward.
options A map of additional options to pass to the method. Supported keys:
duration: A string or number determining how long the animation will run.
easing: A string indicating which easing function to use for the transition.
complete: A function to call once the animation is complete.
step: A function to be called after each step of the animation.
queue: A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string.
specialEasing: A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions (added 1.4).

这篇关于如何使多个jQuery动画同时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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