【问题标题】:How to prevent cycle plugin to autoplay?如何防止循环插件自动播放?
【发布时间】:2013-12-31 21:48:46
【问题描述】:

我正在使用循环插件并且它运行良好。但是滑块一直在滑动,我不知道应该使用什么选项来防止它自动播放。

$('#thumbs').cycle({
            fx: 'scrollHorz',
            prev: '.thumbPrev',
            next: '.thumbNext'
        });

我还检查了循环的选项参考http://jquery.malsup.com/cycle/options.html,但我没有发现任何有用的东西..

【问题讨论】:

  • autostop: 0, // true to end slideshow after X transitions (where X == slide count) autostopCount: 0, // number of transitions (optionally used with autostop to define X) 可以结合使用吗?
  • ... to prevent it autoplay 错过了这一点
  • 我为您提供了插件作者在 jquery 论坛上回答相同问题的参考。

标签: jquery-cycle


【解决方案1】:

我找到了解决办法

$(elem).cycle({
    timeout: 0 //milliseconds between slide transitions (0 to disable auto advance)
});

超时是标准定义的 4000

【讨论】:

    【解决方案2】:

    循环后立即:

    $('#thumbs').cycle('pause')
    

    或者根据 jquery cycle 的作者,我的原始答案的更精简版本:

        $('#thumbs').cycle({
            fx: 'scrollHorz',
            prev: '.thumbPrev',
            next: '.thumbNext'
        }).cycle('pause');
    

    参考:http://forum.jquery.com/topic/cycle-plugin-no-autostart-click-to-start-slideshow

    【讨论】:

      【解决方案3】:

      将超时设置为零。这是一个例子:

      <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
      <script type="text/javascript" src="js/jquery.cycle.all.js"></script>
      <script type="text/javascript">
      $(document).ready(function() {
      $('#porta-slide-demo').cycle({ 
          fx:     'fade', 
          speed:  'fast', 
          timeout: 0, 
          next:   '#para', 
          prev:   '#prapa' 
      });
      });
      </script>
      

      ........

      <div id="porta-slide-demo">
      <img src="demo-images/01.jpg" width="450" height="300" />
      <img src="demo-images/02.jpg" width="450" height="300" />
      <img src="demo-images/03.jpg" width="450" height="300" />
      </div>
          <div>
          <a id="prapa" href="#">Prapa</a>
          <a id="para" href="#">Para</a>
          </div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-05-31
        • 1970-01-01
        • 2015-08-27
        • 1970-01-01
        • 1970-01-01
        • 2014-02-11
        • 2023-04-10
        • 1970-01-01
        相关资源
        最近更新 更多