【问题标题】:bx slider start/stop functionbx 滑块启动/停止功能
【发布时间】:2012-01-03 06:34:15
【问题描述】:

我正在使用 bxslider 插件,并为上一个和下一个功能创建了一些外部控件,尽管我似乎不知道如何对启动/停止控件执行相同操作。

基本上我想把它用作滑块的播放/暂停功能。

有人对这个插件有任何经验吗?

这是我目前所拥有的,没有启动/停止功能:

http://jsfiddle.net/WaWLN/1/

另外,我希望滑块“自动”播放,以及具有此外部控件。我刚刚注意到点击我的任何链接似乎会禁用自动播放,我必须刷新页面才能恢复。

【问题讨论】:

    标签: jquery slider bxslider


    【解决方案1】:

    我不知道你是否还需要这个问题的答案,但如果你更新你的代码到这个,它应该可以工作:

    var slider = $('#bxslider').bxSlider({
    
      auto: true,
    
      controls: false
    
    });
    
    $('#go-prev').click(function(){ 
    
      slider.goToPreviousSlide();
    
      slider.startShow(); //added this line
    
      return false;
    });
    
      $('#go-next').click(function(){
    
        slider.goToNextSlide();
    
        slider.startShow(); //added this line
    
        return false;
    
      });
    
      $('#my-start-stop').click(function(){
    
          /* added a class to your #my-start-start a tag called "stopShow", note: would recommend that you also change the text to say "Stop" when the show is active and "Start" when the show is not. :) */
    
          if($('#my-start-stop').attr('class') == 'stopShow'){
    
              slider.stopShow();
    
              $('#my-start-stop').removeClass('stopShow');
    
          } else {
    
              slider.startShow();
    
              $('#my-start-stop').addClass('stopShow');
    
    
          }
    
    
        return false;
      });
    

    【讨论】:

    • 值得补充的是,最新版本的 BXSlider 上不存在 stopShow() 和 startShow()。您应该改用 stopAuto()startAuto()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-29
    • 2016-02-09
    • 1970-01-01
    相关资源
    最近更新 更多