I have a red box as the element to animate.
Here is a simple representation of how I want to animate the red box.
Here is a try but as you see the anchor point of the movement is at the left of the box no the center as I wish to be:
.yo-yo {
display: block;
position: absolute;
height: 50px;
width: 200px;
background: red;
transform-origin: 50% 50%;
animation: yo-yo 0.5s infinite alternate; /* Animation speed and type */
}
/* Animation beginning and ending */
@keyframes yo-yo {
from { left: 0 }
to { left: 20px }
}
<span class="yo-yo"></span>
Here is the script tag of that specific version of TweenMax:
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TweenMax.min.js" integrity="sha512-DkPsH9LzNzZaZjCszwKrooKwgjArJDiEjA5tTgr3YX4E6TYv93ICS8T41yFHJnnSmGpnf0Mvb5NhScYbwvhn2w==" crossorigin="anonymous"></script>