Jquery 动画帮助
我正在尝试使用 Jquery 创建连锁反应。通过让一个元素一个接一个地“弹跳”。我可以使用它,但不确定为什么它只能以这种方式工作。首先是代码。
//First Part (I Don't know why I need it?)
$(elements).queue(function(){
$(this).fadeTo("fast",1);
$(this).dequeue();});
//The Actuall Ripple Effect
for (var i = 0; i < elements.length; i++)
$(elements[i]).effect("bounce",{times:1}).delay(i * 50);
}
如果我删除第一部分,所有元素都会同时弹起。所以我的问题是为什么会发生这种情况,他们有解决办法吗?
我正在使用 Jquery 1.4.2 “元素”是内联无序列表中的图像
//edit 我忘了声明弹跳效果来自 Jquery UI。
I am trying to create a ripple effect with Jquery. By having an element "bounce" one right after the other. I have it working but not sure as to why it only works this way. First off here is the code.
//First Part (I Don't know why I need it?)
$(elements).queue(function(){
$(this).fadeTo("fast",1);
$(this).dequeue();});
//The Actuall Ripple Effect
for (var i = 0; i < elements.length; i++)
$(elements[i]).effect("bounce",{times:1}).delay(i * 50);
}
If I were to remove the first part all the elements would bounce at the same time. So My question is why does this happen and is their a way around it?
I am using Jquery 1.4.2
and the "elements" are images inside an inline un-ordered list
//edit I forgot to state that the bounce effect comes from Jquery UI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只是将
.delay()
放在了效果的错误一侧。尝试一下: http://jsfiddle.net/MF3A8/ (单击顶部的“运行”按钮重播)
并且您可以使用
.eq()
引用 jQuery 对象中的正确元素。You just have
.delay()
on the wrong side of the effect.Try it out: http://jsfiddle.net/MF3A8/ (click the Run button at the top to replay it)
And you can use
.eq()
to reference the proper element in the jQuery object.尝试:
其中 400 是延迟的持续时间(以毫秒为单位)。 bogusAttribute 可以是 CSS 规范中没有的任何内容,属性值也可以是任何内容,基本原理是让元素忙碌而不真正设置动画。
element.delay()
暂停排队效果 — 它“[设置]一个计时器来延迟队列中后续项目的执行”,因此element.firstAnimationMethod(/*arguments*/).delay(400).secondAnimationMethod(/ * 参数 */)
有效。那将是:
Try:
Where 400 is the duration of the delay in milliseconds. the bogusAttribute can be anything that is not in the CSS specs, and the attribute value can also be anything, rationale being just getting the element busy without really animating.
element.delay()
suspends queued effects — it “[sets] a timer to delay execution of subsequent items in the queue”, soelement.firstAnimationMethod(/* arguments */).delay(400).secondAnimationMethod(/* arguments */)
works.That’ll be: