jCarousel - how to get pause on hover with autoscroll?

一曲冷凌霜 提交于 2019-11-29 04:07:06

add this code into your jcarousel initCallback(carousel)

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

I couldn't get the previous examples working. But I did get the following to work with the latest jcarousel.

$('.carousel').jcarouselAutoscroll(
{
    interval: 4000, 
    scroll: '+=1',
    create: $('.carousel').hover(function() 
    {
        $(this).jcarouselAutoscroll('stop');
    },
    function() 
    {
        $(this).jcarouselAutoscroll('start');
    });
});

Updating the answer to stay current.

See https://github.com/jsor/jcarousel/issues/568 for the correct answer:

$('.jcarousel').hover(function() {
    $(this).jcarouselAutoscroll('stop');
}, function() {
    $(this).jcarouselAutoscroll('start');
});

You can bind your own hover events in the create callback:

  .jcarouselAutoscroll({
    autostart: true,
    interval: 1000,
    scroll: '+=3',
    create: $('#thumbs').bind('mouseenter', function () {
                $(this).jcarouselAutoscroll('option', 'scroll', '+=0' );
            }).bind('mouseleave', function () {
                $(this).jcarouselAutoscroll('option', 'scroll', '+=3' );
            })

  });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!