Guest User

Untitled

a guest
Nov 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. var isAnimating = false;
  2.  
  3. $('.toggle').click(function() {
  4.  
  5. //Only run it if it's not animating
  6. if(!isAnimating) {
  7.  
  8. isAnimating = true;
  9.  
  10. menu.toggleClass('open');
  11.  
  12. item = $('.item');
  13.  
  14. $.each($(item), function(i, el) {
  15.  
  16. $(el).css({'opacity': 0});
  17.  
  18. setTimeout(function() {
  19. $(el).toggleClass('open').animate({
  20. 'opacity': 1.0
  21. }, 450);
  22. },50 + ( i * 200 ));
  23.  
  24. });
  25.  
  26. //It just triggers it as many times as there are elements..
  27. isAnimating = false;
  28. }
  29. });
Add Comment
Please, Sign In to add comment