Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery plugin to make an element orbit another? [closed]

REVISED: Are there any jQuery plugins that can revolve one element around another?

EDIT: By "orbiting", I mean rotating on the same z-index around another element.

like image 918
Voriki Avatar asked Sep 17 '11 12:09

Voriki


1 Answers

THIS ANSWER SUPERCEDED BY MY OTHER RESPONSE TO THIS QUESTION.


You could use the ".animate()" method to modify the "top" and "left" properties of the element. Here is an example fiddle.

HTML:

  <div id='moon' > moon  </div>
  <div id='earth'> earth </div>

CSS:

#moon        {position:        absolute;
             top:             0px;
             left:            0px;
             width:           50px;
             height:          50px;
             background-color: #aaaaff;}
#earth      {position:        absolute;
             top:             50px;
             left:            50px;
             width:           50px;
             height:          50px;
             background-color: #ffaaaa;}

Javascript:

 $('#moon').animate({left: 100}, 2000)
           .animate({top:  100}, 2000)
           .animate({left:   0}, 2000)
           .animate({top:    0}, 2000);    
like image 82
Neil Avatar answered Oct 22 '22 07:10

Neil