?
Solved

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

Posted on 2013-10-31
2
Medium Priority
?
264 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 2000 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

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

850 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