jCarousel - how to get pause on hover with autoscroll?

后端 未结 4 1538
花落未央
花落未央 2020-12-16 19:54

JCarousel have recently changed (january 2011).
It used to have a way to implement pause on hover with autoscroll.

With the new version I cannot solve how to

相关标签:
4条回答
  • 2020-12-16 20:27

    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');
        });
    });
    
    0 讨论(0)
  • 2020-12-16 20:30

    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');
    });
    
    0 讨论(0)
  • 2020-12-16 20:36

    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' );
                })
    
      });
    
    0 讨论(0)
  • 2020-12-16 20:46

    add this code into your jcarousel initCallback(carousel)

     carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    }); 
    
    0 讨论(0)
提交回复
热议问题