我目前正在使用jQuery.Cycle循环访问一些孩子< div>标签.但是,我希望默认循环fx为淡入淡出,当我单击下一个或上一个选择器时,我希望循环fx暂时更改为scrollRight或scrollLeft,具体取决于单击的选择器.
这可能吗?
jQuery代码,如有必要:
$('#banner_content').cycle({
fx: 'fade',// choose your transition type,ex: fade,scrollUp,shuffle,etc...
timeout: 6500,speed: 2000,next: $("#right_arrow a"),prev: $("#left_arrow a"),});
解决方法
好的,我在
jQuery Forum上添加了我的问题,创作者回复了以下
answer.
这是我为此开发的代码:
var slideIndex = 0;
var nextIndex = 0;
var prevIndex = 0;
$('#banner_content').cycle({
fx: 'fade',//fx: 'scrollHorz',etc...
timeout: 8000,speed: 1000,easingIn:20,easingOut:40,after: function(currSlideElement,nextSlideElement,options) {
slideIndex = options.currSlide;
nextIndex = slideIndex + 1;
prevIndex = slideIndex -1;
if (slideIndex == options.slideCount-1) {
nextIndex = 0;
}
if (slideIndex == 0) {
prevIndex = options.slideCount-1;
}
}
});
$("div.left_arrow a").click(function () {
$('#banner_content').cycle(nextIndex,"scrollRight");
});
$("div.right_arrow a").click(function () {
$('#banner_content').cycle(prevIndex,"scrollLeft");
});