7

我目前正在使用jQuery.Cycle循环浏览一些子<div>标签。但是,我希望默认循环 fx 为fade,并且当我单击nextorprev选择器时,我希望循环 fx 临时更改为scrollRightscrollLeft取决于单击的选择器。

这可能吗?

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"),
});
4

1 回答 1

11

好的,我在jQuery 论坛上添加了我的问题,创建者回复了以下答案

这是我为此开发的代码:

var slideIndex = 0;
var nextIndex = 0;
var prevIndex = 0;

$('#banner_content').cycle({
    fx: 'fade',//fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, 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");
});
于 2010-07-19T07:44:14.587 回答