【问题标题】:anythingSlider onShowPause任何东西滑块 onShowPause
【发布时间】:2014-12-22 01:55:50
【问题描述】:

我有两个滑块。当悬停在其中一些上时,它们必须同时停止。 我的代码:

    $('.slider').anythingSlider({   
                autoPlay            : true,
                delay               : 1000,  
                autoPlayLocked      : true,
                infiniteSlides      : false,
                stopAtEnd           : false,

                onShowUnpause : function(e, slider){
                    $('.slider').each(function() {
                        $(this).data('AnythingSlider').startStop();
                    });

                },

                onShowPause: function(e, slider){
                    $('.slider').each(function() {
                        $(this).data('AnythingSlider').startStop(false);
                    });

                }
            });

但这不起作用

【问题讨论】:

  • 不确定你想要什么。你能解释一下吗?
  • 我想同步两个滑块。他们在自动播放上滑动。但是如果将鼠标悬停在其中一些上 - 必须停止两者(pauseOnHover:true)。

标签: jquery anythingslider


【解决方案1】:

当使用startStop() 函数时,它实际上完全停止了幻灯片放映,因此onShowUnpause 函数永远不会触发。试试这个(demo):

$('.slider').anythingSlider({
    autoPlay: true,
    delay: 1000,
    resumeDelay : 1000,
    autoPlayLocked: true,
    infiniteSlides: false,
    stopAtEnd: false,
    onShowPause: function (e, slider) {
        $('.slider').each(function () {
            $(this).data('AnythingSlider').startStop();
        });
    }
}).on('mouseleave', function () {
    $('.slider').each(function(){
        $(this).data('AnythingSlider').startStop(true);
    });
});

【讨论】:

    猜你喜欢
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多