This is a nice solution for a problem occured when making strategy games or wireframe applications. Or generally when we want to select multiple items and have them in a visible group.
It is a rather simple solution once the math make sense.
Here’s a nice example I made on codepen. Simply click and drag to form a rectangle around one or both of the objects.