This is actually not complicated:
function moveDiv(t,mdiv) { t = t + 0.05; // "time" var r = 10, //radius of circle xcenter = 400, //x location of circles centre on screen ycenter = 400, //y location of circles centre on screen x = Math.floor(xcenter + (r * Math.cos(t))), //circles parametric function y = Math.floor(ycenter + (r * Math.sin(t))); //circles parametric function mDiv.style.top = x + "px"; //set divs new coordinates mDiv.style.left = y + "px"; //set divs new coordinates setTimeout(function() { //make sure the animation keeps going moveDiv(t,mdiv); }, 100); } myDiv = //get div element moveDiv(1,myDiv); //start the animation
Not tested, but it's about how it should work. Make sure the css "position" property for these divs is absolute or fixed. Also consider the parametric equation for the circle.
Maiku mori
source share