bx滑块启动/停止功能 [英] bx slider start/stop function

查看:86
本文介绍了bx滑块启动/停止功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用bxslider插件,并且为上一个和下一个功能创建了一些外部控件,尽管我似乎无法弄清楚如何使用开始/停止控件来实现同样的功能.

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.

推荐答案

我不知道您是否仍然需要这个答案,但是如果您将代码更新为此,它应该可以工作:

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

这篇关于bx滑块启动/停止功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆