Guest User

Untitled

a guest
Sep 15th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.22 KB | None | 0 0
  1.     $('#sidebar .myxpress_promote').hover(function(){
  2.         start_bubbles();
  3.     }, function(){
  4.         window.clearTimeout(h);
  5.     });
  6.    
  7.     function start_bubbles() {
  8.         new heart();
  9.         h = window.setTimeout(start_bubbles, 500);
  10.     }
  11.  
  12.     function heart() {
  13.         this.parent = $('#sidebar .myxpress_promote');
  14.         this.element = $('<span class="heart">♥</span>');
  15.         this.parent.append(this.element);
  16.         this.x = Math.floor(Math.random() * this.parent.width() + 20);
  17.         this.y = - ( Math.floor(Math.random()*this.element.height()) -10 );
  18.         this.ticks = 0;
  19.         this.size = Math.floor(Math.random() * 30 + 8);
  20.        
  21.         this.element.css({
  22.             'font-size' : this.size + 'px',
  23.             'left' : this.x + 'px',
  24.             'bottom' : this.y + 'px'
  25.         });
  26.        
  27.         this.tick = function() {
  28.             this.y += this.size / 30;
  29.             this.element.css({
  30.                 'left': Math.sin(this.ticks / 10.0) * this.size / 15.0 + this.x - this.element.width() / 1.0 + 'px',
  31.                 'bottom': this.y + 'px'
  32.             });
  33.             this.ticks++;
  34.             this.update = window.setTimeout(update_heart, 20, this);
  35.         }
  36.        
  37.         this.tick();
  38.         this.element.fadeOut({ duration: 6000, queue: false }, "easeOut");
  39.     }
  40.    
  41.     function update_heart(hrt) {
  42.         hrt.tick();
  43.         if(hrt.element.css("display")=="none") {
  44.             hrt.element.remove();
  45.             window.clearTimeout(hrt.update);
  46.         }
  47.     }
Add Comment
Please, Sign In to add comment