How this works
One drag creates exactly one animated object. The drag start point becomes the thread's starting point. The drag direction decides the movement direction. The drag length decides the initial speed.
When the thread touches the left or right wall, its horizontal velocity is reversed. When it touches the top or bottom wall, its vertical velocity is reversed.
This is similar to a ball reflecting from a wall. The JavaScript animation is handled by
requestAnimationFrame().