Solved

jquery animations - how to run at the same time?

Posted on 2012-07-21
9
842 Views
Last Modified: 2012-07-23
How can I have these animations all run at the same time?  The $mask.fadeOut seems to run last regardless of the order of the commands (why is that?)

$MenuItems.stop(true,true).fadeOut(200); // sets display: none
$mask.fadeOut(200, function() { $mask.css('z-index', '0'); } );
$Toolbar.stop(true, true).animate({ backgroundColor: '#008000', height: ToolbarHeight }, 200 );

Open in new window

0
Comment
Question by:SAbboushi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38211559
look up "queue false". You can use it on the animate() method, not sure about fadeOut.


$Toolbar.stop(true, true).animate({ backgroundColor: '#008000', height: ToolbarHeight }, {queue:false, duration: 200} );
0
 

Author Comment

by:SAbboushi
ID: 38211975
Thanks - but no difference...
0
 

Author Comment

by:SAbboushi
ID: 38211979
I am new to jquery but I thought I read somewhere that fadeout calls animation routine.  Is there a way to make an animation call directly to do the fadout (.animate instead of .fadeOut) so that I can also specify queue:false for the fadeout animation - and then would they both happen at the same time?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 500 total points
ID: 38212100
yes. Instead of fadeOut use animate opacity, and a callback to hide()

$MenuItems.stop(true,true).animate({opacity:0}, {
                                                        queue:false, 
                                                        duration: 200, 
                                                        complete: function() {
                                                                    $(this).hide();
                                                                    }
                                                        });   
                

$mask.stop(true,true).animate({opacity:0}, {
                                                        queue:false, 
                                                        duration: 200,
                                                        complete: function(){
                                                                    $(this).hide().css('z-index', '0');
                                                                    }
                                                        });

$Toolbar.stop(true, true).animate({ backgroundColor: '#008000', height: ToolbarHeight }, {queue:false, duration: 200} );
		

Open in new window


with a duration of 200, it'll happens so quickly, you may not even notice the animation.

Also, you can't animate background color with animate, so you'll have to do that differently. You could try css3 animations, or a color plugin.
0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38212116
with css3:

$Toolbar.css({
                        '-webkit-transition': 'background-color 0.3s ease',
                        '-moz-transition': 'background-color 0.3s ease',
                        '-o-transition': 'background-color 0.3s ease',
                        '-ms-transition': 'background-color 0.3s ease',
                        'transition': 'background-color 0.3s ease'
                });                                        

                $Toolbar.css({ 'background-color': '#008000'}).stop(true, true).animate({'height': ToolbarHeight }, {queue:false, duration: 2000} );

Open in new window

0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38212170
0
 

Author Closing Comment

by:SAbboushi
ID: 38216343
Beautiful!!!  Thank you very much!

Pros and cons of jquery vs. css3?
0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38216468
css3 will only work in modern browsers (that excludes IE < 9), but it's more lightweight. depends what you're targeting..

cheers.
0
 

Author Comment

by:SAbboushi
ID: 38216768
k thanks--
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question