Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:41:28+00:00 2026-05-15T13:41:28+00:00

Final Edit : The wall of text below can be summed up by simply

  • 0

Final Edit: The wall of text below can be summed up by simply asking “can I specify the speed of animations using jQuery’s animate()? All that is provided is duration.”

~~

jQuery’s animate() seems to implement easing despite my use of “linear”. How can I get the two boxes to stay together until the first finishes @ 250px? The second animates much faster because it has a longer distance to go.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
    $(function()
    {
        $('#a').animate({left: '250px'}, 1000, 'linear');
        $('#b').animate({left: '500px'}, 1000, 'linear');
    });
</script>

<div id="a" style="background-color: red; position: relative; width: 50px; height: 50px;"></div>
<br/><br/>
<div id="b" style="background-color: red; position: relative;width: 50px; height: 50px;"></div>

Alternatively is there a jQuery carousel plugin that does this (mouse movement based on where you’re mousing) so I don’t have to rewrite it? I spent about 20 minutes looking for one on Google but couldn’t come up with anything I liked.

ETA: The example I provided is very simple, but the issue as I found it is applied to a more complex code base. (1) Go here. (2) Put mouse on C. Viper, see the speed. (3) Put mouse on Ryu, but before it finishes, move your mouse to the middle of the DIV (so it stops). (4) Put your mouse back on the left side and see how utterly slow it moves.

Calculating the differences in speed and distance seems insurmountable here. All I’m trying to do is recreate a lovely effect I saw a site use today (this site). But it’s Mootools, and I’m in jQuery. =[

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:41:28+00:00Added an answer on May 15, 2026 at 1:41 pm

    For the updated question:
    First, here’s a working demo with the behavior you want. What we’re doing here is adjusting the speed based on the amount needed to move, because speed isn’t an accurate description, it’s the duration, moving a shorter distance over the same duration means a slower move, so we need to scale the duration with the distance we need to move. For moving backwards, it looks like this:

    var oldLeft = ul.offset().left;
    ul.animate({left: 0}, -oldLeft * speed, 'linear');
    

    Since the <ul> scrolls with a negative left position, we need to move the inverse of that many pixels to get back to the beginning, so we’re using -oldLeft (it’s current left position).

    For the forward direction, a very similar approach:

    var newLeft = divWidth - ulWidth,
        oldLeft = ul.offset().left;
    ul.animate({left: newLeft + 'px'}, (-newLeft + oldLeft) * speed, 'linear');
    

    This gets the new left property, the end being the width of the <ul> minus the width of the <div> it’s in. Then we subtract (it’s negative so add) that from the current left position (also negative, so reverse it).

    This approach gives your speed variable a whole new meaning, it now means “milliseconds per pixel” rather than the duration it did before, which seems to be what you’re after. The other optimization is using that cached <ul> selector you already had, making things a bit faster/cleaner overall.


    For the original question:
    Keep it simple, just half the time for half the distance, like this:

    $(function() {
        $('#a').animate({left: '250px'}, 500, 'linear');
        $('#b').animate({left: '500px'}, 1000, 'linear');
    });
    

    You can try a demo here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: With enough rewriting, and commenting, I have it running, will post final below
Can final keyword be used for a method?
My final goal is to write the program which can run on the Unix
I am using following code to post image on Facebook wall. it's working fine.
FINAL EDIT: It does indeed appear to be a compiler bug - see the
FINAL EDIT: This turned out to be a stack overflow problem related to neither
read final edit for solution I'm try update the onclick function of a link
Final Edit: I was able to locate the duplicate field in the ini file.
final ProgressDialog Pdialog = ProgressDialog.show(SpinnerClass.this, , Loading. Please wait..., true); Thread ProgressThread = new
final String message[] = {,,}; try{ String UID = null, UBAL = null; DateFormat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.