bx slider start/stop function

此生再无相见时 提交于 2019-12-07 08:49:29

问题


I'm using the bxslider plugin, and have created some external controls for the previous and next function, although I cant seem to figure out how to do the same with the start/stop control.

Basically I want to use this as a play/pause function for the slider.

Does anyone have any experience with this plugin?

Here's what I have so far, without the start/stop function working:

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

Also, I want the slider to "auto" play, as well a having this external controls. I just noticed that clicking on any of my links seems to disable the auto play, and I have to refresh the page to get it back.


回答1:


I don't know if you still need an answer to this, but if you update your code to this, it should work:

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;
  });


来源:https://stackoverflow.com/questions/8708743/bx-slider-start-stop-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!