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 04-24-2011, 01:16 PM   PM User | #1
Mooseman
Regular Coder

 
Mooseman's Avatar
 
Join Date: Sep 2010
Posts: 118
Thanks: 7
Thanked 3 Times in 3 Posts
Mooseman is an unknown quantity at this point
Question .animate has automatic reverse?

I know this is a stupid question, but I am using this code for my "doors" and the effect does the inverse operation post-animation. How can I fix this? Thanks!

My jQuery:
Code:
$(document).ready(function() {
/* Elevator effects */
	$("#contactMenu").click(function () {
		$("#elevator-left").animate({"left": "1000px"}, "200");
		$("#elevator-right").animate({"right": "1000px"}, "200");
	});
});
My CSS:
Code:
div#elevator-right{
	position: fixed;
	width: 50%;
	background: #FFF;
	top: 0;
	bottom: 0;
	right: -1000px;
	margin-left: 100%;
	border-left: 5px #000
}
div#elevator-left{
	position: fixed;
	width: 50%;
	background: #FFF;
	top: 0;
	bottom: 0;
	left: -1000px;
	margin-right: 100%;
	border-right: 5px #000
}
My HTML(5):
Code:
<!--Elevator Doors-->
<!--Elevator Left-->
	<div id="elevator-left">
	<p>LEFT ELEVATOR DOOR</p>
	</div>
<!--Elevator Right-->
	<div id="elevator-right">
	<p>RIGHT ELEVATOR DOOR</p>
	</div>
My CSS and JS are external files; however other functions/styles do appear correctly. I am currently using Chrome 11.
Mooseman is offline   Reply With Quote
Old 04-25-2011, 11:57 AM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,604
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Don’t quite know what this looks like but are you aware that with the animate function you’re not setting the distance to animate but the absolute position the element is supposed to be animated to? I mean, you are not telling the element “animate 1000px to the left” but rather “animate left until the x-position at 1000px (from the reference point) is reached”. So, if you have the elements at -1000px and animate them to 1000px you’re actually animating them over a distance of 2000px.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 04-25-2011, 01:16 PM   PM User | #3
Mooseman
Regular Coder

 
Mooseman's Avatar
 
Join Date: Sep 2010
Posts: 118
Thanks: 7
Thanked 3 Times in 3 Posts
Mooseman is an unknown quantity at this point
It supposed to be touching each other in the center, width 50%. can you please give an example of the code for left to center? Thanks!
Mooseman is offline   Reply With Quote
Reply

Bookmarks

Tags
css, html, javascript, jquery, mooseman

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 05:34 AM.


Advertisement
Log in to turn off these ads.