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. =[