2011-01-24 72 views

回答

5

最簡單我能想到的是:

  1. 使相對
  2. 使動畫元素是上面
  3. 計算頂子,使用留下的中心點位置:
    math.sin(時間*(角/秒))*距離
    math.cos(....)

簡單的演示:

var elem = $('h1:eq(0)') 
    .append('<span id="round" style="position:absolute;background-color:red;">&nbsp;</span>') 
    .css('position','relative') 
    .find('span#round'); 

var i = 0; 
setInterval(function(){  
    ++i; 
    elem.css({'left': Math.sin(i * 0.02) * 100, 'top': Math.cos(i * 0.02) * 100});}, 100); 


看到它在行動jsfiddle