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);
最后一个滚动方法会触发,但并非总是如此。这是 JCarousel 中的错误吗?
下面是JCarousel中scroll方法的代码:
/**
* 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);
}