0

我想将此滑块设置为自动滚动。现在,我对此很陌生,并且从其他人那里获取了一段代码。谁能告诉我如何将其设置为自动滚动?

我尝试过自己编辑,但无济于事!

如果需要,这里是完整 .js 文件的链接。http://jsfiddle.net/CMCPB/

mainCycle: {
    currentIndex: 0,
    slidersSpeed: 500,
    resizing: 0,
    objLib: {
        cycleA: $('section.cycle-a'),
        cycleNav: $('#cycle-1-nav'),
        allSliders: $('section.cycle-a > article'),
        cycleNavContainer: $('nav.cycle-nav-container'),
        nextButton: null,
        prevButton: null
    },
    init: function () {
        var self = this;
        self.cycleInit();
    },
    cycleInit: function () {
        var self = this;
        if (self.objLib.cycleA.length) {
            var startIndex = self.getIndexByHash();
            self.generateNavButtons();
            self.cycleStart(startIndex);

            self.horzNavInit();
            self.prevNavCycleStart();
            self.nextNavCycleStart();
            self.setNavigation(startIndex);

            //resize event listener
            self.resizeAction();

            //history event listener
            self.historyAction();

            //mousewheel event listener
            self.mouseWheelAction();

            //keyboard navigation
            self.keyboardNavigation();

            //gestures navigation
            self.gesturesNav();
        }
    },
    cycleStart: function (startingIndex) {
        var self = this;

        if (startingIndex) {

        } else {
            startingIndex = 0;
        }

        self.mainSlider = self.objLib.cycleA.cycle({
            fx: 'scrollHorz',
            speed: self.slidersSpeed,
            timeout: 0,
            autostop: 0,
            init: 1,
            /*easing : "swing",*/
            next: self.objLib.nextButton,
            prev: self.objLib.prevButton,
            manualTrump: false,
            startingSlide: startingIndex,
            before: function (curr, next, opts, fwd) {
                //alert(opts.fx);
                self.objLib.cycleA.scrollTop(0);
                if (opts.init === 1) {
                    var index = startingIndex;
                    opts.init = 0;
                    self.currentIndex = index;
                } else {
                    var index = opts.nextSlide;
                    self.currentIndex = index;
                    self.cycleEffect($(next), fwd);
                }
                self.activeNavChanger(index);
            },
            after: function (curr, next, opts) {
                //set new document location hash
                var myId = $(next).attr('id');
                var hash = document.location.hash.replace('#', '');
                if (hash != myId) {
                    $('#' + myId).attr('id', '_' + myId);
                    document.location.hash = '#' + myId;
                    $('#_' + myId).attr('id', myId);
                }
            }
        });
    },
4

0 回答 0