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\$
    – Charlie
    Commented Jul 5, 2012 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.