Advertisement
Guest User

Untitled

a guest
May 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.     //custom
  3.     var item = ".feature-box";
  4.     var in_anim = 'bounceInDown';
  5.     var out_anim = 'bounceOutLeft';
  6.     var duration = 4000;
  7.     var timeout_to_next = 500;
  8.     //helper
  9.     var canchange = false;
  10.     var current = 0;
  11.     var all = $(item).children();
  12.     var cycle = [];
  13.     all.each(function(i){
  14.         cycle[i] = $(this);
  15.         $(this).css('display','none');
  16.     });
  17.     cycle[current].css('display', 'block');
  18.    
  19.     setInterval(function(){
  20.         canchange = true;
  21.         cycle[current].removeClass('animated '+in_anim);
  22.         cycle[cycle.length-1].removeClass('animated '+out_anim);
  23.         cycle[current].addClass('animated '+out_anim);
  24.  
  25.         setTimeout(function(){
  26.             cycle[current].css('display', 'none');
  27.             if (current == cycle.length-1) {
  28.                 current = 0;
  29.             } else {
  30.                 current++;
  31.             }
  32.             cycle[current].css('display', 'block');
  33.         }, timeout_to_next);
  34.        
  35.         if (current < 2) {
  36.             cycle[current+1].addClass('animated '+in_anim);
  37.         } else {
  38.             cycle[0].addClass('animated '+in_anim);
  39.             reset();
  40.         }
  41.  
  42.     }, duration);
  43.    
  44.     function reset() {
  45.         for (var a = 0; a < cycle.length; a++){
  46.             cycle[a].removeClass('animated '+out_anim);
  47.         }
  48.         cycle[cycle.length-1].addClass('animated '+out_anim);
  49.         cycle[0].addClass('animated '+in_anim);
  50.     }
  51.    
  52. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement