jQuery Cycle 插件 - 暂停/恢复奇怪的行为

标签 jquery jquery-plugins jquery-cycle

我有一个使用很棒的循环插件运行的幻灯片,当您单击演示中的按钮时,我会在页面上显示一个隐藏层并发送“暂停”命令来循环。我有两个问题:

  1. 收到暂停命令后,循环立即翻转回序列中的第一张幻灯片(为什么?),并且不会触发我的之前/之后回调。

  2. 关闭图层后,我发送“恢复”命令进行循环。幻灯片恢复(从第一张幻灯片开始,暂停处),但现在循环根本不调用我的之前/之后回调,即使幻灯片正在进行。

所以我想我的问题是:如何正确暂停/恢复幻灯片放映,以免发生这些奇怪的行为? (为了完全清楚并避免任何混淆,这与“悬停时暂停”功能无关,该功能实际上对我来说效果很好。:-)

这是我的cycle() init 和我的回调函数。 (您可能会问,为什么我要手动跟踪下一张幻灯片?因为当前幻灯片的内置值无法针对之前/之后的回调正确更新。)

  $(document).ready(function() {
    $('#slideshow').cycle({
      fx: 'fade',        // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout:       4000,  // milliseconds between slide transitions (0 to disable auto advance)
        speed:         1000,  // speed of the transition (any valid fx speed value)
        pause:         1,     // true to enable "pause on hover"
        delay:         0,     // additional delay (in ms) for first transition (hint: can be negative)
        slideExpr:     'img',  // expression for selecting slides (if something other than all children is required)
        before:       moveArrow, // function to call when moving to next slide
        after:       upd, // function to call when moving to next slide
        fastOnEvent:   'fast',
    });
  });

  var nextSlide = 0;

  function upd(a, b, c) {
    nextSlide = nextSlide + 1;        // track which slide we're on
    c = $('#slideshow img').length;
    if(nextSlide > (c - 1)) nextSlide = 0;   // wrap back to 1st
  }

  // move indicator showing which slide we're on
  function moveArrow(a, b, c) {
    $('#slide-indicator').attr('class', 'c'+nextSlide);

    $(".clickmap").hide();          // hide other clickmaps
    $(".clickmap.c"+nextSlide).show();    // show map for this slide

    return true;
  }

感谢您对此的任何想法--

最好的, 埃里克

最佳答案

我遇到了同样的问题,暂停和恢复不起作用。看起来我已经安装了精简版,完整/完整版本可以正常工作。

关于jQuery Cycle 插件 - 暂停/恢复奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3286736/

相关文章:

jQuery UI Datepicker 在打字过程中速度缓慢

javascript - 如何让div出现在用户点击的位置?

javascript - 当一个页面中有多个脚本时,如何禁用下一个脚本标签?

jquery - 创建 jQuery 插件最优雅的方法是什么?

javascript - 如何在页面加载前使用 CSS 在响应式 slider 上设置高度

c# - 如何选择特定图像并从特定网址保存? (内有说明)

javascript - 来自 <ul> 结构的 js dynatree 插件 - 如果其根节点禁用单选按钮选择

jquery - 滑动框过渡效果

javascript - 在 jQuery Cycle 插件中单击时暂时禁用下一个/上一个按钮(链接)(不一定是 jQuery 循环问题)

jQuery Cycle 创建太多分页器链接