Moving an element along a circle

It all started a few months ago, when Chris Coyier casually asked me how would I move an element along a circle, without of course rotating the element itself. If I recall correctly, his solution was to use multiple keyframes, for various points on a c…


This content originally appeared on Lea Verou’s blog and was authored by Lea Verou

It all started a few months ago, when Chris Coyier casually asked me how would I move an element along a circle, without of course rotating the element itself. If I recall correctly, his solution was to use multiple keyframes, for various points on a circle’s circumference, approximating it. I couldn’t think of anything better at the time, but the question was stuck in the back of my head. 3 months ago, I came up with a first solution. Unfortunately, it required an extra wrapper element. The idea was to use two rotate transforms with different origins and opposite angles that cancel each other at any given time. The first transform-origin would be the center of the circle path and the other one the center of the element. Because we can’t use multiple transform-origins, a wrapper element was needed.

So, even though this solution was better, I wasn’t fully satisfied with it due to the need for the extra element. So, it kept being stuck in the back of my head.

Recently, I suggested to www-style that transform-origin should be a list and accept multiple origins and presented this example as a use case. And then Aryeh Gregor came up with this genius idea to prove that it’s already possible if you chain translate() transforms between the opposite rotates.

I simplified the code a bit, and here it is:

With the tools we currently have, I don’t think it gets any simpler than that.


This content originally appeared on Lea Verou’s blog and was authored by Lea Verou


Print Share Comment Cite Upload Translate Updates
APA

Lea Verou | Sciencx (2012-02-08T00:00:00+00:00) Moving an element along a circle. Retrieved from https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/

MLA
" » Moving an element along a circle." Lea Verou | Sciencx - Wednesday February 8, 2012, https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/
HARVARD
Lea Verou | Sciencx Wednesday February 8, 2012 » Moving an element along a circle., viewed ,<https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/>
VANCOUVER
Lea Verou | Sciencx - » Moving an element along a circle. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/
CHICAGO
" » Moving an element along a circle." Lea Verou | Sciencx - Accessed . https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/
IEEE
" » Moving an element along a circle." Lea Verou | Sciencx [Online]. Available: https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/. [Accessed: ]
rf:citation
» Moving an element along a circle | Lea Verou | Sciencx | https://www.scien.cx/2012/02/08/moving-an-element-along-a-circle/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.