繁体   English   中英

按钮悬停时连续滚动jCarousel

[英]Continuously scroll jCarousel on button hover

我正在使用jCarousel插件,我遇到了路障......

每当导航按钮悬停时,我都需要旋转木马连续滚动。 将内置配置变量更改为“鼠标悬停”只需在每个悬停时滚动一次。

我遇到了这个类似的问题,但我不是一个JavaScript专家,无法得到工作的答案。

这是我的代码:

    function mycarousel_initCallback(carousel)
{

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 10,
        start: 1,
        scroll: 1,
        animation: 'slow',
        wrap: 'circular',
        buttonNextEvent: 'mouseover',
        buttonPrevEvent: 'mouseover',
        initCallback: mycarousel_initCallback
    });
});

任何帮助将非常感激。

您可以使用以下脚本使其工作。 我在jquery.jcarousel.jsjquery-1.4.1上测试过它

要注意,我的jcarousel设置没有自动滚动。

<script>
jQuery(document).ready(function() {
    var _this = null;
    $('.jcarousel-next').mouseover(function() {
        if (!$(this).hasClass("jcarousel-next-disabled")) {
            _this = $(this);
            _this.click();
            window.setTimeout(CallAgain, 100);
        }
    });

    $('.jcarousel-next').mouseout(function() {
        if (!$(this).hasClass("jcarousel-next-disabled")) {
            _this = null;
        }
    });

    function CallAgain() {
        if (_this != null) {
            //alert("Inside Call again");
            _this.click();
            window.setTimeout(CallAgain, 100);
        }
    };

    $('.jcarousel-prev').mouseover(function() {
        if (!jQuery(this).hasClass("jcarousel-prev-disabled")){
            _this = $(this);
            _this.click();
            window.setTimeout(CallAgain, 100);
        }
    });

    $('.jcarousel-prev').mouseout(function() {
        if (!$(this).hasClass("jcarousel-next-disabled")) {
            _this = null;
        }
    });
});
</script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM