kswedberg / jquery-carousel-lite

A jQuery carousel plugin based on jCarouselLite by Ganeshji Marwaha
MIT License
177 stars 59 forks source link

when itemLength lessthan visibleCeil and circular enable , it's show the same image three times #34

Closed ahmad-saad closed 10 years ago

ahmad-saad commented 10 years ago

e.g: if I put visibleCeil =3 and put just 1 image then the code show me this image three times.

I add this condition to solve the problem , perhaps u can fix it in another way:

Lines (60 - 70)

var li = ul.children('li'),
itemLength = li.length;     
if (o.circular && itemLength > visibleCeil) {

  beforeCirc = tLi.slice( tl - visibleCeil ).clone(true).each(fixIds);
  afterCirc = tLi.slice( 0, visibleCeil ).clone(true).each(fixIds);
  ul.prepend( beforeCirc )
    .append( afterCirc );
  start += visibleCeil;
  activeBtnOffset = visibleCeil;

}
travco commented 10 years ago

Invalid Issue?

Please correct me if I'm not understanding this correctly, but this is an issue caused by having fewer elements to display than elements displayed?

If you're making a carousel with fewer elements than it is displaying, there is no point in it cycling, because it won't display anything new. It kinda negates the purpose of having the carousel. I can understand why you'd want it to bail or cease displaying if it's making copies, but that would be adding code to prevent what is basically improper use. Ultimately making it more costly to run when configured correctly.

kswedberg commented 10 years ago

I think the best solution would be to use the init callback option to bail out if the number of the <li>s is less than or equal to the visible option. See https://github.com/kswedberg/jquery-carousel-lite#init--function---callback for an example