Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of Vigrant

Vigrant

Vigrant has asked 1 questions and find answers to 1 problems.

Stats

60
EtPoint
23
Vote count
1
questions
1
answers

About

https://github.com/rdsilver/

// Fish tank
numElements = $('*:visible').length;
function moveRandomElement() {
  let elementNum = Math.floor(numElements * Math.random());
  let $element = $('*:visible').eq(elementNum);

  $element.css('position', 'relative');
  let top = $element.css('top') ? parseInt($element.css('top')) : 0;
  let left = $element.css('left') ? parseInt($element.css('left')) : 0;

  if (Math.random() > .5) {
   $element.animate({
    'top': top + Math.cos(Math.random() * 100) * 50 + 'px'
   }, 2000);
  } else {
   $element.animate({
    'left': left + Math.cos(Math.random() * 100) * 50 + 'px'
   }, 2000);
  }
}

window.setInterval(function(){
  moveRandomElement();
}, 10);