Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts

    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.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,917
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    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.

  • #3
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts
    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!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •