【问题标题】:jQuery Slider - Progress BarjQuery 滑块 - 进度条
【发布时间】:2013-01-30 17:24:11
【问题描述】:

类似于:Jquery slider with progress bar

我有这个滑块和进度条,但我希望进度条与“上一个”和“下一个”按钮同步。因此,当您单击“下一步”时,进度条将从头开始。

http://jsfiddle.net/aidenguinnip/8rJws/

$(window).load(function(){
var currentIndex = 0;// store current pane index displayed
var ePanes = $('#slider .panel'), // store panes collection
    time   = 3000,
    bar = $('.progress_bar');

function showPane(index){// generic showPane
    // hide current pane
    ePanes.eq(currentIndex).stop(true, true).fadeOut();
    // set current index : check in panes collection length
    currentIndex = index;
    if(currentIndex < 0) currentIndex = ePanes.length-1;
    else if(currentIndex >= ePanes.length) currentIndex = 0;
    // display pane
    ePanes.eq(currentIndex).stop(true, true).fadeIn();
    // menu selection
    $('.nav li').removeClass('current').eq(currentIndex).addClass('current');
}
// bind ul links
$('.nav li').click(function(ev){showPane($(this).index());});
// bind previous & next links
$('.previous').click(function(){showPane(currentIndex-1);});
$('.next').click(function(){showPane(currentIndex+1);});
// apply start pane
showPane(0);

function run(){
    bar.width(0);
    showPane(currentIndex+1);
    bar.animate({'width': "+=400"}, time, run);
}

run();

});

【问题讨论】:

    标签: jquery slider progress-bar gallery progress


    【解决方案1】:

    给你...

    http://jsfiddle.net/8rJws/1/

    我在更改幻灯片时停止了动画并将条形宽度重置为 0,然后重新启动了动画(见第 10 行)...

    bar.stop(true, true).css("width", 0).animate({'width': "+=400"}, time, run);
    

    【讨论】:

    • 没问题 - 很高兴为您提供帮助 :)
    猜你喜欢
    • 1970-01-01
    • 2010-11-06
    • 1970-01-01
    • 2014-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多