2

在项目中使用 BxSlider jQuery 内容滑块 ( http://bxslider.com/ )。我在窗口调整大小时使用“reloadShow() 函数,以便内容重新对齐到中心。

reloadShow() 函数正在工作,但每次都会将我的幻灯片重置为第一张。相反,我想记住它所在的幻灯片并重新加载到该幻灯片。

这是我的 JS:

$(function(){
    // assign the slider to a variable
    slider = $('#slider').bxSlider(
    {
        controls: false,
        auto: false
    });

    // assign a click event to the external thumbnails
    $('.thumbs a').click(function()
    {
        var thumbIndex = $('.thumbs a').index(this);
        // call the "goToSlide" public function
        slider.goToSlide(thumbIndex);

        // remove all active classes
        $('.thumbs a').removeClass('pager-active');
        // assisgn "pager-active" to clicked thumb
        $(this).addClass('pager-active');
        // very important! you must kill the links default behavior
        return false;

    });

    // assign "pager-active" class to the first thumb
    $('.thumbs a:first').addClass('pager-active');

    $(window).resize(function(e)
    {
        slider.reloadShow();
    });

});
4

0 回答 0