4

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.

user1031508
  • 97
  • 1
  • 1
  • 8

1 Answers1

4

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;
  });
Flexo
  • 87,323
  • 22
  • 191
  • 272
Kate Houst
  • 41
  • 2
  • 4
    Worth adding that stopShow() and startShow() don't exist on the latest version of BXSlider. You should instead use `stopAuto()` and `startAuto()` – Chris Jul 31 '14 at 14:53