根据幻灯片索引更改 Malsup Cycle 的效果/效果
我有一个正在使用 malsup 循环 的画廊,我想根据被单击的链接索引(scrollLeft 或scrollRight)。我知道 .live()
在这种情况下可能会起作用,但我不确定如何以编程方式实现。下面的代码可以让您了解我想要做什么。
var animDir = 'scrollLeft';
var animIndex = 0;
$("#colors").cycle({
fx : animYarisDir,
timeout : 0
});
$("#color-controls > li a").click(function(e){
e.preventDefault();
$this = $(this),
i = $this.parent().index() -2;
if (i > animIndex ){
animDir = "scrollLeft";
} else {
animDir = "scrollRight";
};
$("#colors").cycle(i);
animIndex = i;
})
提前谢谢你,
JN
I have a gallery that I am using malsup's cycle on and I would like to change the effect based on the link that was clicked index (scrollLeft or scrollRight). I know .live()
would probably work in this situation but I am not sure how to implement programatically. Below is the code to give an idea of what I would like to do.
var animDir = 'scrollLeft';
var animIndex = 0;
$("#colors").cycle({
fx : animYarisDir,
timeout : 0
});
$("#color-controls > li a").click(function(e){
e.preventDefault();
$this = $(this),
i = $this.parent().index() -2;
if (i > animIndex ){
animDir = "scrollLeft";
} else {
animDir = "scrollRight";
};
$("#colors").cycle(i);
animIndex = i;
})
Thank you in advance,
JN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哎哟!我的答案的关键是将
fx : "scrollHorz"
传递给 Cycle 选项,而 Cycle 可以为你工作。Doh! The ticket to my answer was to pass
fx : "scrollHorz"
to the options for cycle and cycle does the work for you.