【发布时间】:2014-03-09 05:52:58
【问题描述】:
我有一个包含 4 个 jquery 元素的数组。
<div class="wrapper">
<img class="image">
<img class="image">
<img class="image">
<img class="image">
</div>
在 jQuery 中:
var images = $('.image');
对于我的幻灯片效果(例如左侧的幻灯片)我做了类似的事情(这不是我的完整代码,幻灯片效果有效!)
$('.wrapper').prepend($('.image').last());
$('.wrapper').css('margin-left', '0px');
$('.wrapper').animate({'margin-left', '-100px'}, 1000);
我的包装器向左滑动。现在,我想在幻灯片的同时转换我的图像。
if(images.index() === 0) {
// some css for this image (I do my transformation width css transition)
} else if(images.index() === 1) {
// do some other transformation with css
}
我将if 包含在我的animate() 中(目前,在complete 中)。
所以我的包装器向左滑动,我的数组元素按照它们应该的方式进行变换,但仅在幻灯片动画的结尾处。我需要在我的幻灯片效果时进行这种转换。
喜欢:
while(images.index() >= 0 && images.index() <= 1) {// do transformation while this is true}
【问题讨论】:
-
我用 prepend 和 append 改变了我的数组。我需要时间来追加或前置。谢谢
-
你有没有尝试过?
-
没有。我不知道什么时候需要为我的数组元素设置动画。我的元素“二”从第 2 位滑到第 1 位。在这个过程中,我想转换这个元素。