Work out the position of the point to the edge of the screen from the start and end points, then move your square from the start point to the edge point of the screen. If you need to move it out of the screen, just move the edge point a little outside the screen.
Work out the position of the point to the edge of the screen from the start and end points, then move your square from the start point to the edge point of the screen.
If you need to move it out of the screen, just move the edge point a little outside the screen.
If you want such an animation, just specify the beginning and end positions directly, no need to worry about the intermediate process
pseudocode
This is a small demo I wrote. Can you understand it? https://github.com/KarmaChen/TestViewAnimation.git