Sad part is most of that fancy scripting for the animation smoothing could have simply been done by adding a CSS transition to it. Set it to like a quarter of a second, and it would smooth out the input.
transition:top 0.2s, left 0.2s;
And be done with it. Wouldn't even need to play with requestAnimationFrame.
This is 2020, JavaScript is NOT the answer to every blasted problem.