Flickering/glitching issue while applying the CSS animation.

Hello everyone, I designed a "slide to unlock" component in React. It doesn't work as expected. Sometimes it's reappearing for a millisecond inside its container. I tried to change the timeout function inside animateBack() function but it didn't fix the issue. Here are pics of my code and CSS stylesheet. I also couldn't make it less DRY because TypeScript didn't allow me to combine both mouse events and touch events types...If you have any suggestions to how fix my code and maybe make it DRY, please! Thank you !
No description
No description
No description
No description
No description
No description