开发者

Jquery Cycle - 'next', 'prev', & pause actions reset autostop & autostopCount?

I'm working with a Jquery cycle slideshow, and I want to stop at the last slide, but autostop seems to reset itself upon any resume, next, or prev action.

For example, say I've got this slideshow:

<div id="slideshow">
<div id="slide_0">
    <img src="0.jpg">
    <div class="caption">lorem ipsum</div>
</div>
<div id="slide_1">
    <img src="1.jpg">
    <div class="caption">lorem ipsum</div>
<开发者_StackOverflow社区/div>
<div id="slide_2">
    <img src="2.jpg">
    <div class="caption">lorem ipsum</div>
</div>
<div id="slide_3">
    <img src="3.jpg">
    <div class="caption">lorem ipsum</div>
</div>
</div><!--#slideshow-->

<div id="navigation">
    <a id="next">NEXT</a>
    <a id="prev">PREV</a>
</div><!--#navigation-->

<script type="text/javascript">
$('#slideshow').cycle({
    fx: 'fade', 
    speed: 1000,
    timeout: 7000,
    autostop: true,
    next: '#next',
    prev: '#prev'
});
</script>

if, while the slideshow is playing, I hit '#next' twice, it will actually stop the slideshow on #slide_1, instead of on #slide_3. Pausing and resuming seems to reset the counter as well. I tried using autostopCount and it seems to be in the same boat.

My javascript isn't the best, but I've been thinking of how I might be able to use the OnAfter callback to do a check for the slide number, but I don't know how to get information out of the cycle object, or what its variables are. Thoughts?

Thanks!


Try this:

<script type="text/javascript">
var slider = $('#slideshow').cycle({
    fx: 'fade', 
    speed: 1000,
    timeout: 7000,
    after: function(curElement, nextElement, options, forwardFlag) {
       if (options.currSlide == 3) 
          setTimeout(function(){slider.cycle('stop'); }, 1000);
    },
    next: '#next',
    prev: '#prev'
});
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜