jquery 中的间隔定时双淡出
哇我有问题吗?我试图创建一个骑行推荐区域,其中推荐和客户同时淡入和淡出。我使用 setInterval() 并遇到了很多问题。我还认为我完全误解了queue()。
它不遵循我的“counter++ 变量”。元素在重复。而且时间很快就会变得不匹配。有人可以告诉我我做错了什么吗?
如果你查看这个 jsfiddle 代码,你就会明白我想要做什么。
非常感谢!
WOW am i having problems. Im trying to create a cycling testimonials area where the testimonial and client fade in and out at the same time. Im using setInterval() and having a bunch of issues. Im also thinking I am completely misunderstanding queue().
It's not following my 'counter++ variable'. The elements are repeating. And the timing gets mismatched real fast. Can someone pls tell me what im doing wrong?
If you check out this jsfiddle code you'll see exactly what im trying to do.
thanks so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你可能让它变得比需要的更复杂:)。我写了 一个快速的 jsFiddle 供参考,但我想说你可以做一些更改您构建标记的方式将使转换更加清晰:
将推荐和客户保留在标记中而不是数组中。仅当您要执行诸如通过 ajax 提取评论之类的操作时才使用数组。
不要太担心队列方法或跟踪计数器。相反,在元素上使用类名来跟踪当前正在显示的元素(我的 jsFiddle 显示了这一点)。
如果您查看示例代码,您还可以轻松应用效果。您可以使用类似 fadeToggle()。
I think you may be making it more complicated than it needs to be :). I wrote up a quick jsFiddle for reference, but I'd say that you could make a couple of changes to the way you've got your markup structured that would make the transitions much cleaner:
Keep the testimonials and clients in the markup rather than an array. Only use an array if you're going to be doing something like pulling the comments via ajax.
Don't worry too much about the queue method or keeping track of counters. Instead, use a classname on the elements to track which ones are currently being displayed (my jsFiddle shows this).
If you take a look at the sample code, you can also easily apply effects. Rather than using toggle(), you could use something like fadeToggle().