2010-05-14 3 views
1
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); 

La toute dernière méthode de défilement se déclenche mais pas toujours. Est-ce un bug dans JCarousel?La méthode de défilement JCarousel ne se déclenche pas toujours

Ce qui suit est le code de la méthode de défilement dans 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); 
} 

Répondre

1

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

Paramètre 2 est une valeur booléenne. Vous avez spécifié un nombre entier:

carousel.scroll(index, 1);

Alors peut-être cela fonctionnerait mieux:

carousel.scroll(index, true);

1

s'il vous plaît essayer quelque chose comme ça

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); 

Espérons que cela aide!

Questions connexes