I use a css animation to represent the sun cycle for a day (from 6AM to 6PM). Unfortunatly, I want also to be able to set the current percentage depending on the time of the day (for example, if the current time is 12AM, I want to put the sun at 50% of the animation.
Here is my jsfiddle : http://jsfiddle.net/vyhjt6mu/3/
and Here is my code :
/* Chrome, Safari, Opera */
@-webkit-keyframes sunAnimation {
0% {
left: -100px;
top: 30%;
}
25% {
left: calc(25% - 25px);
top: 20%;
}
50% {
left: calc(50% - 40px);
top: 10%;
}
75% {
left: calc(75% + 25px);
top: 20%;
}
100% {
left: calc(100% + 100px);
top: 30%;
}
}
@keyframes sunAnimation {
0% {
left: -100px;
top: 30%;
}
25% {
left: calc(25% - 25px);
top: 20%;
}
50% {
left: calc(50% - 40px);
top: 10%;
}
75% {
left: calc(75% + 25px);
top: 20%;
}
100% {
left: calc(100% + 100px);
top: 30%;
}
}
.sun {
width: 100px;
height: 100px;
position: absolute;
animation-name: sunAnimation;
animation-duration: 60s;
animation-timing-function: linear;
-webkit-animation-name: sunAnimation;
/* Chrome, Safari, Opera */
-webkit-animation-duration: 60s;
/* Chrome, Safari, Opera */
-webkit-animation-timing-function: linear;
/* Chrome, Safari, Opera */
}
How can I simply set the current percentage of a css3 animation ? If it's very complex to do it, does a library exist for that ?
Thanks for your help.
It's not a duplicate because the needs are different.