Sign up ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

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...

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Yeah, I'll worry about the naming later. –  Charlie Jul 5 '12 at 1:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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