Ok folks, I really need some help here, it's blowing my mind...
Please take a look at the following example:
https://jsfiddle.net/t0Lahyjy/
HTML:
<div id="exmpl"></div>
<button id="btn">Try it</button>
CSS:
#exmpl {
margin: 100px auto 0 auto;
height: 100px;
width: 10px;
background: #000;
-webkit-animation: anim 3s infinite linear;
animation: anim 3s infinite linear;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
@-webkit-keyframes anim {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes anim {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#btn {
margin: 100px auto 0 auto;
display:block;
}
.animationIsOff {
}
JS:
document.getElementById("btn").addEventListener("click", function(){
document.getElementById("btn").className += " animationIsOff";
});
Now look, what I want is... to get the smooth animation from the rotation state of default to the transform: rotate(90deg);
when #btn
clicked. I wanna do it with adding a new class, say animationIsOff
, but there's no smoothness between this two states. IF there's no way to accomplish this smoothness with CSS(by only adding a class with JS), perhaps there's a way to do it with help of JS?
I hope I'm pretty clear to you, otherwise please do ask... I will describe it as I can further.