Posted By

brianyang on 12/07/09


Tagged

jquery plug-in


Versions (?)

jQuery Infinite Carousel


 / Published in: jQuery
 

  1. $(document).ready(function(){
  2.  
  3. //setup width on tour items
  4. var itemLeft = 0;
  5. $(".cz-setup-width").each(function(el){
  6. $(this).css("margin-left",itemLeft+"px");
  7. itemLeft = itemLeft+$(this).width();
  8. });
  9. $(".tour-note p:not(:first)").hide();
  10. var left = 0;
  11. var navLeft = 0;
  12. var inc = $(".tour-item:first").width();
  13. var paddingLeft = $(".back").width();
  14. var paddingRight = $(".forward").width();
  15. var leftTotal = left;
  16. var counter = 0;
  17. left = 0;
  18. $(".forward a").click(function(){
  19. if(counter+1 == $(".tour-nav a").size()){
  20. counter = 0;
  21. $(".tour-nav li:first a").click();
  22. return false;
  23. }
  24. $(".tour-note").css({opacity:0});
  25. left = (left+inc);
  26. $(".back").removeClass("disabled");
  27. var cur = $(".tour-nav li.active");
  28. cur.removeClass("active");
  29. cur.next("li").addClass("active");
  30. $(".tour-item-container").animate({
  31. marginLeft: "-"+(left)+"px"
  32. }, 500,'swing',function(){
  33. $(".tour-note p").hide();
  34. $(".tour-note p:eq("+counter+")").show();
  35. $(".tour-note").animate({opacity:1},500);
  36. });
  37. counter++;
  38. return false;
  39. });
  40. $(".back a").click(function(){
  41. if(counter == 0){
  42. counter = $(".tour-nav li").size()-1;
  43. $(".tour-nav li:last a").click();
  44. return false;
  45. }
  46. $(".tour-note").css({opacity:0});
  47. left = left-inc;
  48. var cur = $(".tour-nav li.active");
  49. cur.removeClass("active");
  50. cur.prev("li").addClass("active");
  51. navLeft = navLeft - 200;
  52. $(".tour-item-container").animate({
  53. marginLeft: "-"+(left)+"px"
  54. }, 500,'swing',function(){
  55. $(".tour-note p").hide();
  56. $(".tour-note p:eq("+counter+")").show();
  57. $(".tour-note").animate({opacity:1},500);
  58. });
  59. counter--;
  60.  
  61. });
  62. $(".tour-nav a").click(function(e){
  63. $(".tour-note").css({opacity:0});
  64. var index = $(".tour-nav a").index(this);
  65. counter = index;
  66. var go = (index*inc);
  67. var cur = $(".tour-nav li.active").removeClass("active");
  68. $(this).parents("li").addClass("active");
  69. $(".tour-item-container").animate({
  70. marginLeft: "-"+(go)+"px"
  71. }, 500,function(){
  72. $(".tour-note p").hide();
  73. $(".tour-note p:eq("+index+")").show();
  74. $(".tour-note").animate({opacity:1},500);
  75. } );
  76. left = go;
  77. return false;
  78. });
  79. }); //end document.ready

Report this snippet  

You need to login to post a comment.