Slider Issue

Slider Issue

This almost works... almost.

  1. $(document).ready(function(){

  2. var n = 0;
  3.     var totalImageWidth = 0;
  4. var totalLi = $('#containerBadgeC li').size();
  5. var totalLiScroll = totalLi - 4;
  6. for(i=0; i<totalLi; i++) { 
  7.     totalImageWidth += $('#containerBadgeC ul li').eq(i).outerWidth( true );
  8. }
  9. $('#containerBadgeC').css('width', totalImageWidth);

  10. $('.arrowRight').click(function() {
  11. $('#containerBadgeC ul li').eq(n).animate(
  12. {width:'hide',marginRight:'0',opacity: 'hide'},
  13. {duration: 600, easing: 'swing', queue: true}
  14. );
  15. if (n >= totalLiScroll )
  16.   n = totalLiScroll;
  17.   }
  18.   else
  19.   {n++;}
  20. });
  21. $('.arrowLeft').click(function() {
  22. if (n <= 0 )
  23.   n = 0;
  24.   }
  25. else if(n <= totalLiScroll){
  26. n--;
  27. $('#containerBadgeC ul li').eq(n).animate(
  28. {width:'show',marginRight:'40px',opacity: 'show'},
  29. {duration: 600, easing: 'swing', queue: true}
  30. );
  31. }
  32. });
  33. });
This here is speaking to an unordered list which contains button like images all of the same height but of varying widths. The code actually does work for the most part except when say there is 20 items, when going from left to right the 17th disappears and never reappears.

The items slide either left or right when using arrow images that are parallel to the image slider. The right button makes it go right and the left makes it go left.