Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
101
reputation
1

Vigrant

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);
  • Austin, TX, USA
  • Member for 7 years, 4 months
  • 0 profile views
  • Last seen Aug 30 at 22:06