bx slider:如何在单击默认bx寻呼机后继续自动滑动?

use*_*671 13 navigation jquery bxslider

我想在点击bx寻呼机项目后继续自动滑动.

这是代码:

$(document).ready(function () {
    $('.bxslider').bxSlider({
        mode: 'horizontal', //mode: 'fade',            
        speed: 500,
        auto: true,
        infiniteLoop: true,
        hideControlOnEnd: true,
        useCSS: false
    });

    $(".bx-pager-link").click(function () {
        console.log('bla');            
        slider = $('.bxslider').bxSlider();
        slider.stopAuto();
        slider.startAuto();
        //slider.stopShow();
        //slider.startShow();
    });
});
Run Code Online (Sandbox Code Playgroud)

uncommented stopShow()startShow()函数根本不起作用.startAuto()继续播放幻灯片,但bx寻呼机导航被冻结.即使出现新幻灯片,活动点仍保持活动状态.怎么解决?

Jaw*_*aad 19

你可以这样试试:

$(document).ready(function () {
    var slider = $('.bxslider').bxSlider({
        mode: 'horizontal', //mode: 'fade',            
        speed: 500,
        auto: true,
        infiniteLoop: true,
        hideControlOnEnd: true,
        useCSS: false
    });

    $(".bx-pager-link").click(function () {
        console.log('bla');            
        slider.stopAuto();
        slider.startAuto();
    });
});
Run Code Online (Sandbox Code Playgroud)

或者您可以使用此:

$(document).ready(function () {
    var slider = $('.bxslider').bxSlider({
        mode: 'horizontal', //mode: 'fade',            
        speed: 500,
        auto: true,
        infiniteLoop: true,
        hideControlOnEnd: true,
        useCSS: false
    });

    $('.bx-pager-item a').click(function(e){
        var i = $(this).index();
        slider.goToSlide(i);
        slider.stopAuto();
        restart=setTimeout(function(){
            slider.startAuto();
            },500);

        return false;
    });
});
Run Code Online (Sandbox Code Playgroud)

第二个对我有用.

  • 谢谢!那是一个很大的帮助!但它不适用于你的i变量.必须是:var i = $(this).attr("data-slide-index"); ;) (5认同)

Vip*_*hva 6

以下代码在网站上正常工作.请试一试:

var slider = $('.bxslider').bxSlider({
    auto: true,
    pager: false,
    autoHover: true,
    autoControls: true,
    onSlideAfter: function() {
        slider.stopAuto();
        slider.startAuto();
    }
});
Run Code Online (Sandbox Code Playgroud)