2
\$\begingroup\$

I'm kinda worried that the way I did my animation intro is a bit too heavy and is not optimized. Please review and let me know your thoughts.

$(document).ready(function() {
 introIconFirst();
 function introIconFirst() {
 $('h2.ribbon').css({
 'marginTop': '+30px',
 'opacity': '0'
 }).animate({
 marginTop: '0',
 opacity: '1'
 }, 1500, 'easeOutElastic', introIconSecond());
 }
 function introIconSecond() {
 $('#ico_website').rotate('0deg').css({
 'top': '+900px',
 'opacity': '0'
 }).animate({
 top: '50px',
 opacity: '1'
 }, {
 queue: false,
 duration: 1100,
 easing: 'easeOutElastic'
 }).animate({
 rotate: '-30deg'
 }, 1000, 'easeOutElastic', introIconThird());
 }
 function introIconThird() {
 $('#ico_rails').css({
 'top': '+900px',
 'opacity': '0'
 }).delay(300).animate({
 top: '145px',
 opacity: '1'
 }, 1400, 'easeOutElastic', introIconFourth());
 }
 function introIconFourth() {
 $('#ico_plane').css({
 'left': '255px',
 'top': '90px',
 'opacity': '0'
 }).delay(800).animate({
 top: '18px',
 left: '299px',
 opacity: '1'
 }, 600, 'linear');
 }
});
dfhwze
14.1k3 gold badges40 silver badges101 bronze badges
asked Dec 31, 2011 at 18:52
\$\endgroup\$
1
  • \$\begingroup\$ @JoshSmith Thanks. I didn't know it before. Will do for future post. \$\endgroup\$ Commented Jan 1, 2012 at 9:30

2 Answers 2

1
\$\begingroup\$

Looks good, though I prefer to keep the $(document).ready() as clean as possible, by only making calls and not definitions. Makes DOM management a bit easier.

answered Jan 1, 2012 at 0:16
\$\endgroup\$
1
  • \$\begingroup\$ No problem, I tend to be a bit too obsessive over things like that. Often times my doc readys' don't consist of more than a few lines. \$\endgroup\$ Commented Jan 1, 2012 at 11:09
1
\$\begingroup\$

Why the hell you need to declare your functions inside $(document).ready()? :)

answered Jan 1, 2012 at 0:31
\$\endgroup\$
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.