I've written a css animation using keyframes for svg path
path {
animation: anim 1s linear;
animation-fill-mode: forwards;
}
@keyframes anim {
50% {
d: path('M20 20 L 20 20');
}
100% {
d: path('M10 10 L 30 30');
}
}
<path class="top" d="M10 10 L 30 10" stroke-width="2" stroke="black" fill="transparent" />
If you click on the svg you can see the animation in action. Now, if you click again I want it to animation to its original state. I've tried adding
transition: all 1s ease-out;
and
animation-direction: alternate;
But still there is no animation back to its initial state.
So the question is, how can I animate back?