1
\$\begingroup\$

I have a couple of jQuery animations running in a sequence after certain resources are loaded:

$(".loading").delay(2600).fadeOut({
    useTranslate3d: true,
});

$(".zip").delay(1900).slideDown({
    useTranslate3d: true,
});

$("#zip").delay(2800).slideDown({
    useTranslate3d: true,
});

Is there a better way to combine all of these animations? It feels superfluous having to write them all out like this...

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

You can use the same options object for all three animations.

var opts = {
    useTranslate3d: true,
}
$(".loading").delay(2600).fadeOut(opts);
$(".zip").delay(1900).slideDown(opts);
$("#zip").delay(2800).slideDown(opts);

Having .zip and #zip pointing to different elements might also be a bit confusing - but that depends on your DOM structure.

\$\endgroup\$
1
  • \$\begingroup\$ Yeah, I'll worry about the naming later. \$\endgroup\$ Commented Jul 5, 2012 at 1:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.