Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-13-2011, 09:03 PM   PM User | #1
marilynn.fowler
Regular Coder

 
Join Date: Aug 2002
Location: San Francisco
Posts: 442
Thanks: 19
Thanked 15 Times in 15 Posts
marilynn.fowler is an unknown quantity at this point
Control speed of a jQuery animation

I am new to jQuery (2 weeks). I would like to set up my animations so that the #logo slides in over a period of 3 seconds, then the #homeDetail fades in over a period of 5 seconds. I don't know how to control the speed of the logo slide, and I don't know how to tell the #homeDetail to start after the slide.

Here's the code I'm using right now:

Code:
<script type="text/javascript">
	$(document).ready(function() {
		$("img#homeDetail").fadeIn(5000);
		
		var $lefty = $("#logo");
		$lefty.animate({
			left: parseInt($lefty.css('left'),10) == 15 ?
			-$lefty.outerWidth() :
			15
		});
    	});
</script>
__________________
Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx

Last edited by marilynn.fowler; 02-14-2011 at 01:00 AM..
marilynn.fowler is offline   Reply With Quote
Old 02-13-2011, 10:15 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
The first place to look for answers should always be the official documentation:
http://api.jquery.com/animate/

What you're looking for are the "duration" and "queue" options.
venegal is offline   Reply With Quote
Old 02-14-2011, 01:00 AM   PM User | #3
marilynn.fowler
Regular Coder

 
Join Date: Aug 2002
Location: San Francisco
Posts: 442
Thanks: 19
Thanked 15 Times in 15 Posts
marilynn.fowler is an unknown quantity at this point
I had gone to that page before, but didn't understand it. I did see the word "delay" at some point in my search, and when I went to the "delay" page, I got the answer I needed. Plus, their code made more sense to me.

Code:
	$(document).ready(function() {
		//set opacity of logo and detail to 0, then slide in and fade up
		$("#logo").css({
			left: "170px",
			opacity: "0"
		}).animate({
			opacity: 1,
			left: "10"
		}, 2000 );
		
		//set opacity to 0, delay for 1.2 seconds, then fade up
		$("#homeDetail").css({
			opacity: "0"
		}).delay(1200).animate({
			opacity: 1
		}, 2000 );
    	});
__________________
Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx

Last edited by marilynn.fowler; 02-14-2011 at 01:05 AM..
marilynn.fowler is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:42 PM.


Advertisement
Log in to turn off these ads.