JQuery JCarousel(不是lite)和鼠标滚轮.需要帮助

JQuery JCarousel (not lite) and mousewheel. need help

本文关键字:帮助 鼠标 JCarousel 不是 lite JQuery      更新时间:2023-09-26

我使用下面的js文件:

jquery-1.4.2.min.js
include/jcarousel/lib/jquery.jcarousel.min.js
include/mousewheel/jquery.mousewheel.js

在我的index.php文件中,我得到:

 jQuery(document).ready(function() {
jQuery('#mycarousel').mousewheel(function(event, delta) {
                    if (delta > 0)
                    {carousel.prev();}
                    else if (delta < 0)
                    {carousel.next();}
        });
jQuery('#mycarousel').jcarousel({
    size: mycarousel_itemList.length,
    itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback},
visible: 3,
btnNext: null,
 btnPrev: null,
});
});

我认为问题出在

{carousel.prev();}
{carousel.next();}

我想添加鼠标轮到我的jcarousel,但我找不到适当的函数要调用当我滚动我的车轮。请帮帮我。可能需要进一步的资料。到现在为止我都是靠自己。(

carousel.prev();和carousel.next ();将不工作,因为旋转木马是未定义的。您需要指定一个回调函数,然后可以在其中手动运行carousel函数。

例如:

jQuery('#mycarousel').jcarousel({    
    size: mycarousel_itemList.length,
    itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback},
    visible: 3,
    btnNext: null,
    btnPrev: null,
    // The callback function to run
    initCallback: mycarousel_initCallback,    
});
function mycarousel_initCallback(carousel) {
    // All code referencing the carousel in here.
    jQuery('#mycarousel').mousewheel(function(event, delta) {
        if (delta > 0)
            {carousel.prev();}
        else if (delta < 0)
            {carousel.next();}
        });
}

在这个例子中阅读更多内容:http://sorgalla.com/projects/jcarousel/examples/static_controls.html

希望这对你有帮助!

插入我的代码片段到你的jquery.jcarousel.js这行之后:

(窗口).bind(美元的负载。jcarousel', function() {windowLoaded = true;});

// Activate the mouse wheel function --------------------------
$('.jcarousel').bind('mousewheel', function(event, delta) {
    if (delta > 0)
        self.prev();
    else if (delta < 0)
        self.next();
});