SlideDeck AutoPlay Functionality with First Slide Delay


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var loopingInterval;
  2. var mySlideDeck = jQuery('.slidedeck').slidedeck();
  3. mySlideDeck.vertical();
  4. var interval = 1000;
  5. var firstDelay = 3000;
  6.  
  7.  
  8. // initialize an autoplay switch
  9. var autoPlay = false;
  10. var autoPlayLoop = true;
  11.  
  12. function autoPlayAdvanceLoop(){
  13. if(autoPlay){
  14. // Check to see if the current slide is the last slide
  15. if(mySlideDeck.current == mySlideDeck.slides.length && autoPlayLoop == true){
  16. // This is the last slide, go to the first slide
  17. mySlideDeck.goTo(1);
  18. } else {
  19. // This is not the last slide, go to the next slide
  20. mySlideDeck.next();
  21. }
  22. }
  23. }
  24.  
  25. // sets an initial delay
  26. setTimeout(function(){
  27. loopingInterval = setInterval(autoPlayAdvanceLoop,interval); // Run the autoPlayAdvanceLoop() function every interval milliseconds
  28. }, firstDelay - interval)
  29.  
  30. autoPlay = true;
  31.  
  32. // Stop autoPlay if the deck is clicked.
  33. jQuery('.slidedeck').click(function(){
  34. autoPlay = false;
  35. clearInterval(loopingInterval);
  36. });

URL: http://getsatisfaction.com/slidedeck/topics/slide_time

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.