Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jQuery and animating around a central point
  2. var elem = $('h1:eq(0)')
  3.     .append('<span id="round" style="position:absolute;background-color:red;">&nbsp;</span>')
  4.     .css('position','relative')
  5.     .find('span#round');
  6.  
  7. var i = 0;
  8. setInterval(function(){    
  9.     ++i;  
  10.     elem.css({'left': Math.sin(i * 0.02) * 100, 'top': Math.cos(i * 0.02) * 100});}, 100);