Advertisement
Guest User

Rotating Quotes

a guest
Apr 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var quotes: {
  2.     element: null,
  3.     counter: 0,
  4.     index: 0,
  5.     array: [
  6.         "cool",
  7.         "moderno",
  8.         "prático",
  9.         "inovador",
  10.         "interessante",
  11.         "smart",
  12.         "Mad Bird",
  13.         "econômico",
  14.         "inteligente"
  15.     ],
  16.    
  17.     initialize: function(){
  18.         quotes.element = $(".rotatingQuotes").find("#elogio");
  19.         $(window).scroll(quotes.update());
  20.         quotes.update();
  21.     },
  22.  
  23.     update: function() {
  24.         if (quotes.counter >= 10) {
  25.             quotes.rotate();
  26.             quotes.counter = 0;
  27.         } else {
  28.             quotes.counter++;
  29.         }
  30.     },
  31.  
  32.     rotate: function() {
  33.         if (quotes.index == quotes.array.length) {
  34.             quotes.index = 0;
  35.         }
  36.         var quote = quotes.array[quotes.index];
  37.         quotes.element.fadeOut(0, function() {
  38.             $(this).text(quote).fadeIn(100);
  39.         });
  40.         quotes.index++;
  41.     }
  42. };
  43.  
  44.  
  45. $(document).ready(function() {
  46.     quotes.initialize();
  47. });
  48.  
  49. /*
  50. <div class="rotatingQuotes">
  51.     <div class="text">
  52.         Ser <span id="resp-cor">responsivo</span> é ser <span id="elogio" style=""></span>
  53.     </div>
  54. </div>
  55. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement