Solved

How do you delay a chain of animations that happen on page load?

Posted on 2013-10-31
2
257 Views
Last Modified: 2013-10-31
Hi guys,

I have this jquery code below, but whatever I do, it does not seem to stop the animation from happening until a certain time has passed after the page has loaded.

I thought that by adding the .delay(4000) in the script below, it would stop anything from happening until that time has passed, but when I load the page, part of the animation still runs first before the delay kicks in.....

Could someone be kind enough to show me what I am doing wrong?

Thanks so very much!


<script language=javascript type='text/javascript'>

$(function(){

$("#hot")
            .delay(4000)
            .addClass('changecolor')
         .animate({left: '+=50', top: '-=50',"height": "50px", "width": "50px"}, 1000)
           .animate({'margin-top': '-50px'}, "slow",
               function() {
 
    $("#hot").hide();
  }
               );
});


</script>
0
Comment
Question by:CFbubu
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39614701
$(function(){

$("#hot").delay(4000)
	.queue(function(){
		$("#hot").addClass('changecolor').dequeue()
		.animate({left: '+=50', top: '-=50',"height": "50px", "width": "50px"}, 1000)
		.animate({'margin-top': '-50px'}, "slow",
		function() {
			$("#hot").hide();
		})
	});
})

Open in new window

0
 

Author Closing Comment

by:CFbubu
ID: 39614787
Thanks bro....you nailed it fast!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
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 the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

749 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