【问题标题】:How to pause Jquery Cycle plugin mid animation (on hover)如何暂停 Jquery Cycle 插件中间动画(悬停时)
【发布时间】:2012-07-30 02:56:32
【问题描述】:

我正在使用 Jquery 循环并让它连续水平滚动。我希望动画在用户悬停时停止。我通过插件的“暂停:1”选项有这个工作排序,但它不会暂停,直到它循环到下一个图像,这很慢。我希望它在用户悬停时暂停动画中间,所以即使它在图像之间的中间,然后在鼠标悬停时恢复。这可能吗?

我的代码:

$('.gallery .continuous').each(function(index, element) {   
    $(element).cycle({ 
        fx:'scrollHorz',                
        continuous: 1,
        speed:10000,
        timeout:0,
        easing: 'linear',
        pause:1,
        pauseOnPagerHover: true,
    });
});

感谢您的帮助。

【问题讨论】:

  • 只是想我会再检查一次,有没有人知道如何做到这一点?!

标签: jquery cycle


【解决方案1】:

嗨,Desmond,你可以在你的 javascript 中试试这个。将其放入准备好的文档中

    $('.gallery .continuous').hover(
function(){
$(this).cycle('pause');  //Pauses the cycle on hover
},
function(){
$(this).cycle('resume'); // Resumes the cycle when mouse is outside div
});

我希望它对你有用。

【讨论】:

  • 感谢您的帮助帕里托什!
  • 检查一下,如果你使用的是同一个插件,正如我所期望的那样jquery.malsup.com/cycle/pause.html
  • 谢谢帕里托什。我将画廊设置为从左到右的连续动画,如果用户悬停,我希望它在循环中途停止 - 那些只会在动画结束时停止。
【解决方案2】:
<div id="slider">
        <img class="images" src="1.jpg">
        <img class="images" src="2.jpg">
        <img class="images" src="3.jpg">
        <img class="images" src="4.jpg">
    </div>

<!-- for example above mentioned is your html with container with id "slider"

then cycle code will be like that -->


    <script>
    //this is your cycling code!!!!!!!!!!!!!!!
      $('#slider').cycle({ 
        fx:      'scrollHorz', 
        timeout:   200,
        speed:   1000,
        next: '.right',
        prev: '.left'
    });

//if you want to pause you need to use .cycle("pause") for e.g:

//on mouseover.

        $('#slider').mouseover(function(){
            $('#slider').cycle('pause');
        });


    //and continue on mouse out

        $('#slider').mouseout(function(){
            $('#slider').cycle('resume');
        });

    </script>

【讨论】:

  • 欢迎来到 Stack Overflow!请不要对多个问题发布相同的答案。发布一个好的答案,然后投票/标记以关闭其他问题作为重复问题。如果问题不是重复的,调整您对该问题的回答。
  • 您好,欢迎来到 Stack Overflow!我想建议不要粘贴整个代码,只需键入答案并显示代码并解释它
猜你喜欢
  • 1970-01-01
  • 2019-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-01
  • 2012-02-09
  • 2011-12-12
  • 1970-01-01
相关资源
最近更新 更多