6

animation across an Arc

Is it possible with current CSS3 to animate an object (DIV) along an this arc?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Adam Wojda
  • 749
  • 1
  • 7
  • 14

3 Answers3

8

Check this

http://dabblet.com/gist/1615901

.wrapper {
    width: 500px;
    margin: 300px 0 0;
    transition: all 1s;
    transform-origin: 50% 50%;
}
.inner {
    display: inline-block;
    padding: 1em;
    transition: transform 1s;
    background: lime;
}
html:hover .wrapper {
    transform: rotate(180deg);
}
html:hover .inner {
    transform: rotate(-180deg);
}
Arun Bertil
  • 4,598
  • 4
  • 33
  • 59
8

I've forked the (very good) @ArunBertil "fulcrum" solution to convert it to CSS3 Animation:

Running Demo

CSS

@keyframes drawArc1 {
    0%   { transform: rotate(180deg);  }
    100% { transform: rotate(0deg);    }
}

@keyframes drawArc2 {
    0%   { transform: rotate(-180deg); }
    100% { transform: rotate(0deg);    }
}

body{
    padding: 150px;    
    background: black;
}

.wrapper {
    width: 300px;
    animation: drawArc1 3s linear infinite;
}

.inner {    
    border-radius: 50%;
    display: inline-block;
    padding: 30px;    
    background: yellowgreen;
    animation: drawArc2 3s linear infinite;
}

HTML

<div class="wrapper">
    <div class="inner"></div>
</div>

Watch it on FireFox... to run it on other browsers, simply put the prefixes (@-webkit-keyframes, etc)

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
6

Well, working on the work of Andrea based on the work of Arun ...

simplified to make use of only 1 div, and 1 animation:

@keyframes drawArc {
    0% { transform: rotate(0deg) translateX(150px) rotate(0deg) ;}
    100%{ transform: rotate(-180deg) translateX(150px) rotate(180deg);  }
}
@-webkit-keyframes drawArc {
    0% { -webkit-transform: rotate(0deg) translateX(150px) rotate(0deg) ;}
    100%{ -webkit-transform: rotate(-180deg) translateX(150px) rotate(180deg);  }
}


body{
    padding: 150px;    
    background: black;
}

.test {
    width: 30px;    
    border-radius: 50%;
    display: inline-block;
    padding: 30px;    
    background: yellowgreen;
    animation: drawArc 3s linear infinite;
    -webkit-animation: drawArc 3s linear infinite;
}

demo

Added also text in the div to show that it doesn't rotate

vals
  • 61,425
  • 11
  • 89
  • 138