I don't have much experience with coding, so I was hoping for some assistance.
My goal was to create a div that moves back and forth using toggleClass;
$('div').on('click', function() {
$(this).toggleClass('active');
});
as well as keyframes;
.active {
animation-name: moveme;
animation-duration: 1s;
animation-timing-function: linear;
animation-fill-mode: forwards;
}
@keyframes moveme {
0% {transform: translate(0,0)}
50% {transform: translate(-200px, 0px)}
100% {transform: translate(-200px,-50px);}
}
However, when the div returns to its original position, it does not animate. I would like the div to animate in reverse with the same animation. Is there a way to achieve this?
You can view what I'm attempting to do here jsfiddle.net/jmrMW/43/ The example is simple now, but it will become more complex in the future.
Thank you kindly for your help! ^^