jQuery Cycle - 一个循环中的两个动画

时间:2011-01-16 13:53:00

标签: jquery animation cycle effect jquery-effects

我用jQuery Cycle制作了幻灯片,但我对定时器有问题。经过几个周期,他们搞砸了。如何在一个函数和一个计时器中合并两个循环动画?

感谢您的帮助。

的xHTML:

<div id="slideshow">
  <ul>
    <li>
      <div class="image"><img src="test.jpg" /></div>
      <div class="description">Some text goes here</div>
    </li>
    <li>
      <div class="image"><img src="test.jpg" /></div>
      <div class="description">Some text goes here</div>
    </li>
    <li>
      <div class="image"><img src="test.jpg" /></div>
      <div class="description">Some text goes here</div>
    </li>
  </ul>
</div>

jQuery的:

var img = $(this).find('#slideshow div.image');
var desc = $(this).find('#slideshow div.description');
$('#slideshow ul').cycle({
    fx:    'scrollHorz', 
    speed:  'fast', 
    timeout: 5000,
    next:   '.next',
    pause: 1,
    slideExpr: img
});
$('#slideshow').cycle({
    fx:    'scrollVert', 
    speed:  'fast', 
    timeout: 5000,
    next:   '.next',
    pause: 1,
    slideExpr: desc
});

1 个答案:

答案 0 :(得分:0)

我认为你应该:

  1. 为时间处理问题制作自己的自定义函数(一个相当简单的JS函数可以解决这个问题)。
  2. 将周期中的“超时”属性设置为0,这样就不会自动执行。
  3. 使用以下格式在自定义函数中使用可用命令“prev”和“next”:

  4. $('#slideshow').cycle('next');
    

    我在你的代码中看到了这个方法,感谢你刚才给我的好主意。