Guest User

Untitled

a guest
Oct 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. // Set the initial state: Hide all but the first slide
  4. $('.slideshow').find('> div:eq(0)').nextAll().css({'opacity':'0','display':'none'});
  5.  
  6. // On click of a controller link...
  7. $('.controls > a').click(function(event) {
  8. event.preventDefault();
  9.  
  10. // Get the div containing the clicked link...
  11. var currentslide = $(this).parents('div:first');
  12.  
  13. // ... and get the index of that div
  14. var currentposition = $('.slideshow div').index(currentslide);
  15.  
  16. // Use that index to get the slide we'll be fading to
  17. var nextposition = ($(this).attr('class')=='next') ? currentposition+1 : currentposition-1;
  18.  
  19. // Fade the current slide out...
  20. $('.slideshow div:eq('+currentposition+')').animate({opacity: 0}, 250, function() {
  21.  
  22. // ... and hide it.
  23. $('.slideshow div:eq('+currentposition+')').css('display','none');
  24.  
  25. // Show the next slide...
  26. $('.slideshow div:eq('+nextposition+')').css('display','block');
  27.  
  28. // ... and fade it in.
  29. $('.slideshow div:eq('+nextposition+')').animate({opacity: 100}, 1500);
  30. }
  31. );
  32. });
  33.  
  34. });
Add Comment
Please, Sign In to add comment