Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. $('div.showarea').fadeOut(0);
  2. $('div.showarea:first').fadeIn(500);
  3.  
  4. $('a.leftarrow, a.rightarrow').click( function (ev) {
  5. //prevent browser jumping to top
  6. ev.preventDefault();
  7.  
  8. //get current visible item
  9. var $visibleItem = $('div.showarea:visible');
  10.  
  11. //get total item count
  12. var total = $('div.showarea').length;
  13.  
  14. //get index of current visible item
  15. var index = $visibleItem.prevAll().length;
  16.  
  17. //if we click next increment current index, else decrease index
  18. $(this).attr('href') === '#carouselNext' ? index++ : index--;
  19.  
  20. //if we are now past the beginning or end show the last or first item
  21. if (index === -1){
  22. index = total-1;
  23. }
  24. if (index === total){
  25. index = 0
  26. }
  27.  
  28. //hide current show item
  29. $visibleItem.hide();
  30.  
  31. //fade in the relevant item
  32. $('div.showarea:eq(' + index + ')').fadeIn(500);
  33.  
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement