jQuery 循环幻灯片计数

发布于 2024-09-03 18:42:10 字数 508 浏览 2 评论 0原文

我目前正在使用一个名为 Cycle 的 jQuery 插件,并且想调整一小部分功能,但不喜欢真的不知道怎么办。

我制作了一个示例,可以在 jsbin 上在此处查看

我遇到的问题是实际的幻灯片“计数器”。按照当前配置的方式,当前所在的幻灯片在淡入淡出完成之前不会更新。这是通过插件“after”回调完成的。 更多选项位于此处

然而,我想做的是,一旦动画开始,数字就会改变。因此,基本上第二张幻灯片 2 将开始播放动画,计数将变为“3 中的 2”。

任何帮助将不胜感激。如有必要,将发送cookie。

Im currently using a plugin called Cycle for jQuery and would like to tweak a small piece of functionality but don't really know how.

I made an example which can be viewed here on jsbin.

The issue that I am having is with the actual slide "counter." The way that its currently configured, the current slide that it is on does not update until the fade has finished. This is done through the plugins "after" callback. More of the options are here.

What I would like to do however is make it to where as soon as the animation starts, the number changes. So essentially the second slide 2 would start to animate in, the count would go "2 of 3"

Any help would be greatly appreciated. Will send cookies if necessary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听风念你 2024-09-10 18:42:10
$('#slideshow-container').cycle({
    speed:  '1200',
    after: onAfter,
    timeout: 1200
  });
});

function onAfter(curr, next, opts) {
     var slide;
     slide = opts.currSlide + 1;
     var caption1 = (slide) + ' of ' + opts.slideCount;
     $('#count').html(caption1);
}

我知道这篇文章很旧,但很有帮助,我做了一些更正,这对我有用。

$('#slideshow-container').cycle({
    speed:  '1200',
    after: onAfter,
    timeout: 1200
  });
});

function onAfter(curr, next, opts) {
     var slide;
     slide = opts.currSlide + 1;
     var caption1 = (slide) + ' of ' + opts.slideCount;
     $('#count').html(caption1);
}

I know this post was old but it was helpful, I did some corrections and this worked for me.

天煞孤星 2024-09-10 18:42:10

不熟悉这个插件,但以下更改可能会帮助您:

jQuery(function(){

$('#slideshow-container').cycle({
    speed:  '1200',
    before: before,
    timeout: 1200
  });
});

started = false;
function before(curr,next,opts) {
  var slide = (!started ) ? 1 : opts.nextSlide + 1;

  started = true;
  var caption1 = '(' + (slide) + ' of ' + opts.slideCount + ')';
  $('#count').html(caption1);
}

Not familiar with this plugin but the following changes might help you with this:

jQuery(function(){

$('#slideshow-container').cycle({
    speed:  '1200',
    before: before,
    timeout: 1200
  });
});

started = false;
function before(curr,next,opts) {
  var slide = (!started ) ? 1 : opts.nextSlide + 1;

  started = true;
  var caption1 = '(' + (slide) + ' of ' + opts.slideCount + ')';
  $('#count').html(caption1);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文