2013-04-25 86 views
-1

我去过很多答案,但没有一个答案我的问题。我有这个JCarousel,自动滚屏。我希望它停止悬停,我需要在我的代码中添加什么?暂停鼠标悬停不能在JCarousel上工作

<script type="text/javascript"> 

jQuery(document).ready(function() { 
    jQuery('#mycarousel').jcarousel({ 
     auto: 1, 
     wrap: 'circular', 
     vertical: true, 
     animation: 3500, 
     pauseOnHover: true, 
     scroll:1, 
    }); 
}); 
</script> 

在此先感谢你们!

回答

0

在你的初始化添加以下代码:initCallback(carousel)

carousel.clip.hover(function() { 
    carousel.stopAuto(); 
}, function() { 
    carousel.startAuto(); 
}); 

这在一个的jCarousel被bug甚至提及。

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

您可以编辑我提供的代码,包括这一个?我是这个新手,所以我不知道在哪里插入它。抱歉。 – 2013-04-25 04:57:16

+0

没有。它不在你的代码中。你需要编辑插件文件。 – 2013-04-25 08:37:58

1

下面是如何使鼠标悬停在工作的jCarousel

一步暂停的resoudere promeble步骤:1使该功能在我们的安全(file.js)的根。

function mycarousel_initCallback(carousel) 
{ 
    carousel.clip.hover(function() { 
     carousel.stopAuto(); 
    }, function() { 
     carousel.startAuto(); 
    }); 
}; 

第2步:使该功能在准备功能

jQuery(document).ready(function() { 

//exemple 
jQuery('#carosule ul').jcarousel({ 
    scroll:1, 
    visible:4, 
    wrap:"circular", 
    animation:300, 
    auto:1, 
    hoverPause: true, 
    width: 160, 
    initCallback: mycarousel_initCallback 

    }); 

});