jsor / jcarousel

Riding carousels with jQuery.
https://sorgalla.com/jcarousel/
MIT License
1.99k stars 734 forks source link

jCarousel waits to finish animation before reloading #752

Closed cortopy closed 9 years ago

cortopy commented 9 years ago

I am displaying products in a continous jcarousel. It's set up like this:

$('.jcarousel').jcarousel({
        wrap: 'circular',
        animation: {
        duration: 7000,
        easing:   'linear'
        }
    })
    .jcarouselAutoscroll({
        interval: 0
    })

The problem with this is that there are no controls to interact with it. I'm trying to create buttons to fast forward/backward.

My code is working fine. However, it creates an important glitch which I can't get rid off:

var carouselFastForward = function () {
    $('.jcarousel').jcarousel('reload', {
        animation: {
        duration: 1500,
        easing:   'linear'
        }
    })
    .jcarouselAutoscroll({
        interval: 0
    });
};
$('.carousel-prev').click(carouselFastForward);

As I said this does the trick with a big BUT. The carousel flickers and then nothing seems to happen. At first, I thought my code wasn't working. However, it turns out jCarousel will not change duration/speed until the animation on the disappearing

  • element is finished. This means there can be nearly up to 7 seconds delay in reloading the new settings.

    The same behaviour happens if I try the following. jCarousel doesn't stop until animation on the disappearing

  • has completed

    $j('.carousel-prev').click(function() {
        $j('.jcarousel').jcarouselAutoscroll('stop');
        //reloading options
    });

    I'm wondering why jCarousel waits for the animation to finish before accepting any new options. Could the animation be stopped immediately to allow for immediate reloading of options?

  • jsor commented 9 years ago

    jCarousel is unfortunately not suited for continous scrolling as it is locked while animating.

    cortopy commented 9 years ago

    That explains the behaviour then. Smooth scrolling was working perfect without controls though. I guess I got carried away. Thanks for clarifying this @jsor