【发布时间】:2011-03-12 14:32:14
【问题描述】:
最终编辑:下面的文字墙可以简单地总结为“我可以使用jQuery的animate()指定动画的速度吗?提供的只是duration。”
~~
jQuery 的animate() 似乎实现了缓动,尽管我使用了“线性”。我怎样才能让两个盒子保持在一起,直到第一个完成@ 250px?第二个动画更快,因为它有更长的距离。
<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>
或者is there a jQuery carousel plugin that does this(鼠标移动取决于你的鼠标位置)所以我不必重写它?我花了大约 20 分钟在 Google 上寻找一个,但找不到任何我喜欢的东西。
ETA:我提供的示例非常简单,但我发现它的问题适用于更复杂的代码库。 (1) Go here. (2) 将鼠标放在 C. Viper 上,看速度。 (3) 将鼠标放在 Ryu 上,但在完成之前,将鼠标移动到 DIV 的中间(因此它停止)。 (4) 将鼠标放回左侧,看看它的移动速度有多慢。
在这里计算速度和距离的差异似乎是不可逾越的。我要做的就是重新创建我今天看到的网站使用的可爱效果 (this site)。但它是 Mootools,我在 jQuery 中。 =[
【问题讨论】:
-
链接 (1) 不起作用
标签: jquery jquery-animate