Solved

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

Posted on 2013-10-31
2
256 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

825 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