2011-04-14 53 views
2

我用低于js文件:JQuery JCarousel(不是精简版)和mousewheel。需要帮助

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();} 

我想添加mousewheel到我的jcarousel,但我不能找到适当的功能,当我滚动我的轮时被调用。 请帮帮我。可能需要更多信息。直到现在,我一直在做我自己的事情。 :(

回答

3

carousel.prev();和carousel.next();不会因为转盘工作未定义您需要指定您可以手动运行该转盘功能的回调函数

有关。例如:

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

希望这有助于

3

插入我的代码片段我! n您的jquery.jcarousel.js 此行之后:

$(窗口).bind( 'load.jcarousel',函数(){windowLoaded = TRUE; });

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