Guest User

Untitled

a guest
Jul 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <div id="slider">
  2. <div class="wrap">
  3. <div class="panel">Panel1</div>
  4. <div class="panel">Panel2</div>
  5. <div class="panel">Panel3</div>
  6. </div>
  7.  
  8. <div class="previous">This need Implementation</div>
  9. <div class="next">This need Implementation</div>
  10.  
  11. </div>
  12.  
  13. <div class="nav">
  14.  
  15. <ul>
  16. <li> panel1</li>
  17. <li> panel2</li>
  18. <li> panel3</li>
  19. <ul>
  20.  
  21. </div>
  22.  
  23.  
  24. $(document).ready(function () {
  25.  
  26. $(".wrap .panel:not(.active)").fadeOut();
  27. $(".wrap .panel:first(.active)").fadeIn();
  28.  
  29. $(".nav ul li").click(function (event) {
  30.  
  31. $(this).addClass('current').siblings().removeClass('current');
  32.  
  33. $(".wrap .panel").stop(true, true).fadeOut().eq($(this).index()).fadeIn();
  34.  
  35. });
  36. });
  37.  
  38. var currentIndex = 0;// store current pane index displayed
  39. var ePanes = $('#slider .panel');// store panes collection
  40. function showPane(index){// generic showPane
  41. // hide current pane
  42. ePanes.eq(currentIndex).stop(true, true).fadeOut();
  43. // set current index : check in panes collection length
  44. currentIndex = index;
  45. if(currentIndex < 0) currentIndex = ePanes.length-1;
  46. else if(currentIndex >= ePanes.length) currentIndex = 0;
  47. // display pane
  48. ePanes.eq(currentIndex).stop(true, true).fadeIn();
  49. // menu selection
  50. $('.nav li').removeClass('current').eq(currentIndex).addClass('current');
  51. }
  52. // bind ul links
  53. $('.nav li').click(function(ev){ showPane($(this).index());});
  54. // bind previous & next links
  55. $('.previous').click(function(){ showPane(currentIndex-1);});
  56. $('.next').click(function(){ showPane(currentIndex+1);});
  57. // apply start pane
  58. showPane(0);
Add Comment
Please, Sign In to add comment