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

查看:16
本文介绍了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天全站免登陆