-1

我有以下设置 bxslider

    //<![CDATA[
  jQuery.noConflict();
  jQuery(document).ready(function(){
    var slider;
    slider = jQuery('#slider-popular').bxSlider({
            infiniteLoop: true,
            hideControlOnEnd: true,
            pager: false,
            randomStart: true,
            displaySlideQty: 4,
            moveSlideQty: 1,
            auto:true,
            autoDelay:500,
            autoHover: true,
            speed: 4000
    });

    jQuery('.bx-prev').on('click',function(){
        slider.goToPreviousSlide();
        slider.speed = 500;
        slider.startShow();
        return false;
    });

    jQuery('.bx-next').on('click',function(){
        slider.goToNextSlide();
        slider.speed = 500;
        slider.startShow();
        return false;
    });
  });
//]]>  

我想在单击上一个/下一个按钮时将滑块的速度提高到 500 而不是 4000

上面的代码不起作用(速度不增加!!!)

在正常方式自动模式下,它应该以 4000 的速度滚动,但在单击上一个/下一个按钮时,它应该以 500 的速度滚动

4

1 回答 1

2

我不确定这是否正是您要寻找的东西,但这就是我让它工作的方式。

        slideSpeedAdjusted = false;
        //Set variable so you know if slider speed has been adjusted already

       //Initial bxslider
        var slider = $('#slider-popular').bxSlider({
          infiniteLoop: true,
          hideControlOnEnd: true,
          pager: false,
          randomStart: true,
          displaySlideQty: 4,
          moveSlideQty: 1,
          auto:true,
          autoDelay:500,
          autoHover: true,
          speed: 500
        });

        //Sets bxslider speed to scroll to the next slide and adjust the speed
        //so that it doesn't take forever to get to the next slide

        //Also checks to see if slide speed has already been adjusted
        if(!slideSpeedAdjusted){
        $('.bx-next').click(function(e){
            //We want to make sure the slider is at the location on reload
            //that the user was at so we use this variable to reload the slider
            //at the correct position
            var current = slider.getCurrentSlide();
            e.preventDefault();
           //just reload the slider with the function given by bxslider
           //here you can recreate the slider with the variables you desire
            slider.reloadSlider({
                startSlide: current,
                infiniteLoop: true,
                hideControlOnEnd: true,
                pager: false,
                randomStart: true,
                displaySlideQty: 4,
                moveSlideQty: 1,
                auto:true,
                autoDelay:500,
                autoHover: true,
                speed: 500
            });
            //Set slideSpeedAdjusted to true so the slider doesn't
            //reload after it's been adjusted.
            slideSpeedAdjusted = true;
            });

        //same version for the previous button
        $('.bx-prev').click(function(e){
            var current = slider.getCurrentSlide();
            e.preventDefault();
            slider.reloadSlider({
                startSlide: current,
                infiniteLoop: true,
                hideControlOnEnd: true,
                pager: false,
                randomStart: true,
                displaySlideQty: 4,
                moveSlideQty: 1,
                auto:true,
                autoDelay:500,
                autoHover: true,
                speed: 500
            });
            slideSpeedAdjusted = true;
            });
        };
于 2015-03-18T17:26:22.790 回答