Jquery排队动画 [英] Jquery queueing animations

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

问题描述

我想要在dom中的不同对象上执行几个动画。

I have several animations that I want to perform on different objects in the dom.

我希望它们按顺序发生。

I want them to occur in order.

我不想这样做:

$('#first').show(800, function () 
{ $('#second').show(800, function () {...etc...});

我想将所有动画(和cpu密集型函数)添加到某种队列对象中,以确保它们按顺序执行。

I want to add all my animations(and cpu intensive functions) to some kind of queue object that will make sure they execute sequentially.

推荐答案

我不确定你为什么不想使用你描述的方法。如果纯粹从组织的角度来看你不必使用匿名函数

I'm not sure why you don't want to use the method you described. If its purely from an organizational standpoint you don't have to use anonymous functions

function showFirst() {
  $('#first').show(800, showSecond);
}

function showSecond() {
  $('#second').show(800, showThird);
}

function showThird() {
  $('#third').show(800);
}

function startAnimation() {
  showFirst();
}

这篇关于Jquery排队动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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