Question

var carousel = jQuery('#mycarousel').data('jcarousel');     
var index = carousel.size() + 1;
carousel.size(index); 
var html = '<li> some html </li>'; 
carousel.add(index, html);
carousel.scroll(index, 1);

The very last scroll method fires but not always. Is this a bug in JCarousel?

The following is the code for the scroll method in JCarousel:

/**
 * Scrolls the carousel to a certain position.
 *
 * @method scroll
 * @return undefined
 * @param i {Number} The index of the element to scoll to.
 * @param a {Boolean} Flag indicating whether to perform animation.
 */
scroll: function(i, a) {
    if (this.locked || this.animating)
        return;
    this.animate(this.pos(i), a);
}
Was it helpful?

Solution

@param a {Boolean} Flag indicating whether to perform animation.

Parameter 2 is a boolean. You've specified an integer:

carousel.scroll(index, 1);

So maybe this would work better:

carousel.scroll(index, true);

OTHER TIPS

please try something like this

var position = 11; // assuming that every page contains 10 elements.
// now this will move your scroll to a desired position (first element to show)
jQuery('#myCarousel').jcarousel('scroll',position);

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top