Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…

726 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