jQuery循环淡入顺序变化
问题描述:
$('.rotateme').cycle({fx:'fade',speed:2500,timeout:3000,next:'#arrowright',prev:'#arrowleft',sync:1,pause:1});
海德斯,上面的代码是我用于图像滑块,其中图像在一个循环(这是显而易见)淡出。jQuery循环淡入顺序变化
无论如何,这是发生了什么:
当它的循环通过li
元素,以前的按钮返回我刚刚淡出li
元素,然后继续在列表中向下。
我想什么要发生的事情:
我想前面的按钮,我返回到先前的元素和反向的方向,所以它不会去背下来的列表,而是会去了。
显而易见的解决方案是为#arrowright
单独绑定使用,使:
rev: 0, // causes animations to transition in reverse
此作品在一定程度上,在这里失败:如果我再次点击#arrowright
,它会再次扭转方向(DOH)的含义#arrowright
实际上是一个切换按钮,我不需要那个...
有什么建议吗?
答
//此代码段将向“#arrowRight”添加一个“selected”类,并从“#arrowLeft”中删除一个“selected”类。然后,在运行.cycle()时,它会看到“#arrowRight”是否具有“selected”类,如果是,则.cycle()将在没有rev:0变量的情况下运行。否则,它会正常反转。当用户点击“#leftArrow”时,“selected”类将被删除。
if($("#arrowRight").hasClass("selected")) {
$('.rotateme').cycle({
fx:'fade',
speed:2500,
timeout:3000,
next:'#arrowright',
prev:'#arrowleft',
sync:1,pause:1
});
}
else{
$('.rotateme').cycle({
fx:'fade',
speed:2500,
timeout:3000,
next:'#arrowright',
prev:'#arrowleft',
sync:1,pause:1
rev: 0
});
}
$("#arrowRight").click({
$(this).addClass({"selected"});
$("#arrowLeft").removeClass({"selected"});
});
$("#arrowLeft").click({
$(this).addClass({"selected"});
$("#arrowRight").removeClass({"selected"});
});
工作就像一个魅力,非常感谢。 – Kirill 2009-09-28 09:57:34